From 76791d2db550dcf398d66d99a06d41cc864cb614 Mon Sep 17 00:00:00 2001 From: piotr-wozniak-mobica Date: Mon, 21 Aug 2023 14:34:48 +0200 Subject: [PATCH 1/2] UT for enqueueReleaseGLObjects --- tests/test_openclhpp.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index 7748e664..33440c95 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -4517,4 +4517,38 @@ void testgetObjectInfo() { TEST_ASSERT_EQUAL(type, CL_GL_OBJECT_BUFFER); TEST_ASSERT_EQUAL(bufobj, 0); } +static cl_int clEnqueueReleaseGLObjects_testenqueueReleaseGLObjects( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, cl_event *event, int num_calls) { + (void)command_queue; + TEST_ASSERT_EQUAL(1, num_objects); + TEST_ASSERT_NOT_NULL(mem_objects); + 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 testenqueueReleaseGLObjects() { + cl::Memory obj; + cl::vector mem_objects = {obj}; + cl::Event event; + cl::vector events = {event}; + cl_int ret = CL_INVALID_COMMAND_QUEUE; + + clEnqueueReleaseGLObjects_StubWithCallback( + clEnqueueReleaseGLObjects_testenqueueReleaseGLObjects); + ret = commandQueuePool[0].enqueueReleaseGLObjects(&mem_objects, &events, + &event); + TEST_ASSERT_EQUAL(CL_SUCCESS, ret); + TEST_ASSERT_EQUAL_PTR(make_event(1), event()); + + event() = nullptr; + events[0]() = nullptr; + mem_objects[0]() = nullptr; +} } // extern "C" From 33809b4d112b93580edc14dec8342be01ea2b736 Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Thu, 16 Nov 2023 13:15:01 +0100 Subject: [PATCH 2/2] Review corrections --- tests/test_openclhpp.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index 33440c95..103ee6f2 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -4524,8 +4524,10 @@ static cl_int clEnqueueReleaseGLObjects_testenqueueReleaseGLObjects( (void)command_queue; TEST_ASSERT_EQUAL(1, num_objects); TEST_ASSERT_NOT_NULL(mem_objects); + TEST_ASSERT_EQUAL(make_mem(0), *mem_objects); TEST_ASSERT_EQUAL(1, num_events_in_wait_list); TEST_ASSERT_NOT_NULL(event_wait_list); + TEST_ASSERT_EQUAL(make_event(0), event_wait_list[0]); TEST_ASSERT_EQUAL(0, num_calls); if (event != nullptr) { *event = make_event(1); @@ -4534,10 +4536,11 @@ static cl_int clEnqueueReleaseGLObjects_testenqueueReleaseGLObjects( } void testenqueueReleaseGLObjects() { - cl::Memory obj; - cl::vector mem_objects = {obj}; + cl::vector mem_objects; + mem_objects.emplace_back(make_mem(0), false); cl::Event event; - cl::vector events = {event}; + cl::vector events; + events.emplace_back(cl::Event(make_event(0))); cl_int ret = CL_INVALID_COMMAND_QUEUE; clEnqueueReleaseGLObjects_StubWithCallback(