Reformat test harness code (#940)

* Reformat common help text

Signed-off-by: Stuart Brady <stuart.brady@arm.com>

* Reformat test harness code

This goes part of the way to fixing issue #625.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
This commit is contained in:
Stuart Brady
2020-10-30 14:13:52 +00:00
committed by GitHub
parent 55976fad35
commit af7d914514
38 changed files with 7676 additions and 6692 deletions

View File

@@ -1,6 +1,6 @@
//
// Copyright (c) 2017-2019 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -23,16 +23,24 @@
#include <string>
class Version
{
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(); }
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
{
@@ -66,7 +74,7 @@ Version get_device_cl_version(cl_device_id device);
typedef struct test_definition
{
basefn func;
const char* name;
const char *name;
Version min_version;
} test_definition;
@@ -83,57 +91,78 @@ extern int gTestCount;
extern cl_uint gReSeed;
extern cl_uint gRandomSeed;
// Supply a list of functions to test here. This will allocate a CL device, create a context, all that
// setup work, and then call each function in turn as dictatated by the passed arguments.
// Returns EXIT_SUCCESS iff all tests succeeded or the tests were listed,
// otherwise return EXIT_FAILURE.
extern int runTestHarness( int argc, const char *argv[], int testNum, test_definition testList[],
int imageSupportRequired, int forceNoContextCreation, cl_command_queue_properties queueProps );
// Supply a list of functions to test here. This will allocate a CL device,
// create a context, all that setup work, and then call each function in turn as
// dictatated by the passed arguments. Returns EXIT_SUCCESS iff all tests
// succeeded or the tests were listed, otherwise return EXIT_FAILURE.
extern int runTestHarness(int argc, const char *argv[], int testNum,
test_definition testList[], int imageSupportRequired,
int forceNoContextCreation,
cl_command_queue_properties queueProps);
// Device checking function. See runTestHarnessWithCheck. If this function returns anything other than TEST_PASS, the harness exits.
typedef test_status (*DeviceCheckFn)( cl_device_id device );
// Device checking function. See runTestHarnessWithCheck. If this function
// returns anything other than TEST_PASS, the harness exits.
typedef test_status (*DeviceCheckFn)(cl_device_id device);
// Same as runTestHarness, but also supplies a function that checks the created device for required functionality.
// Returns EXIT_SUCCESS iff all tests succeeded or the tests were listed,
// otherwise return EXIT_FAILURE.
extern int runTestHarnessWithCheck( int argc, const char *argv[], int testNum, test_definition testList[],
int forceNoContextCreation, cl_command_queue_properties queueProps,
DeviceCheckFn deviceCheckFn );
// Same as runTestHarness, but also supplies a function that checks the created
// device for required functionality. Returns EXIT_SUCCESS iff all tests
// succeeded or the tests were listed, otherwise return EXIT_FAILURE.
extern int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
test_definition testList[],
int forceNoContextCreation,
cl_command_queue_properties queueProps,
DeviceCheckFn deviceCheckFn);
// The command line parser used by runTestHarness to break up parameters into calls to callTestFunctions
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 );
// The command line parser used by runTestHarness to break up parameters into
// calls to callTestFunctions
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);
// Call this function if you need to do all the setup work yourself, and just need the function list called/
// managed.
// Call this function if you need to do all the setup work yourself, and just
// need the function list called/ managed.
// testList is the data structure that contains test functions and its names
// selectedTestList is an array of integers (treated as bools) which tell which function is to be called,
// each element at index i, corresponds to the element in testList at index i
// resultTestList is an array of statuses which contain the result of each selected test
// testNum is the number of tests in testList, selectedTestList and resultTestList
// contextProps are used to create a testing context for each test
// deviceToUse and numElementsToUse are all just passed to each test function
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 );
// selectedTestList is an array of integers (treated as bools) which tell
// which function is to be called,
// each element at index i, corresponds to the element in testList at
// index i
// resultTestList is an array of statuses which contain the result of each
// selected test testNum is the number of tests in testList, selectedTestList
// and resultTestList contextProps are used to create a testing context for
// each test deviceToUse and numElementsToUse are all just passed to each
// test function
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);
// This function is called by callTestFunctions, once per function, to do setup, call, logging and cleanup
extern test_status callSingleTestFunction( test_definition test, cl_device_id deviceToUse, int forceNoContextCreation,
int numElementsToUse, cl_command_queue_properties queueProps );
// This function is called by callTestFunctions, once per function, to do setup,
// call, logging and cleanup
extern test_status
callSingleTestFunction(test_definition test, cl_device_id deviceToUse,
int forceNoContextCreation, int numElementsToUse,
cl_command_queue_properties queueProps);
///// Miscellaneous steps
// standard callback function for context pfn_notify
extern void CL_CALLBACK notify_callback(const char *errinfo, const void *private_info, size_t cb, void *user_data);
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_type GetDeviceType(cl_device_id);
// Given a device (most likely passed in by the harness, but not required), will attempt to find
// a DIFFERENT device and return it. Useful for finding another device to run multi-device tests against.
// Note that returning NULL means an error was hit, but if no error was hit and the device passed in
// is the only device available, the SAME device is returned, so check!
extern cl_device_id GetOpposingDevice( cl_device_id device );
// Given a device (most likely passed in by the harness, but not required), will
// attempt to find a DIFFERENT device and return it. Useful for finding another
// device to run multi-device tests against. Note that returning NULL means an
// error was hit, but if no error was hit and the device passed in is the only
// device available, the SAME device is returned, so check!
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);
@@ -143,19 +172,20 @@ void version_expected_info(const char *test_name, const char *api_name,
test_status check_spirv_compilation_readiness(cl_device_id device);
extern int gFlushDenormsToZero; // This is set to 1 if the device does not support denorms (CL_FP_DENORM)
extern int gInfNanSupport; // This is set to 1 if the device supports infinities and NaNs
extern int gIsEmbedded; // This is set to 1 if the device is an embedded device
extern int gHasLong; // This is set to 1 if the device suppots long and ulong types in OpenCL C.
extern int gFlushDenormsToZero; // This is set to 1 if the device does not
// support denorms (CL_FP_DENORM)
extern int gInfNanSupport; // This is set to 1 if the device supports infinities
// and NaNs
extern int gIsEmbedded; // This is set to 1 if the device is an embedded device
extern int gHasLong; // This is set to 1 if the device suppots long and ulong
// types in OpenCL C.
extern bool gCoreILProgram;
#if ! defined( __APPLE__ )
void memset_pattern4(void *, const void *, size_t);
#if !defined(__APPLE__)
void memset_pattern4(void *, const void *, size_t);
#endif
extern void PrintArch(void);
#endif // _testHarness_h