mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-28 08:37:12 +08:00
Functions: fileExists and loadDataToFile use IO functions from namespace IoFunctions Now tests that use these functions are mocked by default, but some still require access to real files and have been restored the ability to read files. They will be mocked in next PRs. Related-To: NEO-7006 Signed-off-by: Marcel Skierkowski <marcel.skierkowski@intel.com>
98 lines
2.9 KiB
C++
98 lines
2.9 KiB
C++
/*
|
|
* Copyright (C) 2018-2025 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
#include "shared/source/built_ins/built_ins.h"
|
|
#include "shared/source/helpers/file_io.h"
|
|
|
|
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
|
|
#include "opencl/test/unit_test/fixtures/context_fixture.h"
|
|
#include "opencl/test/unit_test/fixtures/program_fixture.h"
|
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
|
|
|
#include <string>
|
|
|
|
namespace NEO {
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// ProgramFromBinaryTest Test Fixture
|
|
// Used to test the Program class
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
struct ProgramFromBinaryFixture : public ClDeviceFixture,
|
|
public ContextFixture,
|
|
public ProgramFixture,
|
|
public testing::Test {
|
|
|
|
using ContextFixture::setUp;
|
|
|
|
void SetUp() override {
|
|
ProgramFromBinaryFixture::setUp("CopyBuffer_simd32", "CopyBuffer");
|
|
}
|
|
void setUp(const char *binaryFileName, const char *kernelName) {
|
|
USE_REAL_FILE_SYSTEM();
|
|
this->binaryFileName = binaryFileName;
|
|
this->kernelName = kernelName;
|
|
ClDeviceFixture::setUp();
|
|
|
|
cl_device_id device = pClDevice;
|
|
ContextFixture::setUp(1, &device);
|
|
ProgramFixture::setUp();
|
|
|
|
if (options.size())
|
|
createProgramFromBinary(pContext, pContext->getDevices(), binaryFileName, options);
|
|
else
|
|
createProgramFromBinary(pContext, pContext->getDevices(), binaryFileName);
|
|
}
|
|
|
|
void TearDown() override {
|
|
knownSource.reset();
|
|
ProgramFixture::tearDown();
|
|
ContextFixture::tearDown();
|
|
ClDeviceFixture::tearDown();
|
|
}
|
|
|
|
void setOptions(std::string &optionsIn) {
|
|
options = optionsIn;
|
|
}
|
|
|
|
const char *binaryFileName = nullptr;
|
|
const char *kernelName = nullptr;
|
|
cl_int retVal = CL_SUCCESS;
|
|
std::string options;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// ProgramSimpleFixture Test Fixture
|
|
// Used to test the Program class, but not using parameters
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
class ProgramSimpleFixture : public ClDeviceFixture,
|
|
public ContextFixture,
|
|
public ProgramFixture {
|
|
using ContextFixture::setUp;
|
|
|
|
public:
|
|
void setUp() {
|
|
USE_REAL_FILE_SYSTEM();
|
|
ClDeviceFixture::setUp();
|
|
|
|
cl_device_id device = pClDevice;
|
|
ContextFixture::setUp(1, &device);
|
|
ProgramFixture::setUp();
|
|
}
|
|
|
|
void tearDown() {
|
|
knownSource.reset();
|
|
ProgramFixture::tearDown();
|
|
ContextFixture::tearDown();
|
|
ClDeviceFixture::tearDown();
|
|
}
|
|
|
|
protected:
|
|
cl_int retVal = CL_SUCCESS;
|
|
};
|
|
} // namespace NEO
|