From 3461e8d589f19e6f5125badf1c25bf6ec22884a5 Mon Sep 17 00:00:00 2001 From: piotr-wozniak-mobica Date: Mon, 7 Aug 2023 14:43:18 +0200 Subject: [PATCH 1/2] UT for compile --- tests/test_openclhpp.cpp | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index 7748e664..f1a2d080 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -4517,4 +4517,61 @@ void testgetObjectInfo() { TEST_ASSERT_EQUAL(type, CL_GL_OBJECT_BUFFER); TEST_ASSERT_EQUAL(bufobj, 0); } + +#if CL_HPP_TARGET_OPENCL_VERSION >= 120 +static cl_int clGetProgramInfo_testcompile(cl_program program, + cl_program_build_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret, + int /*num_calls*/) { + TEST_ASSERT_EQUAL_PTR(make_program(0), program); + TEST_ASSERT_EQUAL_HEX(CL_PROGRAM_DEVICES, param_name); + TEST_ASSERT(param_value == nullptr || + param_value_size >= sizeof(cl_context)); + if (param_value_size_ret != nullptr) + *param_value_size_ret = sizeof(cl_context); + if (param_value != nullptr) + *static_cast(param_value) = make_context(0); + return CL_SUCCESS; +} + +static cl_int clCompileProgram_testcompile( + cl_program program, cl_uint num_devices, const cl_device_id *device_list, + const char *options, cl_uint num_input_headers, + const cl_program *input_headers, const char **header_include_names, + cmock_cl_func_ptr6 pfn_notify, void *user_data, int num_calls) { + TEST_ASSERT_EQUAL_PTR(program, make_program(0)); + TEST_ASSERT_EQUAL(num_devices, 0); + TEST_ASSERT_EQUAL_PTR(device_list, nullptr); + TEST_ASSERT_EQUAL_PTR(options, nullptr); + TEST_ASSERT_EQUAL(num_input_headers, 0); + TEST_ASSERT_EQUAL_PTR(input_headers, nullptr); + TEST_ASSERT_EQUAL_PTR(header_include_names, nullptr); + TEST_ASSERT_EQUAL(pfn_notify, 0); + TEST_ASSERT_EQUAL_PTR(user_data, nullptr); + TEST_ASSERT_EQUAL(num_calls, 0); + return CL_COMPILE_PROGRAM_FAILURE; +} + +void testcompile() { + const char *options = nullptr; + void(CL_CALLBACK * notifyFptr)(cl_program, void *) = nullptr; + void *data = (void *)nullptr; + cl_int ret = 0; + + clGetProgramInfo_StubWithCallback(clGetProgramInfo_testcompile); + clGetDeviceInfo_StubWithCallback(clGetDeviceInfo_platform); + clGetDeviceInfo_StubWithCallback(clGetDeviceInfo_platform); + clCompileProgram_StubWithCallback(clCompileProgram_testcompile); + clGetPlatformInfo_StubWithCallback(clGetPlatformInfo_version_1_1); + clGetProgramBuildInfo_StubWithCallback( + clGetProgramBuildInfo_testGetBuildInfo); + ret = programPool[0].compile(options, notifyFptr, data); + TEST_ASSERT_EQUAL(ret, CL_COMPILE_PROGRAM_FAILURE); +} +#else +void testcompile() {} +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 + } // extern "C" From 125e52be84ef3b0cd0559e8d0f443a7e62a9843e Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Thu, 19 Oct 2023 12:48:13 +0200 Subject: [PATCH 2/2] Added some corrections --- tests/test_openclhpp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index f1a2d080..c8b9153c 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -4562,11 +4562,11 @@ void testcompile() { clGetProgramInfo_StubWithCallback(clGetProgramInfo_testcompile); clGetDeviceInfo_StubWithCallback(clGetDeviceInfo_platform); - clGetDeviceInfo_StubWithCallback(clGetDeviceInfo_platform); - clCompileProgram_StubWithCallback(clCompileProgram_testcompile); clGetPlatformInfo_StubWithCallback(clGetPlatformInfo_version_1_1); - clGetProgramBuildInfo_StubWithCallback( - clGetProgramBuildInfo_testGetBuildInfo); + clGetProgramBuildInfo_StubWithCallback(clGetProgramBuildInfo_testGetBuildInfo); + + clCompileProgram_StubWithCallback(clCompileProgram_testcompile); + ret = programPool[0].compile(options, notifyFptr, data); TEST_ASSERT_EQUAL(ret, CL_COMPILE_PROGRAM_FAILURE); }