#ifndef _testHarness_h
#define _testHarness_h
#include "threadTesting.h"
#include "clImageHelper.h"
#include <string>
#include <sstream>
#include <string>
class Version {
public:
Version(): m_major(0), m_minor(0) {}
Version(int major, int minor): m_major(major), m_minor(minor) {}
bool operator>(const Version &rhs) const { return to_int() > rhs.to_int(); }
bool operator<(const Version &rhs) const { return to_int() < rhs.to_int(); }
bool operator<=(const Version &rhs) const
{
return to_int() <= rhs.to_int();
}
bool operator>=(const Version &rhs) const
{
return to_int() >= rhs.to_int();
}
bool operator==(const Version &rhs) const
{
return to_int() == rhs.to_int();
}
int to_int() const { return m_major * 10 + m_minor; }
std::string to_string() const
{
std::stringstream ss;
ss << m_major << "." << m_minor;
return ss.str();
}
private:
int m_major;
int m_minor;
};
Version get_device_cl_version(cl_device_id device);
#define ADD_TEST(fn) \
{ \
test_##fn, #fn, Version(1, 0) \
}
#define ADD_TEST_VERSION(fn, ver) \
{ \
test_##fn, #fn, ver \
}
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
typedef struct test_definition
{
basefn func;
const char *name;
Version min_version;
} test_definition;
typedef enum test_status
{
TEST_PASS = 0,
TEST_FAIL = 1,
TEST_SKIP = 2,
TEST_SKIPPED_ITSELF = -100,
} test_status;
extern int gFailCount;
extern int gTestCount;
extern cl_uint gReSeed;
extern cl_uint gRandomSeed;
extern int runTestHarness(int argc, const char *argv[], int testNum,
test_definition testList[],
int forceNoContextCreation,
cl_command_queue_properties queueProps);
typedef test_status (*DeviceCheckFn)(cl_device_id device);
extern int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
test_definition testList[],
int forceNoContextCreation,
cl_command_queue_properties queueProps,
DeviceCheckFn deviceCheckFn);
extern int parseAndCallCommandLineTests(int argc, const char *argv[],
cl_device_id device, int testNum,
test_definition testList[],
int forceNoContextCreation,
cl_command_queue_properties queueProps,
int num_elements);
extern void callTestFunctions(test_definition testList[],
unsigned char selectedTestList[],
test_status resultTestList[], int testNum,
cl_device_id deviceToUse,
int forceNoContextCreation, int numElementsToUse,
cl_command_queue_properties queueProps);
extern test_status
callSingleTestFunction(test_definition test, cl_device_id deviceToUse,
int forceNoContextCreation, int numElementsToUse,
cl_command_queue_properties queueProps);
extern void CL_CALLBACK notify_callback(const char *errinfo,
const void *private_info, size_t cb,
void *user_data);
extern cl_device_type GetDeviceType(cl_device_id);
extern cl_device_id GetOpposingDevice(cl_device_id device);
Version get_device_spirv_il_version(cl_device_id device);
bool check_device_spirv_il_support(cl_device_id device);
void version_expected_info(const char *test_name, const char *api_name,
const char *expected_version,
const char *device_version);
test_status check_spirv_compilation_readiness(cl_device_id device);
extern int gFlushDenormsToZero;
extern int gInfNanSupport;
extern int gIsEmbedded;
extern int gHasLong;
extern bool gCoreILProgram;
extern cl_platform_id getPlatformFromDevice(cl_device_id deviceID);
#if !defined(__APPLE__)
void memset_pattern4(void *, const void *, size_t);
#endif
extern void PrintArch(void);
#endif