mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +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:
@@ -62,6 +62,27 @@ bool gCoreILProgram = true;
|
||||
|
||||
#define DEFAULT_NUM_ELEMENTS 0x4000
|
||||
|
||||
test_definition *test_registry::definitions() { return &m_definitions[0]; }
|
||||
|
||||
size_t test_registry::num_tests() { return m_definitions.size(); }
|
||||
|
||||
void test_registry::add_test(test *t, const char *name, Version version)
|
||||
{
|
||||
|
||||
m_tests.push_back(t);
|
||||
test_definition testDef;
|
||||
testDef.func = t->getFunction();
|
||||
testDef.name = name;
|
||||
testDef.min_version = version;
|
||||
m_definitions.push_back(testDef);
|
||||
}
|
||||
|
||||
test_registry &test_registry::getInstance()
|
||||
{
|
||||
static test_registry instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
static int saveResultsToJson(const char *suiteName, test_definition testList[],
|
||||
unsigned char selectedTestList[],
|
||||
test_status resultTestList[], int testNum)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Version {
|
||||
public:
|
||||
@@ -99,6 +100,53 @@ struct test_harness_config
|
||||
unsigned numWorkerThreads;
|
||||
};
|
||||
|
||||
|
||||
struct test
|
||||
{
|
||||
virtual test_function_pointer getFunction() = 0;
|
||||
};
|
||||
|
||||
class test_registry {
|
||||
private:
|
||||
std::vector<test *> m_tests;
|
||||
std::vector<test_definition> m_definitions;
|
||||
|
||||
public:
|
||||
static test_registry &getInstance();
|
||||
|
||||
test_definition *definitions();
|
||||
|
||||
size_t num_tests();
|
||||
|
||||
void add_test(test *t, const char *name, Version version);
|
||||
test_registry() {}
|
||||
};
|
||||
|
||||
template <typename T> T *register_test(const char *name, Version version)
|
||||
{
|
||||
T *t = new T();
|
||||
test_registry::getInstance().add_test((test *)t, name, version);
|
||||
return t;
|
||||
}
|
||||
|
||||
#define REGISTER_TEST_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 test { \
|
||||
private: \
|
||||
test_function_pointer fn; \
|
||||
\
|
||||
public: \
|
||||
test_##name##_class(): fn(test_##name) {} \
|
||||
test_function_pointer getFunction() { return fn; } \
|
||||
}; \
|
||||
test_##name##_class *var_##name = \
|
||||
register_test<test_##name##_class>(#name, version); \
|
||||
int test_##name(cl_device_id deviceID, cl_context context, \
|
||||
cl_command_queue queue, int num_elements)
|
||||
|
||||
#define REGISTER_TEST(name) REGISTER_TEST_VERSION(name, Version(1, 2))
|
||||
|
||||
extern int gFailCount;
|
||||
extern int gTestCount;
|
||||
extern cl_uint gReSeed;
|
||||
|
||||
Reference in New Issue
Block a user