Skip to content

Commit

Permalink
fix after review
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-wozniak-mobica committed Sep 21, 2023
1 parent 2986780 commit f92e9e3
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions tests/test_openclhpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4473,26 +4473,48 @@ void testTemplateGetImageRequirementsInfo() {}
#endif // cl_ext_image_requirements_info

#if CL_HPP_TARGET_OPENCL_VERSION >= 300
static cl_int clSetContextDestructor_testsetDestructorCallback(
static void CL_CALLBACK test_context_destructor_callback(
cl_context,
void*)
{
}

static cl_int clSetContextDestructorCallback_testsetDestructorCallback(
cl_context context, cmock_cl_func_ptr3 pfn_notify, void *user_data,
int num_calls) {
TEST_ASSERT_EQUAL_PTR(context, make_context(0));
TEST_ASSERT_EQUAL_PTR(pfn_notify, nullptr);
TEST_ASSERT_EQUAL_PTR(user_data, nullptr);
TEST_ASSERT_EQUAL(0, num_calls);
return CL_INVALID_CONTEXT;
if(test_context_destructor_callback == pfn_notify)
{
return CL_SUCCESS;
}
else
{
return CL_INVALID_VALUE;
}
}

void testsetDestructorCallback() {
void testsetDestructorCallbackNull() {
cl_int ret = 0;
void(CL_CALLBACK * pfn_notify)(cl_context, void *) = nullptr;

clSetContextDestructorCallback_StubWithCallback(
clSetContextDestructor_testsetDestructorCallback);
clSetContextDestructorCallback_testsetDestructorCallback);
ret = contextPool[0].setDestructorCallback(pfn_notify);
TEST_ASSERT_EQUAL(CL_INVALID_CONTEXT, ret);
TEST_ASSERT_EQUAL(CL_INVALID_VALUE, ret);
}

void testsetDestructorCallbackNotNull() {
cl_int ret = 0;

clSetContextDestructorCallback_StubWithCallback(
clSetContextDestructorCallback_testsetDestructorCallback);
ret = contextPool[0].setDestructorCallback(test_context_destructor_callback);
TEST_ASSERT_EQUAL(CL_SUCCESS, ret);
}
#else
void testsetDestructorCallback() {}
void testsetDestructorCallbackNull() {}
void testsetDestructorCallbackNotNull() {}
#endif // CL_HPP_TARGET_OPENCL_VERSION >= 300
} // extern "C"

0 comments on commit f92e9e3

Please sign in to comment.