From 9e0deab9e58f54c73d42afae301afa50a1a877ff Mon Sep 17 00:00:00 2001 From: piotr-wozniak-mobica Date: Thu, 10 Aug 2023 09:13:35 +0200 Subject: [PATCH 1/2] UT for enqueueUnmapSVM --- tests/test_openclhpp.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index 7748e664..216ce33c 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -4517,4 +4517,35 @@ void testgetObjectInfo() { TEST_ASSERT_EQUAL(type, CL_GL_OBJECT_BUFFER); TEST_ASSERT_EQUAL(bufobj, 0); } +#if CL_HPP_TARGET_OPENCL_VERSION >= 200 +static cl_int clenqueueUnmapSVM_testenqueueUnmapSVM( + cl_command_queue command_queue, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, cl_event *event, int num_calls) { + TEST_ASSERT_EQUAL_PTR(make_command_queue(0), command_queue); + TEST_ASSERT_EQUAL(1, num_events_in_wait_list); + TEST_ASSERT_NOT_NULL(event_wait_list); + TEST_ASSERT_EQUAL(0, num_calls); + if (event != nullptr) { + *event = make_event(1); + } + return CL_SUCCESS; +} + +void testenqueueUnmapSVM() { + cl_int ret = CL_DEVICE_NOT_FOUND; + cl::Event event; + cl::vector events = {event}; + + clenqueueUnmapSVM_StubWithCallback( + clenqueueUnmapSVM_testenqueueUnmapSVM); + ret = commandQueuePool[0].enqueueUnmapSVM(&events, &event); + TEST_ASSERT_EQUAL(CL_SUCCESS, ret); + TEST_ASSERT_EQUAL_PTR(make_event(1), event()); + + event() = nullptr; + events[0]() = nullptr; +} +#else +void testenqueueUnmapSVM() {} +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 } // extern "C" From 647286adc501019f8e3ee6425b83d4f56b43235a Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Fri, 17 Nov 2023 14:34:14 +0100 Subject: [PATCH 2/2] Corrected test for enqueueUnmapSVM --- tests/test_openclhpp.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index e044a587..77cd7f5d 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -4573,13 +4573,16 @@ void testgetObjectInfo() { } #if CL_HPP_TARGET_OPENCL_VERSION >= 200 -static cl_int clenqueueUnmapSVM_testenqueueUnmapSVM( - cl_command_queue command_queue, cl_uint num_events_in_wait_list, - const cl_event *event_wait_list, cl_event *event, int num_calls) { +static cl_int clEnqueueSVMUnmap_testenqueueUnmapSVM( + cl_command_queue command_queue, void* svm_ptr, cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, cl_event* event, cl_int cmock_to_return +){ + (void*)cmock_to_return; + TEST_ASSERT_EQUAL(*(cl_mem*)svm_ptr, make_mem(0)); TEST_ASSERT_EQUAL_PTR(make_command_queue(0), command_queue); TEST_ASSERT_EQUAL(1, num_events_in_wait_list); TEST_ASSERT_NOT_NULL(event_wait_list); - TEST_ASSERT_EQUAL(0, num_calls); + TEST_ASSERT_EQUAL(event_wait_list[0], make_event(0)); if (event != nullptr) { *event = make_event(1); } @@ -4589,16 +4592,19 @@ static cl_int clenqueueUnmapSVM_testenqueueUnmapSVM( void testenqueueUnmapSVM() { cl_int ret = CL_DEVICE_NOT_FOUND; cl::Event event; - cl::vector events = {event}; + cl::vector events; + events.emplace_back(cl::Event(make_event(0))); + cl::Memory mem(make_mem(0), false); - clenqueueUnmapSVM_StubWithCallback( - clenqueueUnmapSVM_testenqueueUnmapSVM); - ret = commandQueuePool[0].enqueueUnmapSVM(&events, &event); + clEnqueueSVMUnmap_StubWithCallback( + clEnqueueSVMUnmap_testenqueueUnmapSVM); + ret = commandQueuePool[0].enqueueUnmapSVM(&mem, &events, &event); TEST_ASSERT_EQUAL(CL_SUCCESS, ret); TEST_ASSERT_EQUAL_PTR(make_event(1), event()); event() = nullptr; events[0]() = nullptr; + mem() = nullptr; } #else void testenqueueUnmapSVM() {}