test: mock Filesystem in IOQTaskTestsMt ULTs

The MockZebin module is used, which has prepared CopyBuffer kernel,
so it does not need to be fetched from a file

Related-To: NEO-14058
Signed-off-by: Marcel Skierkowski <marcel.skierkowski@intel.com>
This commit is contained in:
Marcel Skierkowski
2025-02-14 10:21:44 +00:00
committed by Compute-Runtime-Automation
parent 76acacd413
commit e518acea15
4 changed files with 112 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,8 +7,10 @@
#pragma once
#include "shared/source/device/device.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/helpers/file_io.h"
#include "shared/test/common/helpers/test_files.h"
#include "shared/test/common/mocks/mock_modules_zebin.h"
#include "opencl/source/kernel/kernel.h"
#include "opencl/source/platform/platform.h"
@@ -80,6 +82,47 @@ struct HelloWorldKernelFixture : public ProgramFixture {
EXPECT_EQ(CL_SUCCESS, retVal);
}
void setUp(ClDevice *pDevice, const char *kernelNameStr) {
ProgramFixture::setUp();
pKernelName = new std::string(kernelNameStr);
constexpr auto numBits = is32bit ? Elf::EI_CLASS_32 : Elf::EI_CLASS_64;
auto zebinData = std::make_unique<ZebinTestData::ZebinCopyBufferSimdModule<numBits>>(pDevice->getHardwareInfo(), 32);
const auto &src = zebinData->storage;
ASSERT_NE(nullptr, src.data());
ASSERT_NE(0u, src.size());
const unsigned char *binaries[1] = {reinterpret_cast<const unsigned char *>(src.data())};
const size_t binarySize = src.size();
auto deviceVector = toClDeviceVector(*pDevice);
pContext = Context::create<MockContext>(nullptr, deviceVector, nullptr, nullptr, retVal);
ASSERT_EQ(CL_SUCCESS, retVal);
ASSERT_NE(nullptr, pContext);
createProgramFromBinary(
pContext,
deviceVector,
binaries,
&binarySize);
ASSERT_NE(nullptr, pProgram);
retVal = pProgram->build(
pProgram->getDevices(),
nullptr);
ASSERT_EQ(CL_SUCCESS, retVal);
// create a kernel
pMultiDeviceKernel = MultiDeviceKernel::create<MockKernel, Program, MockMultiDeviceKernel>(
pProgram,
pProgram->getKernelInfosForKernel(pKernelName->c_str()),
retVal);
pKernel = static_cast<MockKernel *>(pMultiDeviceKernel->getKernel(pDevice->getRootDeviceIndex()));
EXPECT_NE(nullptr, pKernel);
EXPECT_EQ(CL_SUCCESS, retVal);
}
void tearDown() {
delete pKernelName;
delete pTestFilename;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -96,6 +96,25 @@ void ProgramFixture::createProgramFromBinary(Context *pContext,
ASSERT_EQ(CL_SUCCESS, retVal);
}
void ProgramFixture::createProgramFromBinary(Context *pContext,
const ClDeviceVector &deviceVector,
const unsigned char **binary,
const size_t *binarySize) {
cleanup();
cl_int retVal = CL_SUCCESS;
pProgram = Program::create<MockProgram>(
pContext,
deviceVector,
binarySize,
binary,
nullptr,
retVal);
ASSERT_NE(nullptr, pProgram);
ASSERT_EQ(CL_SUCCESS, retVal);
}
NEOProgramFixture::NEOProgramFixture() = default;
NEOProgramFixture::~NEOProgramFixture() = default;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -32,6 +32,11 @@ class NEOProgramFixture {
class ProgramFixture {
public:
void createProgramFromBinary(Context *pContext,
const ClDeviceVector &deviceVector,
const unsigned char **binary,
const size_t *binarySize);
void createProgramFromBinary(Context *pContext,
const ClDeviceVector &deviceVector,
const std::string &binaryFileName,

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -14,7 +14,47 @@
using namespace NEO;
typedef HelloWorldTest<HelloWorldFixtureFactory> IOQTaskTestsMt;
struct IOQTaskTestsMt : public HelloWorldTest<HelloWorldFixtureFactory> {
void SetUp() override {
ClDeviceFixture::setUp();
ASSERT_NE(nullptr, pClDevice);
pDevice->disableSecondaryEngines = true;
CommandQueueFixture::setUp(pClDevice, 0);
ASSERT_NE(nullptr, pCmdQ);
CommandStreamFixture::setUp(pCmdQ);
ASSERT_NE(nullptr, pCS);
IndirectHeapFixture::setUp(pCmdQ);
KernelFixture::setUp(pClDevice, kernelName);
ASSERT_NE(nullptr, pKernel);
auto retVal = CL_INVALID_VALUE;
BufferDefaults::context = new MockContext(pClDevice);
destBuffer = Buffer::create(
BufferDefaults::context,
CL_MEM_READ_WRITE,
sizeUserMemory,
nullptr,
retVal);
srcBuffer = Buffer::create(
BufferDefaults::context,
CL_MEM_READ_WRITE,
sizeUserMemory,
nullptr,
retVal);
pDestMemory = destBuffer->getCpuAddressForMapping();
pSrcMemory = srcBuffer->getCpuAddressForMapping();
memset(pDestMemory, destPattern, sizeUserMemory);
memset(pSrcMemory, srcPattern, sizeUserMemory);
pKernel->setArg(0, srcBuffer);
pKernel->setArg(1, destBuffer);
}
};
TEST_F(IOQTaskTestsMt, GivenBlockingAndBlockedOnUserEventWhenReadingBufferThenTaskCountAndTaskLevelAreIncremented) {
auto buffer = std::unique_ptr<Buffer>(BufferHelper<>::create());