mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Implement negative tests for cl_device_id API functions (#2495)
Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com> Co-authored-by: Chetankumar Mistry <chetan.mistry@arm.com>
This commit is contained in:
@@ -58,6 +58,13 @@ void helpInfo()
|
||||
with a very small subset of the tests. This option should not be used
|
||||
for conformance submission (default: disabled).
|
||||
|
||||
--invalid-object-scenarios=<option_1>,<option_2>....
|
||||
Specify different scenarios to use when
|
||||
testing for object validity. Options can be:
|
||||
nullptr To use a nullptr (default)
|
||||
valid_object_wrong_type To use a valid_object which is not the correct type
|
||||
NOTE: valid_object_wrong_type option is not required for OpenCL conformance.
|
||||
|
||||
For offline compilation (binary and spir-v modes) only:
|
||||
--compilation-cache-mode <cache-mode>
|
||||
Specify a compilation caching mode:
|
||||
@@ -104,6 +111,7 @@ int parseCustomParam(int argc, const char *argv[], const char *ignore)
|
||||
}
|
||||
|
||||
delArg = 0;
|
||||
size_t i_object_length = strlen("--invalid-object-scenarios=");
|
||||
|
||||
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
|
||||
{
|
||||
@@ -264,6 +272,32 @@ int parseCustomParam(int argc, const char *argv[], const char *ignore)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (!strncmp(argv[i],
|
||||
"--invalid-object-scenarios=", i_object_length))
|
||||
{
|
||||
if (strlen(argv[i]) > i_object_length)
|
||||
{
|
||||
delArg++;
|
||||
gInvalidObject = 0;
|
||||
std::string invalid_objects(argv[i]);
|
||||
|
||||
if (invalid_objects.find("nullptr") != std::string::npos)
|
||||
{
|
||||
gInvalidObject |= InvalidObject::Nullptr;
|
||||
}
|
||||
if (invalid_objects.find("valid_object_wrong_type")
|
||||
!= std::string::npos)
|
||||
{
|
||||
gInvalidObject |= InvalidObject::ValidObjectWrongType;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("Program argument for --invalid-object-scenarios was "
|
||||
"not specified.\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// cleaning parameters from argv tab
|
||||
for (int j = i; j < argc - delArg; j++) argv[j] = argv[j + delArg];
|
||||
|
||||
@@ -60,6 +60,7 @@ int gInfNanSupport = 1;
|
||||
int gIsEmbedded = 0;
|
||||
int gHasLong = 1;
|
||||
bool gCoreILProgram = true;
|
||||
int gInvalidObject = InvalidObject::Nullptr;
|
||||
|
||||
#define DEFAULT_NUM_ELEMENTS 0x4000
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
|
||||
class Version {
|
||||
public:
|
||||
@@ -257,6 +258,37 @@ extern std::string get_platform_info_string(cl_platform_id platform,
|
||||
cl_platform_info param_name);
|
||||
extern bool is_platform_extension_available(cl_platform_id platform,
|
||||
const char *extensionName);
|
||||
enum InvalidObject
|
||||
{
|
||||
Nullptr = 1 << 0,
|
||||
ValidObjectWrongType = 1 << 1,
|
||||
};
|
||||
|
||||
extern int gInvalidObject;
|
||||
|
||||
|
||||
template <typename T> std::vector<T> get_invalid_objects(cl_device_id device)
|
||||
{
|
||||
std::vector<T> ret;
|
||||
if ((gInvalidObject & InvalidObject::Nullptr)
|
||||
&& !(std::is_same<T, cl_platform_id>::value))
|
||||
{
|
||||
ret.push_back(nullptr);
|
||||
}
|
||||
if (gInvalidObject & InvalidObject::ValidObjectWrongType)
|
||||
{
|
||||
if (std::is_same<T, cl_device_id>::value)
|
||||
{
|
||||
cl_platform_id platform = getPlatformFromDevice(device);
|
||||
ret.push_back(reinterpret_cast<T>(platform));
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.push_back(reinterpret_cast<T>(device));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if !defined(__APPLE__)
|
||||
void memset_pattern4(void *, const void *, size_t);
|
||||
|
||||
Reference in New Issue
Block a user