From 1d8405b2ccc83014575ab6e70f37ac9c96d9a24a Mon Sep 17 00:00:00 2001 From: piotr-wozniak-mobica Date: Fri, 18 Aug 2023 13:26:26 +0200 Subject: [PATCH 1/2] UT for enqueueWriteImage --- tests/test_openclhpp.cpp | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index 7748e664..b8fbefaa 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -4517,4 +4517,63 @@ void testgetObjectInfo() { TEST_ASSERT_EQUAL(type, CL_GL_OBJECT_BUFFER); TEST_ASSERT_EQUAL(bufobj, 0); } +cl_int clEnqueueWriteImage_testenqueueWriteImage( + cl_command_queue command_queue, cl_mem image, cl_bool blocking_write, + const size_t *origin, const size_t *region, size_t input_row_pitch, + size_t input_slice_pitch, const void *ptr, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, cl_event *event, int num_calls) { + (void)command_queue; + (void)image; + TEST_ASSERT_EQUAL(region[0], 256); + TEST_ASSERT_EQUAL(origin[0], 8); + TEST_ASSERT_EQUAL(false, blocking_write); + TEST_ASSERT_EQUAL(256, input_row_pitch); + TEST_ASSERT_EQUAL(0, input_slice_pitch); + TEST_ASSERT_EQUAL_PTR(image2DPool, ptr); + TEST_ASSERT_EQUAL(0, num_events_in_wait_list); + TEST_ASSERT_EQUAL_PTR(nullptr, event_wait_list); + TEST_ASSERT_EQUAL_PTR(nullptr, event); + TEST_ASSERT_EQUAL(nullptr, num_calls); + return CL_SUCCESS; +} +cl_int clEnqueueReadImage_testenqueueWriteImage( + cl_command_queue command_queue, cl_mem image, cl_bool blocking_read, + const size_t *origin, const size_t *region, size_t row_pitch, + size_t slice_pitch, void *ptr, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, cl_event *event, int num_calls) { + (void)command_queue; + (void)image; + TEST_ASSERT_EQUAL(region[0], 256); + TEST_ASSERT_EQUAL(origin[0], 8); + TEST_ASSERT_EQUAL(false, blocking_read); + TEST_ASSERT_EQUAL(256, row_pitch); + TEST_ASSERT_EQUAL(0, slice_pitch); + TEST_ASSERT_EQUAL_PTR(image2DPool, ptr); + TEST_ASSERT_EQUAL(0, num_events_in_wait_list); + TEST_ASSERT_EQUAL_PTR(nullptr, event_wait_list); + TEST_ASSERT_EQUAL_PTR(nullptr, event); + TEST_ASSERT_EQUAL(nullptr, num_calls); + return CL_SUCCESS; +} +void testenqueueWriteImage() { + cl_int ret = 0; + cl_int ret_read = 0; + cl_bool blocking = false; + const std::array origin = {8, 16, 0}; + const std::array region = {256, 256, 0}; + size_t row_pitch = 256; + size_t slice_pitch = 0; + void *ptr = image2DPool; + + clEnqueueWriteImage_StubWithCallback( + clEnqueueWriteImage_testenqueueWriteImage); + clEnqueueReadImage_StubWithCallback( + clEnqueueReadImage_testenqueueWriteImage); + ret = commandQueuePool[0].enqueueWriteImage( + image2DPool[1], blocking, origin, region, row_pitch, slice_pitch, ptr); + TEST_ASSERT_EQUAL(CL_SUCCESS, ret); + ret_read = commandQueuePool[0].enqueueReadImage( + image2DPool[1], blocking, origin, region, row_pitch, slice_pitch, ptr); + TEST_ASSERT_EQUAL(CL_SUCCESS, ret_read); +} } // extern "C" From 8c79adcc2424d4b97fe47a1866699a2926f93d8e Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Thu, 19 Oct 2023 12:52:26 +0200 Subject: [PATCH 2/2] Made static mock methods --- tests/test_openclhpp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index b8fbefaa..5b797dee 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -4517,7 +4517,7 @@ void testgetObjectInfo() { TEST_ASSERT_EQUAL(type, CL_GL_OBJECT_BUFFER); TEST_ASSERT_EQUAL(bufobj, 0); } -cl_int clEnqueueWriteImage_testenqueueWriteImage( +static cl_int clEnqueueWriteImage_testenqueueWriteImage( cl_command_queue command_queue, cl_mem image, cl_bool blocking_write, const size_t *origin, const size_t *region, size_t input_row_pitch, size_t input_slice_pitch, const void *ptr, cl_uint num_events_in_wait_list, @@ -4536,7 +4536,7 @@ cl_int clEnqueueWriteImage_testenqueueWriteImage( TEST_ASSERT_EQUAL(nullptr, num_calls); return CL_SUCCESS; } -cl_int clEnqueueReadImage_testenqueueWriteImage( +static cl_int clEnqueueReadImage_testenqueueWriteImage( cl_command_queue command_queue, cl_mem image, cl_bool blocking_read, const size_t *origin, const size_t *region, size_t row_pitch, size_t slice_pitch, void *ptr, cl_uint num_events_in_wait_list,