diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index c564a469..36f69d75 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -4571,6 +4571,52 @@ void testgetObjectInfo() { TEST_ASSERT_EQUAL(type, CL_GL_OBJECT_BUFFER); TEST_ASSERT_EQUAL(bufobj, 0); } + +#if CL_HPP_TARGET_OPENCL_VERSION >= 300 +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(user_data, nullptr); + TEST_ASSERT_EQUAL(0, num_calls); + if(test_context_destructor_callback == pfn_notify) + { + return CL_SUCCESS; + } + else + { + return CL_INVALID_VALUE; + } +} + +void testsetDestructorCallbackNull() { + cl_int ret = 0; + void(CL_CALLBACK * pfn_notify)(cl_context, void *) = nullptr; + + clSetContextDestructorCallback_StubWithCallback( + clSetContextDestructorCallback_testsetDestructorCallback); + ret = contextPool[0].setDestructorCallback(pfn_notify); + 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 testsetDestructorCallbackNull() {} +void testsetDestructorCallbackNotNull() {} +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 300 #if CL_HPP_TARGET_OPENCL_VERSION >= 210 static cl_int clGetHostTimer_testgetHostTimer(cl_device_id device, cl_ulong *host_timestamp,