From a42cce885aa0b7f051fe8e310c6dc77a54a32987 Mon Sep 17 00:00:00 2001 From: piotr-wozniak-mobica Date: Tue, 8 Aug 2023 12:19:56 +0200 Subject: [PATCH] UT for createKernels --- tests/test_openclhpp.cpp | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index cb112b5c..80ee9e30 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -4472,4 +4472,45 @@ void testTemplateGetImageRequirementsInfo() void testTemplateGetImageRequirementsInfo() {} #endif // cl_ext_image_requirements_info +static cl_int clCreateKernelsInProgram_testcreateKernels( + cl_program program, cl_uint num_kernels, cl_kernel *kernels, + cl_uint *num_kernels_ret, int num_calls) { + switch (num_calls) { + case 0: + case 1: + TEST_ASSERT_EQUAL(make_program(0), program); + if (num_kernels_ret != nullptr) { + *num_kernels_ret = 1; + } + return CL_SUCCESS; + case 2: + TEST_ASSERT_EQUAL(make_program(1), program); + if (num_kernels_ret != nullptr) { + *num_kernels_ret = 1; + } + return CL_SUCCESS; + case 3: + TEST_ASSERT_EQUAL(make_program(1), program); + return CL_DEVICE_NOT_FOUND; + case 4: + TEST_ASSERT_EQUAL(make_program(2), program); + return CL_DEVICE_NOT_AVAILABLE; + default: + return CL_SUCCESS; + } +} + +void testcreateKernels() { + cl_int ret = 0; + cl::vector kernels; + + clCreateKernelsInProgram_StubWithCallback( + clCreateKernelsInProgram_testcreateKernels); + ret = programPool[0].createKernels(&kernels); + TEST_ASSERT_EQUAL(CL_SUCCESS, ret); + ret = programPool[1].createKernels(&kernels); + TEST_ASSERT_EQUAL(CL_DEVICE_NOT_FOUND, ret); + ret = programPool[2].createKernels(&kernels); + TEST_ASSERT_EQUAL(CL_DEVICE_NOT_AVAILABLE, ret); +} } // extern "C"