mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 09:58:55 +08:00
fix: fix issues with ubsan in shared and OCL tests
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
6d67198b4f
commit
781533565e
@@ -234,7 +234,7 @@ TEST_F(EnqueueSvmTest, GivenValidParamsWhenFreeingSvmWithCallbackThenSuccessIsRe
|
||||
ClbHelper(bool &callbackWasCalled)
|
||||
: callbackWasCalled(callbackWasCalled) {}
|
||||
|
||||
static void CL_CALLBACK clb(cl_command_queue queue, cl_uint numSvmPointers, void *svmPointers[], void *usrData) {
|
||||
static void CL_CALLBACK clb(cl_command_queue queue, cl_uint numSvmPointers, void **svmPointers, void *usrData) {
|
||||
ClbHelper *data = (ClbHelper *)usrData;
|
||||
data->callbackWasCalled = true;
|
||||
}
|
||||
@@ -264,7 +264,7 @@ TEST_F(EnqueueSvmTest, GivenValidParamsWhenFreeingSvmWithCallbackAndEventThenSuc
|
||||
ClbHelper(bool &callbackWasCalled)
|
||||
: callbackWasCalled(callbackWasCalled) {}
|
||||
|
||||
static void CL_CALLBACK clb(cl_command_queue queue, cl_uint numSvmPointers, void *svmPointers[], void *usrData) {
|
||||
static void CL_CALLBACK clb(cl_command_queue queue, cl_uint numSvmPointers, void **svmPointers, void *usrData) {
|
||||
ClbHelper *data = (ClbHelper *)usrData;
|
||||
data->callbackWasCalled = true;
|
||||
}
|
||||
|
||||
@@ -123,8 +123,8 @@ class D3D9Tests : public PlatformFixture, public ::testing::Test {
|
||||
MockContext *context;
|
||||
MockCommandQueue *cmdQ;
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
char dummyD3DSurface;
|
||||
char dummyD3DSurfaceStaging;
|
||||
uint64_t dummyD3DSurface{};
|
||||
uint64_t dummyD3DSurfaceStaging{};
|
||||
cl_dx9_surface_info_khr surfaceInfo = {};
|
||||
|
||||
Gmm *gmm = nullptr;
|
||||
@@ -457,7 +457,7 @@ TEST_F(D3D9Tests, givenNonDefaultPoolWhenSurfaceIsCreatedThenReturnError) {
|
||||
|
||||
TEST_F(D3D9Tests, givenAlreadyUsedSurfaceWhenSurfaceIsCreatedThenReturnError) {
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
surfaceInfo.resource = reinterpret_cast<IDirect3DSurface9 *>(1);
|
||||
surfaceInfo.resource = reinterpret_cast<IDirect3DSurface9 *>(0x8);
|
||||
|
||||
mockSharingFcns->getTexture2dDescSetParams = true;
|
||||
mockSharingFcns->getTexture2dDescParamsSet.textureDesc = mockSharingFcns->mockTexture2dDesc;
|
||||
@@ -1270,7 +1270,7 @@ static const std::tuple<uint32_t /*d3dFormat*/, uint32_t /*plane*/, uint32_t /*c
|
||||
std::make_tuple(D3DFMT_UYVY, 0, CL_UYVY_INTEL, CL_UNORM_INT8, ImagePlane::NO_PLANE),
|
||||
std::make_tuple(MAKEFOURCC('Y', 'V', 'Y', 'U'), 0, CL_YVYU_INTEL, CL_UNORM_INT8, ImagePlane::NO_PLANE),
|
||||
std::make_tuple(MAKEFOURCC('V', 'Y', 'U', 'Y'), 0, CL_VYUY_INTEL, CL_UNORM_INT8, ImagePlane::NO_PLANE),
|
||||
std::make_tuple(CL_INVALID_VALUE, 0, 0, 0, ImagePlane::NO_PLANE)};
|
||||
std::make_tuple(D3DFMT_UNKNOWN, 0, 0, 0, ImagePlane::NO_PLANE)};
|
||||
}
|
||||
|
||||
struct D3D9ImageFormatTests
|
||||
|
||||
@@ -383,7 +383,7 @@ TYPED_TEST_P(D3DTests, givenSharedResourceFlagWhenCreateBufferThenStagingBufferE
|
||||
this->mockSharingFcns->getBufferDescParamsSet.bufferDesc = this->mockSharingFcns->mockBufferDesc;
|
||||
|
||||
this->mockSharingFcns->createQuerySetParams = true;
|
||||
this->mockSharingFcns->createQueryParamsSet.query = reinterpret_cast<typename TestFixture::D3DQuery *>(1);
|
||||
this->mockSharingFcns->createQueryParamsSet.query = reinterpret_cast<typename TestFixture::D3DQuery *>(0x8);
|
||||
|
||||
auto buffer = std::unique_ptr<Buffer>(D3DBuffer<TypeParam>::create(this->context, reinterpret_cast<typename TestFixture::D3DBufferObj *>(&this->dummyD3DBuffer), CL_MEM_READ_WRITE, nullptr));
|
||||
ASSERT_NE(nullptr, buffer.get());
|
||||
@@ -420,7 +420,7 @@ TYPED_TEST_P(D3DTests, givenNonSharedResourceFlagWhenCreateBufferThenCreateNewSt
|
||||
this->mockSharingFcns->createBufferParamsSet.buffer = reinterpret_cast<typename TestFixture::D3DBufferObj *>(&this->dummyD3DBufferStaging);
|
||||
|
||||
this->mockSharingFcns->createQuerySetParams = true;
|
||||
this->mockSharingFcns->createQueryParamsSet.query = reinterpret_cast<typename TestFixture::D3DQuery *>(1);
|
||||
this->mockSharingFcns->createQueryParamsSet.query = reinterpret_cast<typename TestFixture::D3DQuery *>(0x8);
|
||||
|
||||
auto buffer = std::unique_ptr<Buffer>(D3DBuffer<TypeParam>::create(this->context, reinterpret_cast<typename TestFixture::D3DBufferObj *>(&this->dummyD3DBuffer), CL_MEM_READ_WRITE, nullptr));
|
||||
ASSERT_NE(nullptr, buffer.get());
|
||||
|
||||
@@ -198,12 +198,12 @@ class D3DTests : public PlatformFixture, public ::testing::Test {
|
||||
}
|
||||
|
||||
MockD3DSharingFunctions<T> *mockSharingFcns;
|
||||
MockContext *context;
|
||||
MockCommandQueue *cmdQ;
|
||||
char dummyD3DBuffer;
|
||||
char dummyD3DBufferStaging;
|
||||
char dummyD3DTexture;
|
||||
char dummyD3DTextureStaging;
|
||||
MockContext *context = nullptr;
|
||||
MockCommandQueue *cmdQ = nullptr;
|
||||
uint64_t dummyD3DBuffer{};
|
||||
uint64_t dummyD3DBufferStaging{};
|
||||
uint64_t dummyD3DTexture{};
|
||||
uint64_t dummyD3DTextureStaging{};
|
||||
Gmm *gmm = nullptr;
|
||||
MockGmmResourceInfo *mockGmmResInfo = nullptr;
|
||||
|
||||
|
||||
@@ -2018,7 +2018,7 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenKernelDoesNotHaveDebugDataT
|
||||
static size_t debugDataSize = 0;
|
||||
gtpinCallbacks.onContextCreate = onContextCreate;
|
||||
gtpinCallbacks.onContextDestroy = onContextDestroy;
|
||||
gtpinCallbacks.onKernelCreate = [](context_handle_t context, const instrument_params_in_t *paramsIn, instrument_params_out_t *paramsOut) {
|
||||
gtpinCallbacks.onKernelCreate = [](context_handle_t context, const instrument_params_in_t *paramsIn, instrument_params_out_t *paramsOut) -> void {
|
||||
paramsOut->inst_kernel_binary = const_cast<uint8_t *>(paramsIn->orig_kernel_binary);
|
||||
paramsOut->inst_kernel_size = paramsIn->orig_kernel_size;
|
||||
paramsOut->kernel_id = paramsIn->igc_hash_id;
|
||||
@@ -2045,7 +2045,7 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenKernelHasDebugDataThenCorre
|
||||
size_t dummyDebugDataSize = 0x2245;
|
||||
gtpinCallbacks.onContextCreate = onContextCreate;
|
||||
gtpinCallbacks.onContextDestroy = onContextDestroy;
|
||||
gtpinCallbacks.onKernelCreate = [](context_handle_t context, const instrument_params_in_t *paramsIn, instrument_params_out_t *paramsOut) {
|
||||
gtpinCallbacks.onKernelCreate = [](context_handle_t context, const instrument_params_in_t *paramsIn, instrument_params_out_t *paramsOut) -> void {
|
||||
paramsOut->inst_kernel_binary = const_cast<uint8_t *>(paramsIn->orig_kernel_binary);
|
||||
paramsOut->inst_kernel_size = paramsIn->orig_kernel_size;
|
||||
paramsOut->kernel_id = paramsIn->igc_hash_id;
|
||||
@@ -2072,7 +2072,7 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenInstrumentedBinaryIsZebinTh
|
||||
static size_t debugDataSize = 0;
|
||||
gtpinCallbacks.onContextCreate = onContextCreate;
|
||||
gtpinCallbacks.onContextDestroy = onContextDestroy;
|
||||
gtpinCallbacks.onKernelCreate = [](context_handle_t context, const instrument_params_in_t *paramsIn, instrument_params_out_t *paramsOut) {
|
||||
gtpinCallbacks.onKernelCreate = [](context_handle_t context, const instrument_params_in_t *paramsIn, instrument_params_out_t *paramsOut) -> void {
|
||||
debugDataPtr = const_cast<void *>(paramsIn->debug_data);
|
||||
debugDataSize = paramsIn->debug_data_size;
|
||||
};
|
||||
@@ -2106,7 +2106,7 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenInstrumentedBinaryIsZebinTh
|
||||
HWTEST_F(GTPinTests, givenGtPinInitializedWhenSubmittingKernelCommandThenFlushedTaskCountIsNotified) {
|
||||
auto mockCmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(pContext, pDevice, nullptr);
|
||||
|
||||
auto onKernelSubmitFnc = [](command_buffer_handle_t cb, uint64_t kernelId, uint32_t *entryOffset, resource_handle_t *resource) { return; };
|
||||
auto onKernelSubmitFnc = [](command_buffer_handle_t cb, uint64_t kernelId, uint32_t *entryOffset, resource_handle_t *resource) -> void {};
|
||||
|
||||
gtpinCallbacks.onContextCreate = onContextCreate;
|
||||
gtpinCallbacks.onContextDestroy = onContextDestroy;
|
||||
@@ -2420,7 +2420,7 @@ HWTEST_F(GTPinTestsWithLocalMemory, givenGtPinCanUseSharedAllocationWhenGtpinNot
|
||||
gtpinCallbacks.onContextCreate = onContextCreate;
|
||||
gtpinCallbacks.onContextDestroy = onContextDestroy;
|
||||
gtpinCallbacks.onKernelCreate = onKernelCreate;
|
||||
gtpinCallbacks.onKernelSubmit = [](command_buffer_handle_t cb, uint64_t kernelId, uint32_t *entryOffset, resource_handle_t *resource) {
|
||||
gtpinCallbacks.onKernelSubmit = [](command_buffer_handle_t cb, uint64_t kernelId, uint32_t *entryOffset, resource_handle_t *resource) -> void {
|
||||
auto allocData = std::make_unique<SvmAllocationData>(0);
|
||||
auto mockGA = std::make_unique<MockGraphicsAllocation>();
|
||||
allocData->gpuAllocations.addAllocation(mockGA.get());
|
||||
|
||||
@@ -215,11 +215,11 @@ BOOL WINAPI wglMakeCurrent(HDC arg1, HGLRC arg2) {
|
||||
}
|
||||
return (GLboolean)1;
|
||||
};
|
||||
void *WINAPI mockLoader(const char *name) {
|
||||
PROC mockLoader(const char *name) {
|
||||
if (strcmp(name, "realFunction") == 0) {
|
||||
return reinterpret_cast<void *>(*realFunction);
|
||||
return reinterpret_cast<PROC>(*realFunction);
|
||||
}
|
||||
return nullptr;
|
||||
return 0u;
|
||||
};
|
||||
void resetParam(const char *name) {
|
||||
if (strcmp(name, "glAcquireSharedBufferCalled") == 0) {
|
||||
|
||||
@@ -332,7 +332,7 @@ StatusCode MockMetricsLibraryValidInterface::getData(GetReportData_1_0 *data) {
|
||||
//////////////////////////////////////////////////////
|
||||
void PerformanceCountersDeviceFixture::setUp() {
|
||||
createFunc = Device::createPerformanceCountersFunc;
|
||||
Device::createPerformanceCountersFunc = [](Device *) { return MockPerformanceCounters::create(); };
|
||||
Device::createPerformanceCountersFunc = [](Device *) -> std::unique_ptr<PerformanceCounters> { return MockPerformanceCounters::create(); };
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
@@ -2527,7 +2527,7 @@ TEST_F(ProgramTests, givenProgramWithSpirvWhenRebuildProgramIsCalledThenSpirvPat
|
||||
debugVars.receivedInput = &receivedInput;
|
||||
debugVars.forceBuildFailure = true;
|
||||
gEnvironment->igcPushDebugVars(debugVars);
|
||||
std::unique_ptr<void, void (*)(void *)> igcDebugVarsAutoPop{&gEnvironment, [](void *) { gEnvironment->igcPopDebugVars(); }};
|
||||
std::unique_ptr<void, void (*)(void *)> igcDebugVarsAutoPop{&gEnvironment, [](void *) -> void { gEnvironment->igcPopDebugVars(); }};
|
||||
|
||||
auto program = clUniquePtr(new MockProgram(toClDeviceVector(*pClDevice)));
|
||||
uint32_t spirv[16] = {0x03022307, 0x23471113, 0x17192329};
|
||||
@@ -2625,7 +2625,7 @@ TEST_F(ProgramTests, whenRebuildingProgramThenStoreDeviceBinaryProperly) {
|
||||
debugVars.binaryToReturn = binaryToReturn;
|
||||
debugVars.binaryToReturnSize = sizeof(binaryToReturn);
|
||||
gEnvironment->igcPushDebugVars(debugVars);
|
||||
std::unique_ptr<void, void (*)(void *)> igcDebugVarsAutoPop{&gEnvironment, [](void *) { gEnvironment->igcPopDebugVars(); }};
|
||||
std::unique_ptr<void, void (*)(void *)> igcDebugVarsAutoPop{&gEnvironment, [](void *) -> void { gEnvironment->igcPopDebugVars(); }};
|
||||
|
||||
auto program = clUniquePtr(new MockProgram(toClDeviceVector(*pClDevice)));
|
||||
uint32_t ir[16] = {0x03022307, 0x23471113, 0x17192329};
|
||||
|
||||
@@ -675,7 +675,7 @@ TEST(glSharingBasicTest, givenWhenCheckGLSharingSupportedThenReturnTrue) {
|
||||
}
|
||||
|
||||
TEST(glSharingBasicTest, givenVendorisNullWhenCheckGLSharingSupportedThenReturnFalse) {
|
||||
auto invalidGetStringFcn = [](GLenum name) {
|
||||
auto invalidGetStringFcn = [](GLenum name) -> const GLubyte * {
|
||||
return (const GLubyte *)"";
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -65,7 +65,7 @@ struct CpuInfo {
|
||||
}
|
||||
|
||||
static void (*cpuidexFunc)(int *, int, int);
|
||||
static void (*cpuidFunc)(int[4], int);
|
||||
static void (*cpuidFunc)(int *, int);
|
||||
static void (*getCpuFlagsFunc)(std::string &);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
void cpuidWindowsWrapper(int cpuInfo[4], int functionId) {
|
||||
void cpuidWindowsWrapper(int *cpuInfo, int functionId) {
|
||||
__cpuid(cpuInfo, functionId);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ void cpuidexWindowsWrapper(int *cpuInfo, int functionId, int subfunctionId) {
|
||||
void getCpuFlagsWindows(std::string &cpuFlags) {}
|
||||
|
||||
void (*CpuInfo::cpuidexFunc)(int *, int, int) = cpuidexWindowsWrapper;
|
||||
void (*CpuInfo::cpuidFunc)(int[4], int) = cpuidWindowsWrapper;
|
||||
void (*CpuInfo::cpuidFunc)(int *, int) = cpuidWindowsWrapper;
|
||||
void (*CpuInfo::getCpuFlagsFunc)(std::string &) = getCpuFlagsWindows;
|
||||
|
||||
const CpuInfo CpuInfo::instance;
|
||||
|
||||
@@ -252,7 +252,7 @@ TEST(WslUmKmDataTranslator, whenQueryingForTranslationThenQueryIsForwardedToWslC
|
||||
auto gmmHandleAllocator = translator->createGmmHandleAllocator();
|
||||
ASSERT_NE(nullptr, gmmHandleAllocator);
|
||||
gmmHandleAllocator->getHandleSize();
|
||||
UmKmDataTempStorage<GMM_RESOURCE_INFO> gmmResInfo;
|
||||
UmKmDataTempStorage<GMM_RESOURCE_INFO> gmmResInfo{};
|
||||
EXPECT_EQ(sizeof(GmmResourceInfoWinStruct), gmmHandleAllocator->getHandleSize());
|
||||
auto gmmResourceInfoHandle = gmmHandleAllocator->createHandle(reinterpret_cast<GMM_RESOURCE_INFO *>(gmmResInfo.data()));
|
||||
ASSERT_NE(nullptr, gmmResourceInfoHandle);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
* Copyright (C) 2019-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -11,28 +11,28 @@
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
void mockCpuidEnableAll(int cpuInfo[4], int functionId) {
|
||||
void mockCpuidEnableAll(int *cpuInfo, int functionId) {
|
||||
cpuInfo[0] = -1;
|
||||
cpuInfo[1] = -1;
|
||||
cpuInfo[2] = -1;
|
||||
cpuInfo[3] = -1;
|
||||
}
|
||||
|
||||
void mockCpuidFunctionAvailableDisableAll(int cpuInfo[4], int functionId) {
|
||||
void mockCpuidFunctionAvailableDisableAll(int *cpuInfo, int functionId) {
|
||||
cpuInfo[0] = -1;
|
||||
cpuInfo[1] = 0;
|
||||
cpuInfo[2] = 0;
|
||||
cpuInfo[3] = 0;
|
||||
}
|
||||
|
||||
void mockCpuidFunctionNotAvailableDisableAll(int cpuInfo[4], int functionId) {
|
||||
void mockCpuidFunctionNotAvailableDisableAll(int *cpuInfo, int functionId) {
|
||||
cpuInfo[0] = 0;
|
||||
cpuInfo[1] = 0;
|
||||
cpuInfo[2] = 0;
|
||||
cpuInfo[3] = 0;
|
||||
}
|
||||
|
||||
void mockCpuidReport36BitVirtualAddressSize(int cpuInfo[4], int functionId) {
|
||||
void mockCpuidReport36BitVirtualAddressSize(int *cpuInfo, int functionId) {
|
||||
if (static_cast<uint32_t>(functionId) == 0x80000008) {
|
||||
cpuInfo[0] = 36 << 8;
|
||||
cpuInfo[1] = 0;
|
||||
@@ -44,7 +44,7 @@ void mockCpuidReport36BitVirtualAddressSize(int cpuInfo[4], int functionId) {
|
||||
}
|
||||
|
||||
TEST(CpuInfoTest, giveFunctionIsNotAvailableWhenFeatureIsNotSupportedThenMaskBitIsOff) {
|
||||
void (*defaultCpuidFunc)(int[4], int) = CpuInfo::cpuidFunc;
|
||||
void (*defaultCpuidFunc)(int *, int) = CpuInfo::cpuidFunc;
|
||||
CpuInfo::cpuidFunc = mockCpuidFunctionNotAvailableDisableAll;
|
||||
|
||||
CpuInfo testCpuInfo;
|
||||
@@ -56,7 +56,7 @@ TEST(CpuInfoTest, giveFunctionIsNotAvailableWhenFeatureIsNotSupportedThenMaskBit
|
||||
}
|
||||
|
||||
TEST(CpuInfoTest, giveFunctionIsAvailableWhenFeatureIsNotSupportedThenMaskBitIsOff) {
|
||||
void (*defaultCpuidFunc)(int[4], int) = CpuInfo::cpuidFunc;
|
||||
void (*defaultCpuidFunc)(int *, int) = CpuInfo::cpuidFunc;
|
||||
CpuInfo::cpuidFunc = mockCpuidFunctionAvailableDisableAll;
|
||||
|
||||
CpuInfo testCpuInfo;
|
||||
@@ -68,7 +68,7 @@ TEST(CpuInfoTest, giveFunctionIsAvailableWhenFeatureIsNotSupportedThenMaskBitIsO
|
||||
}
|
||||
|
||||
TEST(CpuInfoTest, whenFeatureIsSupportedThenMaskBitIsOn) {
|
||||
void (*defaultCpuidFunc)(int[4], int) = CpuInfo::cpuidFunc;
|
||||
void (*defaultCpuidFunc)(int *, int) = CpuInfo::cpuidFunc;
|
||||
CpuInfo::cpuidFunc = mockCpuidEnableAll;
|
||||
|
||||
CpuInfo testCpuInfo;
|
||||
@@ -80,7 +80,7 @@ TEST(CpuInfoTest, whenFeatureIsSupportedThenMaskBitIsOn) {
|
||||
}
|
||||
|
||||
TEST(CpuInfoTest, WhenGettingVirtualAddressSizeThenCorrectResultIsReturned) {
|
||||
void (*defaultCpuidFunc)(int[4], int) = CpuInfo::cpuidFunc;
|
||||
void (*defaultCpuidFunc)(int *, int) = CpuInfo::cpuidFunc;
|
||||
CpuInfo::cpuidFunc = mockCpuidReport36BitVirtualAddressSize;
|
||||
|
||||
CpuInfo testCpuInfo;
|
||||
|
||||
Reference in New Issue
Block a user