Skip to content

Commit

Permalink
Added corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-goras-mobica committed Oct 19, 2023
1 parent bb0ff46 commit 8a21a07
Showing 1 changed file with 38 additions and 17 deletions.
55 changes: 38 additions & 17 deletions tests/test_openclhpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4516,46 +4516,67 @@ void testgetObjectInfo() {
TEST_ASSERT_EQUAL(buffer.getObjectInfo(&type, &bufobj), CL_SUCCESS);
TEST_ASSERT_EQUAL(type, CL_GL_OBJECT_BUFFER);
TEST_ASSERT_EQUAL(bufobj, 0);
}

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);
TEST_ASSERT_EQUAL(0, num_kernels);
if (num_kernels_ret != nullptr) {
*num_kernels_ret = 1;
*num_kernels_ret = 3;
}
return CL_SUCCESS;
case 2:
TEST_ASSERT_EQUAL(make_program(1), program);
if (num_kernels_ret != nullptr) {
*num_kernels_ret = 1;
case 1:
TEST_ASSERT_EQUAL(3, num_kernels);
TEST_ASSERT_EQUAL(nullptr, num_kernels_ret);
for (unsigned int i = 0; i < num_kernels; i++)
{
kernels[i] = make_kernel(i);
}

return CL_SUCCESS;
case 3:
case 2:
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;
TEST_ASSERT_EQUAL(0, num_kernels);
TEST_ASSERT_NOT_NULL(num_kernels_ret);

return CL_INVALID_PROGRAM_EXECUTABLE;
case 3:
TEST_ASSERT_EQUAL(nullptr, program);
TEST_ASSERT_EQUAL(0, num_kernels);
TEST_ASSERT_NOT_NULL(num_kernels_ret);

return CL_INVALID_PROGRAM;
default:
return CL_SUCCESS;
}
}

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

clCreateKernelsInProgram_StubWithCallback(
clCreateKernelsInProgram_testcreateKernels);
clCreateKernelsInProgram_StubWithCallback(clCreateKernelsInProgram_testcreateKernels);

ret = programPool[0].createKernels(&kernels);
TEST_ASSERT_EQUAL(CL_SUCCESS, ret);
TEST_ASSERT_EQUAL(3, kernels.size());
for (unsigned int i = 0; i < kernels.size(); i++)
{
kernels[i]() = nullptr;
}
kernels.clear();

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);
TEST_ASSERT_EQUAL(CL_INVALID_PROGRAM_EXECUTABLE, ret);
TEST_ASSERT_EQUAL(true, kernels.empty());

cl::Program invalidProgram;
ret = invalidProgram.createKernels(&kernels);
TEST_ASSERT_EQUAL(CL_INVALID_PROGRAM, ret);
TEST_ASSERT_EQUAL(true, kernels.empty());
}
} // extern "C"

0 comments on commit 8a21a07

Please sign in to comment.