From 8a2b91c715bd8631ce8577c3fd80823927278dee Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 2 Sep 2025 17:40:11 +0200 Subject: [PATCH] Added test to verify negative result of clSetKernelArg with CL_INVALID_KERNEL (#2460) Related to #2282, according to work plan from [here](https://github.com/KhronosGroup/OpenCL-CTS/issues/2282#issuecomment-3069182773) --- test_conformance/api/test_kernels.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test_conformance/api/test_kernels.cpp b/test_conformance/api/test_kernels.cpp index 1446ade8..c5b46d94 100644 --- a/test_conformance/api/test_kernels.cpp +++ b/test_conformance/api/test_kernels.cpp @@ -726,6 +726,26 @@ REGISTER_TEST(negative_set_immutable_memory_to_writeable_kernel_arg) return TEST_PASS; } +REGISTER_TEST(negative_invalid_kernel) +{ + cl_int error = CL_SUCCESS; + clKernelWrapper kernel; + + clMemWrapper mem = clCreateBuffer(context, CL_MEM_READ_ONLY, + sizeof(cl_float), NULL, &error); + test_error(error, "clCreateBuffer failed"); + + // Run the test - CL_INVALID_KERNEL + error = clSetKernelArg(kernel, 0, sizeof(cl_mem), &mem); + test_failure_error_ret( + error, CL_INVALID_KERNEL, + "clSetKernelArg is supposed to fail with CL_INVALID_KERNEL when kernel " + "is not a valid kernel object", + TEST_FAIL); + + return TEST_PASS; +} + REGISTER_TEST(negative_invalid_arg_index) { cl_int error = CL_SUCCESS; @@ -772,6 +792,7 @@ REGISTER_TEST(negative_invalid_arg_size_local) "clSetKernelArg is supposed to fail with CL_INVALID_ARG_SIZE when 0 is " "passed to a local qualifier kernel argument", TEST_FAIL); + return TEST_PASS; }