[RFC] Move logic for test registration to the test harness (#2151)

And use in device_timer suite.

Signed-off-by: Kévin Petit <kpet@free.fr>
This commit is contained in:
Kévin Petit
2024-11-26 17:55:09 +00:00
committed by GitHub
parent df5e87bf97
commit 0a1456d8f9
36 changed files with 307 additions and 352 deletions

View File

@@ -36,56 +36,6 @@
return -1; \
} while (0)
class baseTestClass {
public:
baseTestClass() {}
virtual test_function_pointer getFunction() = 0;
};
class spirvTestsRegistry {
private:
std::vector<baseTestClass *> testClasses;
std::vector<test_definition> testDefinitions;
public:
static spirvTestsRegistry &getInstance();
test_definition *getTestDefinitions();
size_t getNumTests();
void addTestClass(baseTestClass *test, const char *testName,
Version version);
spirvTestsRegistry() {}
};
template <typename T> T *createAndRegister(const char *name, Version version)
{
T *testClass = new T();
spirvTestsRegistry::getInstance().addTestClass((baseTestClass *)testClass,
name, version);
return testClass;
}
#define TEST_SPIRV_FUNC_VERSION(name, version) \
extern int test_##name(cl_device_id deviceID, cl_context context, \
cl_command_queue queue, int num_elements); \
class test_##name##_class : public baseTestClass { \
private: \
test_function_pointer fn; \
\
public: \
test_##name##_class(): fn(test_##name) {} \
test_function_pointer getFunction() { return fn; } \
}; \
test_##name##_class *var_##name = \
createAndRegister<test_##name##_class>(#name, version); \
int test_##name(cl_device_id deviceID, cl_context context, \
cl_command_queue queue, int num_elements)
#define TEST_SPIRV_FUNC(name) TEST_SPIRV_FUNC_VERSION(name, Version(1, 2))
struct spec_const
{
spec_const(cl_int id = 0, size_t sizet = 0, const void *value = NULL)