From d6dd6d3d14191d430de16ed5e918ac9dd229347a Mon Sep 17 00:00:00 2001 From: piotr-wozniak-mobica Date: Wed, 16 Aug 2023 13:12:58 +0200 Subject: [PATCH] UT for EnqueueMapBuffer --- tests/test_openclhpp.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index 7748e664..3d819ce1 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -4516,5 +4516,41 @@ void testgetObjectInfo() { TEST_ASSERT_EQUAL(buffer.getObjectInfo(&type, &bufobj), CL_SUCCESS); TEST_ASSERT_EQUAL(type, CL_GL_OBJECT_BUFFER); TEST_ASSERT_EQUAL(bufobj, 0); +static void *clEnqueueMapBuffer_testenqueueMapBuffer( + cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, + cl_map_flags map_flags, size_t offset, size_t size, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event, cl_int *errcode_ret, int num_calls) { + (void)command_queue; + TEST_ASSERT_EQUAL_PTR(make_mem(0), buffer); + TEST_ASSERT_EQUAL(CL_TRUE, blocking_map); + TEST_ASSERT_EQUAL(CL_MAP_WRITE, map_flags); + TEST_ASSERT_EQUAL(0, offset); + TEST_ASSERT_EQUAL(sizeof(int) * 1024, size); + TEST_ASSERT_EQUAL(0, num_events_in_wait_list); + TEST_ASSERT_EQUAL_PTR(nullptr, event_wait_list); + TEST_ASSERT_NOT_NULL(event); + TEST_ASSERT_NOT_EQUAL(nullptr, errcode_ret); + TEST_ASSERT_EQUAL(0, num_calls); + return make_mem(0); +} +void testenqueueMapBuffer() { + cl_bool blocking = CL_TRUE; + cl_map_flags flags = CL_MAP_WRITE; + cl::size_type offset = 0; + cl::size_type size = sizeof(int) * 1024; + cl::Event event_data(make_event(0), false); + cl::Event *event = &event_data; + const cl::vector *events = nullptr; + cl_int *err = nullptr; + void *ret = nullptr; + + clEnqueueMapBuffer_StubWithCallback( + clEnqueueMapBuffer_testenqueueMapBuffer); + ret = enqueueMapBuffer(bufferPool[0], blocking, flags, offset, size, events, + event, err); + + TEST_ASSERT_EQUAL_PTR(make_mem(0), ret); + event_data() = nullptr; } } // extern "C"