Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UT for updateMutableCommands #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions tests/test_openclhpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ void setUp(void)
cl::pfn_clReleaseCommandBufferKHR = ::clReleaseCommandBufferKHR;
cl::pfn_clGetCommandBufferInfoKHR = ::clGetCommandBufferInfoKHR;
#endif
#if defined(cl_khr_command_buffer_mutable_dispatch)
cl::pfn_clUpdateMutableCommandsKHR = ::clUpdateMutableCommandsKHR;
#endif
#if defined(cl_khr_semaphore)
cl::pfn_clCreateSemaphoreWithPropertiesKHR = ::clCreateSemaphoreWithPropertiesKHR;
cl::pfn_clReleaseSemaphoreKHR = ::clReleaseSemaphoreKHR;
Expand Down Expand Up @@ -486,6 +489,9 @@ void tearDown(void)
cl::pfn_clReleaseCommandBufferKHR = nullptr;
cl::pfn_clGetCommandBufferInfoKHR = nullptr;
#endif
#if defined(cl_khr_command_buffer_mutable_dispatch)
cl::pfn_clUpdateMutableCommandsKHR = nullptr;
#endif
#if defined(cl_khr_semaphore)
cl::pfn_clCreateSemaphoreWithPropertiesKHR = nullptr;
cl::pfn_clReleaseSemaphoreKHR = nullptr;
Expand Down Expand Up @@ -3604,6 +3610,44 @@ void testCommandBufferInfoKHRCommandQueues(void)
TEST_ASSERT_EQUAL_PTR(make_command_queue(2), command_queues[2]());
#endif
}

static cl_int clUpdateMutableCommandsKHR_testUpdateMutableCommands(cl_command_buffer_khr command_buffer,
const cl_mutable_base_config_khr* mutable_config,
cl_int cmock_to_return)
{
switch (cmock_to_return)
{
case 0:
{
TEST_ASSERT_EQUAL_PTR(nullptr, mutable_config);
return CL_INVALID_VALUE;
}
case 1:
{
TEST_ASSERT_EQUAL(CL_STRUCTURE_TYPE_MUTABLE_BASE_CONFIG_KHR, mutable_config->type);
TEST_ASSERT_EQUAL_PTR(nullptr, mutable_config->next);
TEST_ASSERT_EQUAL(1, mutable_config->num_mutable_dispatch);
return CL_SUCCESS;
}
}
return CL_SUCCESS;
}

void testUpdateMutableCommands(void)
{
#if defined(cl_khr_command_buffer_mutable_dispatch)
cl_mutable_dispatch_config_khr mutable_dispatch_list;
cl_mutable_base_config_khr mutable_config{ CL_STRUCTURE_TYPE_MUTABLE_BASE_CONFIG_KHR, nullptr, 1, &mutable_dispatch_list };

clUpdateMutableCommandsKHR_StubWithCallback(clUpdateMutableCommandsKHR_testUpdateMutableCommands);
cl_int ret = commandBufferKhrPool[0].updateMutableCommands(nullptr);
TEST_ASSERT_EQUAL(ret, CL_INVALID_VALUE);

ret = commandBufferKhrPool[0].updateMutableCommands(&mutable_config);
TEST_ASSERT_EQUAL(ret, CL_SUCCESS);
#endif
}

// Tests for Device::GetInfo
static cl_int clGetInfo_testDeviceGetInfoCLDeviceVendorId(
cl_device_id device, cl_device_info param_name, size_t param_value_size,
Expand Down