diff --git a/test_conformance/api/test_api_consistency.cpp b/test_conformance/api/test_api_consistency.cpp index cb39b3a828..efbbdfdf0d 100644 --- a/test_conformance/api/test_api_consistency.cpp +++ b/test_conformance/api/test_api_consistency.cpp @@ -921,7 +921,6 @@ REGISTER_TEST_VERSION(consistency_il_programs, Version(3, 0)) "support cl_khr_il_program"); // Test setup: - error = create_single_kernel_helper(context, &program, &kernel, 1, &test_kernel, "test"); test_error(error, "Unable to create test kernel"); @@ -965,6 +964,97 @@ REGISTER_TEST_VERSION(consistency_il_programs, Version(3, 0)) return TEST_PASS; } +REGISTER_TEST(consistency_missing_compiler) +{ + cl_bool compilerAvail = CL_TRUE; + cl_int err = + clGetDeviceInfo(device, CL_DEVICE_COMPILER_AVAILABLE, + sizeof(compilerAvail), &compilerAvail, nullptr); + test_error_fail(err, "clGetDeviceInfo failed"); + + if (compilerAvail) + { + log_info("Can't perform compiler consistency check\n"); + return TEST_SKIPPED_ITSELF; + } + + const char* sample_kernel = R"( + __kernel void sample_test_C(__global float *src, __global int *dst) + { + size_t tid = get_global_id(0); + dst[tid] = (int)src[tid]; + } + )"; + + clProgramWrapper program = + clCreateProgramWithSource(context, 1, &sample_kernel, nullptr, &err); + test_error(err, "Unable to create reference program"); + + /* clCompileProgram consistency check */ + err = clCompileProgram(program, 1, &device, nullptr, 0, nullptr, nullptr, + nullptr, nullptr); + test_failure_error_ret(err, CL_COMPILER_NOT_AVAILABLE, + "clCompileProgram should return " + "CL_COMPILER_NOT_AVAILABLE", + TEST_FAIL); + + /* clBuildProgram consistency check */ + err = clBuildProgram(program, 1, &device, NULL, NULL, NULL); + test_failure_error_ret(err, CL_COMPILER_NOT_AVAILABLE, + "clBuildProgram should return " + "CL_COMPILER_NOT_AVAILABLE", + TEST_FAIL); + + return TEST_PASS; +} + +REGISTER_TEST(consistency_missing_linker) +{ + cl_bool linkerAvail = CL_TRUE; + cl_int err = clGetDeviceInfo(device, CL_DEVICE_LINKER_AVAILABLE, + sizeof(linkerAvail), &linkerAvail, nullptr); + test_error_fail(err, "clGetDeviceInfo failed"); + + if (linkerAvail) + { + log_info("Can't perform linker consistency check\n"); + return TEST_SKIPPED_ITSELF; + } + + const char* sample_kernel = R"( + __kernel void sample_test_C(__global float *src, __global int *dst) + { + size_t tid = get_global_id(0); + dst[tid] = (int)src[tid]; + } + )"; + + clProgramWrapper program = + clCreateProgramWithSource(context, 1, &sample_kernel, nullptr, &err); + test_error(err, "Unable to create reference program"); + + /* clCompileProgram consistency check */ + err = clCompileProgram(program, 1, &device, nullptr, 0, nullptr, nullptr, + nullptr, nullptr); + test_error(err, "clCompileProgram failed"); + + clProgramWrapper linked = + clLinkProgram(context, 1, &device, "", 1, &program, 0, 0, &err); + test_failure_error_ret(err, CL_LINKER_NOT_AVAILABLE, + "clLinkProgram should return " + "CL_LINKER_NOT_AVAILABLE", + TEST_FAIL); + + /* clBuildProgram consistency check */ + err = clBuildProgram(program, 1, &device, NULL, NULL, NULL); + test_failure_error_ret(err, CL_COMPILER_NOT_AVAILABLE, + "clBuildProgram should return " + "CL_COMPILER_NOT_AVAILABLE", + TEST_FAIL); + + return TEST_PASS; +} + REGISTER_TEST_VERSION(consistency_subgroups, Version(3, 0)) { // clGetDeviceInfo, passing CL_DEVICE_MAX_NUM_SUB_GROUPS