-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UT for createKernels #5
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4571,6 +4571,78 @@ void testgetObjectInfo() { | |
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) { | ||
Comment on lines
+4575
to
+4577
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should test |
||
switch (num_calls) { | ||
case 0: | ||
TEST_ASSERT_EQUAL(make_program(0), program); | ||
TEST_ASSERT_EQUAL(0, num_kernels); | ||
if (num_kernels_ret != nullptr) | ||
{ | ||
*num_kernels_ret = 3; | ||
} | ||
return CL_SUCCESS; | ||
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 2: | ||
TEST_ASSERT_EQUAL(make_program(1), program); | ||
TEST_ASSERT_EQUAL(0, num_kernels); | ||
TEST_ASSERT_NOT_NULL(num_kernels_ret); | ||
if (num_kernels_ret != nullptr) | ||
{ | ||
*num_kernels_ret = 0; | ||
} | ||
|
||
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); | ||
if (num_kernels_ret != nullptr) | ||
{ | ||
*num_kernels_ret = 0; | ||
} | ||
|
||
return CL_INVALID_PROGRAM; | ||
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); | ||
Comment on lines
+4627
to
+4628
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also test size of the vector. |
||
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_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()); | ||
} | ||
|
||
#if CL_HPP_TARGET_OPENCL_VERSION >= 210 | ||
static cl_int clGetHostTimer_testgetHostTimer(cl_device_id device, | ||
cl_ulong *host_timestamp, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a compilation error. Missing
}
at the end of this procedure.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shajder Added some corrections to all comments. Please take a look and review.