Skip to content

Commit

Permalink
UT for createKernels
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-wozniak-mobica committed Aug 8, 2023
1 parent b8b3056 commit a42cce8
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test_openclhpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4472,4 +4472,45 @@ void testTemplateGetImageRequirementsInfo()
void testTemplateGetImageRequirementsInfo() {}
#endif // cl_ext_image_requirements_info

static cl_int clCreateKernelsInProgram_testcreateKernels(
cl_program program, cl_uint num_kernels, cl_kernel *kernels,
cl_uint *num_kernels_ret, int num_calls) {
switch (num_calls) {
case 0:
case 1:
TEST_ASSERT_EQUAL(make_program(0), program);
if (num_kernels_ret != nullptr) {
*num_kernels_ret = 1;
}
return CL_SUCCESS;
case 2:
TEST_ASSERT_EQUAL(make_program(1), program);
if (num_kernels_ret != nullptr) {
*num_kernels_ret = 1;
}
return CL_SUCCESS;
case 3:
TEST_ASSERT_EQUAL(make_program(1), program);
return CL_DEVICE_NOT_FOUND;
case 4:
TEST_ASSERT_EQUAL(make_program(2), program);
return CL_DEVICE_NOT_AVAILABLE;
default:
return CL_SUCCESS;
}
}

void testcreateKernels() {
cl_int ret = 0;
cl::vector<cl::Kernel> kernels;

clCreateKernelsInProgram_StubWithCallback(
clCreateKernelsInProgram_testcreateKernels);
ret = programPool[0].createKernels(&kernels);
TEST_ASSERT_EQUAL(CL_SUCCESS, ret);
ret = programPool[1].createKernels(&kernels);
TEST_ASSERT_EQUAL(CL_DEVICE_NOT_FOUND, ret);
ret = programPool[2].createKernels(&kernels);
TEST_ASSERT_EQUAL(CL_DEVICE_NOT_AVAILABLE, ret);
}
} // extern "C"

0 comments on commit a42cce8

Please sign in to comment.