@@ -372,15 +372,15 @@ MAKE_REFCOUNT_STUBS(cl_command_buffer_khr, clRetainCommandBufferKHR, clReleaseCo
372372 } \
373373 \
374374 void prefix##MoveConstruct##type##NonNull(void ) { \
375- cl:: type tmp (std::move (pool[0 ])); \
375+ type tmp (std::move (pool[0 ])); \
376376 TEST_ASSERT_EQUAL_PTR (makeFunc (0 ), tmp ()); \
377377 TEST_ASSERT_NULL (pool[0 ]()); \
378378 tmp () = nullptr ; \
379379 } \
380380 \
381381 void prefix##MoveConstruct##type##Null(void ) { \
382- cl:: type empty; \
383- cl:: type tmp (std::move (empty)); \
382+ type empty; \
383+ type tmp (std::move (empty)); \
384384 TEST_ASSERT_NULL (tmp ()); \
385385 TEST_ASSERT_NULL (empty ()); \
386386 }
@@ -512,8 +512,9 @@ void testMoveAssignContextNonNull(void);
512512void testMoveAssignContextNull (void );
513513void testMoveConstructContextNonNull (void );
514514void testMoveConstructContextNull (void );
515+ namespace cl {
515516MAKE_MOVE_TESTS (Context, make_context, clReleaseContext, contextPool)
516-
517+ }
517518// / Stub for querying CL_CONTEXT_DEVICES that returns two devices
518519static cl_int clGetContextInfo_testContextGetDevices (
519520 cl_context context,
@@ -781,8 +782,9 @@ void testMoveAssignCommandQueueNonNull(void);
781782void testMoveAssignCommandQueueNull (void );
782783void testMoveConstructCommandQueueNonNull (void );
783784void testMoveConstructCommandQueueNull (void );
785+ namespace cl {
784786MAKE_MOVE_TESTS (CommandQueue, make_command_queue, clReleaseCommandQueue, commandQueuePool)
785-
787+ }
786788// Stub for clGetCommandQueueInfo that returns context 0
787789static cl_int clGetCommandQueueInfo_testCommandQueueGetContext (
788790 cl_command_queue command_queue,
@@ -1180,8 +1182,9 @@ void testMoveAssignBufferNonNull(void);
11801182void testMoveAssignBufferNull (void );
11811183void testMoveConstructBufferNonNull (void );
11821184void testMoveConstructBufferNull (void );
1185+ namespace cl {
11831186MAKE_MOVE_TESTS (Buffer, make_mem, clReleaseMemObject, bufferPool)
1184-
1187+ }
11851188// Stub of clCreateBuffer for testBufferConstructorContextInterator
11861189// - return the first memory location
11871190
@@ -1509,8 +1512,9 @@ void testMoveAssignImage2DNonNull(void);
15091512void testMoveAssignImage2DNull (void );
15101513void testMoveConstructImage2DNonNull (void );
15111514void testMoveConstructImage2DNull (void );
1515+ namespace cl {
15121516MAKE_MOVE_TESTS (Image2D, make_mem, clReleaseMemObject, image2DPool)
1513-
1517+ }
15141518#ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
15151519static cl_mem clCreateImage2D_testCreateImage2D_1_1 (
15161520 cl_context context,
@@ -1627,8 +1631,9 @@ void testMoveAssignImage3DNonNull(void);
16271631void testMoveAssignImage3DNull (void );
16281632void testMoveConstructImage3DNonNull (void );
16291633void testMoveConstructImage3DNull (void );
1634+ namespace cl {
16301635MAKE_MOVE_TESTS (Image3D, make_mem, clReleaseMemObject, image3DPool)
1631-
1636+ }
16321637#ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
16331638static cl_mem clCreateImage3D_testCreateImage3D_1_1 (
16341639 cl_context context,
@@ -1750,8 +1755,9 @@ void testMoveAssignKernelNonNull(void);
17501755void testMoveAssignKernelNull (void );
17511756void testMoveConstructKernelNonNull (void );
17521757void testMoveConstructKernelNull (void );
1758+ namespace cl {
17531759MAKE_MOVE_TESTS (Kernel, make_kernel, clReleaseKernel, kernelPool)
1754-
1760+ }
17551761static cl_int scalarArg;
17561762static cl_int3 vectorArg;
17571763
@@ -3459,6 +3465,100 @@ void testLinkProgramWithVectorProgramInput(void)
34593465#endif
34603466}
34613467
3468+ /* ***************************************************************************
3469+ * Tests for cl::khr::CommandBuffer
3470+ ****************************************************************************/
3471+ #if defined(cl_khr_command_buffer)
3472+ void testMoveAssignCommandBufferNonNull (void );
3473+ void testMoveAssignCommandBufferNull (void );
3474+ void testMoveConstructCommandBufferNonNull (void );
3475+ void testMoveConstructCommandBufferNull (void );
3476+ namespace cl {
3477+ namespace khr {
3478+ MAKE_MOVE_TESTS (CommandBuffer, make_command_buffer_khr,
3479+ clReleaseCommandBufferKHR, commandBufferKhrPool)
3480+ } // namespace khr
3481+ } // namespace cl
3482+ #else
3483+ void testMoveAssignCommandBufferNonNull (void ) {}
3484+ void testMoveAssignCommandBufferNull (void ) {}
3485+ void testMoveConstructCommandBufferNonNull (void ) {}
3486+ void testMoveConstructCommandBufferNull (void ) {}
3487+ #endif
3488+
3489+ // Stub for clGetCommandBufferInfoKHR that returns 1
3490+ static cl_int clGetCommandBufferInfoKHR_testCommandBufferKhrGetNumQueues (
3491+ cl_command_buffer_khr command_buffer, cl_command_buffer_info_khr param_name,
3492+ size_t param_value_size, void *param_value, size_t *param_value_size_ret,
3493+ int /* num_calls*/ ) {
3494+ TEST_ASSERT_EQUAL_PTR (make_command_buffer_khr (0 ), command_buffer);
3495+ TEST_ASSERT_EQUAL_HEX (CL_COMMAND_BUFFER_NUM_QUEUES_KHR, param_name);
3496+ TEST_ASSERT (param_value == nullptr || param_value_size >= sizeof (cl_uint));
3497+ if (param_value_size_ret != nullptr )
3498+ *param_value_size_ret = sizeof (cl_uint);
3499+ if (param_value != nullptr )
3500+ *static_cast <cl_uint *>(param_value) = 1 ;
3501+ return CL_SUCCESS;
3502+ }
3503+
3504+ void testCommandBufferInfoKHRNumQueues (void ) {
3505+ #if defined(cl_khr_command_buffer)
3506+ cl_uint expected = 1 ;
3507+
3508+ clGetCommandBufferInfoKHR_StubWithCallback (
3509+ clGetCommandBufferInfoKHR_testCommandBufferKhrGetNumQueues);
3510+
3511+ cl_uint num =
3512+ commandBufferKhrPool[0 ].getInfo <CL_COMMAND_BUFFER_NUM_QUEUES_KHR>();
3513+ TEST_ASSERT_EQUAL_HEX (expected, num);
3514+ #endif
3515+ }
3516+
3517+ // Stub for clGetCommandBufferInfoKHR that returns command queues array
3518+ static cl_int clGetCommandBufferInfoKHR_testCommandBufferKhrGetCommandQueues (
3519+ cl_command_buffer_khr command_buffer, cl_command_buffer_info_khr param_name,
3520+ size_t param_value_size, void *param_value, size_t *param_value_size_ret,
3521+ int /* num_calls*/ ) {
3522+ TEST_ASSERT_EQUAL_PTR (make_command_buffer_khr (0 ), command_buffer);
3523+ TEST_ASSERT_EQUAL_HEX (CL_COMMAND_BUFFER_QUEUES_KHR, param_name);
3524+ TEST_ASSERT (param_value == nullptr ||
3525+ param_value_size >= 3 * sizeof (cl_command_queue));
3526+ if (param_value_size_ret != nullptr )
3527+ *param_value_size_ret = 3 * sizeof (cl_command_queue);
3528+ if (param_value != nullptr ) {
3529+ cl_command_queue *command_queues =
3530+ static_cast <cl_command_queue *>(param_value);
3531+ command_queues[0 ] = make_command_queue (0 );
3532+ command_queues[1 ] = make_command_queue (1 );
3533+ command_queues[2 ] = make_command_queue (2 );
3534+ }
3535+ return CL_SUCCESS;
3536+ }
3537+
3538+ void testCommandBufferInfoKHRCommandQueues (void ) {
3539+ #if defined(cl_khr_command_buffer)
3540+ // creat expected values for refcounter
3541+ VECTOR_CLASS<cl_command_queue> expected_queue_vec;
3542+ std::array<int , 3 > refcount;
3543+ for (int i = 0 ; i < 3 ; i++) {
3544+ expected_queue_vec.push_back (commandQueuePool[i]());
3545+ refcount[i] = 1 ;
3546+ }
3547+
3548+ clGetCommandBufferInfoKHR_StubWithCallback (
3549+ clGetCommandBufferInfoKHR_testCommandBufferKhrGetCommandQueues);
3550+ prepare_commandQueueRefcounts (expected_queue_vec.size (),
3551+ expected_queue_vec.data (), refcount.data ());
3552+
3553+ VECTOR_CLASS<cl::CommandQueue> command_queues =
3554+ commandBufferKhrPool[0 ].getInfo <CL_COMMAND_BUFFER_QUEUES_KHR>();
3555+ TEST_ASSERT_EQUAL (3 , command_queues.size ());
3556+ TEST_ASSERT_EQUAL_PTR (make_command_queue (0 ), command_queues[0 ]());
3557+ TEST_ASSERT_EQUAL_PTR (make_command_queue (1 ), command_queues[1 ]());
3558+ TEST_ASSERT_EQUAL_PTR (make_command_queue (2 ), command_queues[2 ]());
3559+ #endif
3560+ }
3561+
34623562// Tests for Device::GetInfo
34633563static cl_int clGetInfo_testDeviceGetInfoCLDeviceVendorId (
34643564 cl_device_id device, cl_device_info param_name, size_t param_value_size,
@@ -3540,7 +3640,9 @@ void testMoveAssignSemaphoreNonNull(void);
35403640void testMoveAssignSemaphoreNull (void );
35413641void testMoveConstructSemaphoreNonNull (void );
35423642void testMoveConstructSemaphoreNull (void );
3643+ namespace cl {
35433644MAKE_MOVE_TESTS (Semaphore, make_semaphore_khr, clReleaseSemaphoreKHR, semaphorePool);
3645+ }
35443646#else
35453647void testMoveAssignSemaphoreNonNull (void ) {}
35463648void testMoveAssignSemaphoreNull (void ) {}
@@ -4292,127 +4394,5 @@ void testTemplateGetImageRequirementsInfo()
42924394void testTemplateGetImageRequirementsInfo () {}
42934395#endif // cl_ext_image_requirements_info
42944396
4295- /* ***************************************************************************
4296- * Tests for cl::khr::CommandBuffer
4297- * Please put above any tests of functionalities defined in cl namespace.
4298- * Some macros where redifined with cl::khr namespace.
4299- ****************************************************************************/
4300- #if defined(cl_khr_command_buffer)
4301- void testMoveAssignCommandBufferNonNull (void );
4302- void testMoveAssignCommandBufferNull (void );
4303- void testMoveConstructCommandBufferNonNull (void );
4304- void testMoveConstructCommandBufferNull (void );
4305- #ifdef MAKE_MOVE_TESTS2
4306- #undef MAKE_MOVE_TESTS2
4307- #endif
4308- #define MAKE_MOVE_TESTS2 (prefix, type, makeFunc, releaseFunc, pool ) \
4309- void prefix##MoveAssign##type##NonNull(void ) { \
4310- releaseFunc##_ExpectAndReturn (makeFunc (0 ), CL_SUCCESS); \
4311- pool[0 ] = std::move (pool[1 ]); \
4312- TEST_ASSERT_EQUAL_PTR (makeFunc (1 ), pool[0 ]()); \
4313- TEST_ASSERT_NULL (pool[1 ]()); \
4314- } \
4315- \
4316- void prefix##MoveAssign##type##Null(void ) { \
4317- pool[0 ]() = nullptr ; \
4318- pool[0 ] = std::move (pool[1 ]); \
4319- TEST_ASSERT_EQUAL_PTR (makeFunc (1 ), pool[0 ]()); \
4320- TEST_ASSERT_NULL (pool[1 ]()); \
4321- } \
4322- \
4323- void prefix##MoveConstruct##type##NonNull(void ) { \
4324- cl::khr::type tmp (std::move (pool[0 ])); \
4325- TEST_ASSERT_EQUAL_PTR (makeFunc (0 ), tmp ()); \
4326- TEST_ASSERT_NULL (pool[0 ]()); \
4327- tmp () = nullptr ; \
4328- } \
4329- \
4330- void prefix##MoveConstruct##type##Null(void ) { \
4331- cl::khr::type empty; \
4332- cl::khr::type tmp (std::move (empty)); \
4333- TEST_ASSERT_NULL (tmp ()); \
4334- TEST_ASSERT_NULL (empty ()); \
4335- }
4336- MAKE_MOVE_TESTS (CommandBuffer, make_command_buffer_khr,
4337- clReleaseCommandBufferKHR, commandBufferKhrPool)
4338- #else
4339- void testMoveAssignCommandBufferNonNull (void ) {}
4340- void testMoveAssignCommandBufferNull (void ) {}
4341- void testMoveConstructCommandBufferNonNull (void ) {}
4342- void testMoveConstructCommandBufferNull (void ) {}
4343- #endif
4344-
4345- // Stub for clGetCommandBufferInfoKHR that returns 1
4346- static cl_int clGetCommandBufferInfoKHR_testCommandBufferKhrGetNumQueues (
4347- cl_command_buffer_khr command_buffer, cl_command_buffer_info_khr param_name,
4348- size_t param_value_size, void *param_value, size_t *param_value_size_ret,
4349- int /* num_calls*/ ) {
4350- TEST_ASSERT_EQUAL_PTR (make_command_buffer_khr (0 ), command_buffer);
4351- TEST_ASSERT_EQUAL_HEX (CL_COMMAND_BUFFER_NUM_QUEUES_KHR, param_name);
4352- TEST_ASSERT (param_value == nullptr || param_value_size >= sizeof (cl_uint));
4353- if (param_value_size_ret != nullptr )
4354- *param_value_size_ret = sizeof (cl_uint);
4355- if (param_value != nullptr )
4356- *static_cast <cl_uint *>(param_value) = 1 ;
4357- return CL_SUCCESS;
4358- }
4359-
4360- void testCommandBufferInfoKHRNumQueues (void ) {
4361- #if defined(cl_khr_command_buffer)
4362- cl_uint expected = 1 ;
4363-
4364- clGetCommandBufferInfoKHR_StubWithCallback (
4365- clGetCommandBufferInfoKHR_testCommandBufferKhrGetNumQueues);
4366-
4367- cl_uint num =
4368- commandBufferKhrPool[0 ].getInfo <CL_COMMAND_BUFFER_NUM_QUEUES_KHR>();
4369- TEST_ASSERT_EQUAL_HEX (expected, num);
4370- #endif
4371- }
4372-
4373- // Stub for clGetCommandBufferInfoKHR that returns command queues array
4374- static cl_int clGetCommandBufferInfoKHR_testCommandBufferKhrGetCommandQueues (
4375- cl_command_buffer_khr command_buffer, cl_command_buffer_info_khr param_name,
4376- size_t param_value_size, void *param_value, size_t *param_value_size_ret,
4377- int /* num_calls*/ ) {
4378- TEST_ASSERT_EQUAL_PTR (make_command_buffer_khr (0 ), command_buffer);
4379- TEST_ASSERT_EQUAL_HEX (CL_COMMAND_BUFFER_QUEUES_KHR, param_name);
4380- TEST_ASSERT (param_value == nullptr ||
4381- param_value_size >= 3 * sizeof (cl_command_queue));
4382- if (param_value_size_ret != nullptr )
4383- *param_value_size_ret = 3 * sizeof (cl_command_queue);
4384- if (param_value != nullptr ) {
4385- cl_command_queue *command_queues =
4386- static_cast <cl_command_queue *>(param_value);
4387- command_queues[0 ] = make_command_queue (0 );
4388- command_queues[1 ] = make_command_queue (1 );
4389- command_queues[2 ] = make_command_queue (2 );
4390- }
4391- return CL_SUCCESS;
4392- }
4393-
4394- void testCommandBufferInfoKHRCommandQueues (void ) {
4395- #if defined(cl_khr_command_buffer)
4396- // creat expected values for refcounter
4397- VECTOR_CLASS<cl_command_queue> expected_queue_vec;
4398- std::array<int , 3 > refcount;
4399- for (int i = 0 ; i < 3 ; i++) {
4400- expected_queue_vec.push_back (commandQueuePool[i]());
4401- refcount[i] = 1 ;
4402- }
4403-
4404- clGetCommandBufferInfoKHR_StubWithCallback (
4405- clGetCommandBufferInfoKHR_testCommandBufferKhrGetCommandQueues);
4406- prepare_commandQueueRefcounts (expected_queue_vec.size (),
4407- expected_queue_vec.data (), refcount.data ());
4408-
4409- VECTOR_CLASS<cl::CommandQueue> command_queues =
4410- commandBufferKhrPool[0 ].getInfo <CL_COMMAND_BUFFER_QUEUES_KHR>();
4411- TEST_ASSERT_EQUAL (3 , command_queues.size ());
4412- TEST_ASSERT_EQUAL_PTR (make_command_queue (0 ), command_queues[0 ]());
4413- TEST_ASSERT_EQUAL_PTR (make_command_queue (1 ), command_queues[1 ]());
4414- TEST_ASSERT_EQUAL_PTR (make_command_queue (2 ), command_queues[2 ]());
4415- #endif
4416- }
44174397
44184398} // extern "C"
0 commit comments