mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-10 15:12:56 +08:00
Remove USE_REAL_FILE_SYSTEM() macro uses from API, program, kernel and gtpin tests. Related-To: NEO-15069 Signed-off-by: Oskar Hubert Weber <oskar.hubert.weber@intel.com>
90 lines
2.4 KiB
C++
90 lines
2.4 KiB
C++
/*
|
|
* Copyright (C) 2018-2025 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "shared/test/common/mocks/mock_zebin_wrapper.h"
|
|
|
|
#include "opencl/source/context/context.h"
|
|
|
|
#include "cl_api_tests.h"
|
|
|
|
using namespace NEO;
|
|
|
|
using ClReleaseKernelTests = ApiTests;
|
|
|
|
namespace ULT {
|
|
|
|
TEST_F(ClReleaseKernelTests, GivenNullKernelWhenReleasingKernelThenClInvalidKernelErrorIsReturned) {
|
|
retVal = clReleaseKernel(nullptr);
|
|
EXPECT_EQ(CL_INVALID_KERNEL, retVal);
|
|
}
|
|
|
|
TEST_F(ClReleaseKernelTests, GivenRetainedKernelWhenReleasingKernelThenKernelIsCorrectlyReleased) {
|
|
cl_kernel kernel = nullptr;
|
|
cl_program program = nullptr;
|
|
cl_int binaryStatus = CL_SUCCESS;
|
|
MockZebinWrapper zebin{pDevice->getHardwareInfo()};
|
|
|
|
program = clCreateProgramWithBinary(
|
|
pContext,
|
|
1,
|
|
&testedClDevice,
|
|
zebin.binarySizes.data(),
|
|
zebin.binaries.data(),
|
|
&binaryStatus,
|
|
&retVal);
|
|
|
|
EXPECT_NE(nullptr, program);
|
|
ASSERT_EQ(CL_SUCCESS, retVal);
|
|
|
|
retVal = clBuildProgram(program, 1, &testedClDevice, nullptr, nullptr, nullptr);
|
|
|
|
ASSERT_EQ(CL_SUCCESS, retVal);
|
|
|
|
kernel = clCreateKernel(program, zebin.kernelName, &retVal);
|
|
|
|
EXPECT_NE(nullptr, kernel);
|
|
ASSERT_EQ(CL_SUCCESS, retVal);
|
|
|
|
cl_uint theRef;
|
|
retVal = clGetKernelInfo(kernel, CL_KERNEL_REFERENCE_COUNT, sizeof(cl_uint), &theRef, NULL);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
EXPECT_EQ(1u, theRef);
|
|
|
|
retVal = clRetainKernel(kernel);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
retVal = clRetainKernel(kernel);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
|
|
retVal = clGetKernelInfo(kernel, CL_KERNEL_REFERENCE_COUNT, sizeof(cl_uint), &theRef, NULL);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
EXPECT_EQ(3u, theRef);
|
|
|
|
retVal = clReleaseKernel(kernel);
|
|
ASSERT_EQ(CL_SUCCESS, retVal);
|
|
retVal = clReleaseKernel(kernel);
|
|
ASSERT_EQ(CL_SUCCESS, retVal);
|
|
|
|
retVal = clGetKernelInfo(kernel, CL_KERNEL_REFERENCE_COUNT, sizeof(cl_uint), &theRef, NULL);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
EXPECT_EQ(1u, theRef);
|
|
|
|
retVal = clReleaseKernel(kernel);
|
|
ASSERT_EQ(CL_SUCCESS, retVal);
|
|
|
|
retVal = clReleaseProgram(program);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
}
|
|
|
|
TEST_F(ClReleaseKernelTests, GivenInvalidKernelWhenTerdownWasCalledThenSuccessReturned) {
|
|
wasPlatformTeardownCalled = true;
|
|
auto retVal = clReleaseKernel(nullptr);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
wasPlatformTeardownCalled = false;
|
|
}
|
|
|
|
} // namespace ULT
|