mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-26 00:39:03 +00:00
[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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user