mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Reorganization directory structure [2/n]
Change-Id: I47962d17d755e80dcd9476e1ed75560f433f6115
This commit is contained in:

committed by
Jaroslaw Chodor

parent
d015d3633f
commit
e8852a68c4
111
opencl/test/unit_test/api/cl_api_tests.h
Normal file
111
opencl/test/unit_test/api/cl_api_tests.h
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/execution_environment/root_device_environment.h"
|
||||
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "opencl/source/api/api.h"
|
||||
#include "opencl/source/command_queue/command_queue.h"
|
||||
#include "opencl/source/tracing/tracing_api.h"
|
||||
#include "test.h"
|
||||
|
||||
#include "fixtures/platform_fixture.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "helpers/ult_limits.h"
|
||||
#include "helpers/variable_backup.h"
|
||||
#include "mocks/mock_kernel.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class Context;
|
||||
class MockClDevice;
|
||||
struct RootDeviceEnvironment;
|
||||
|
||||
template <uint32_t rootDeviceIndex = 1u>
|
||||
struct ApiFixture : PlatformFixture {
|
||||
ApiFixture() = default;
|
||||
~ApiFixture() = default;
|
||||
|
||||
virtual void SetUp() {
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
PlatformFixture::SetUp();
|
||||
|
||||
if (rootDeviceIndex != 0u) {
|
||||
rootDeviceEnvironmentBackup.swap(pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[0]);
|
||||
}
|
||||
|
||||
auto pDevice = pPlatform->getClDevice(testedRootDeviceIndex);
|
||||
ASSERT_NE(nullptr, pDevice);
|
||||
|
||||
testedClDevice = pDevice;
|
||||
pContext = Context::create<MockContext>(nullptr, ClDeviceVector(&testedClDevice, 1), nullptr, nullptr, retVal);
|
||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||
|
||||
pCommandQueue = new CommandQueue(pContext, pDevice, nullptr);
|
||||
|
||||
pProgram = new MockProgram(*pDevice->getExecutionEnvironment(), pContext, false, &pDevice->getDevice());
|
||||
|
||||
pKernel = new MockKernel(pProgram, pProgram->mockKernelInfo, *pDevice);
|
||||
ASSERT_NE(nullptr, pKernel);
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
pKernel->release();
|
||||
pCommandQueue->release();
|
||||
pContext->release();
|
||||
pProgram->release();
|
||||
|
||||
if (rootDeviceIndex != 0u) {
|
||||
rootDeviceEnvironmentBackup.swap(pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[0]);
|
||||
}
|
||||
|
||||
PlatformFixture::TearDown();
|
||||
}
|
||||
DebugManagerStateRestore restorer;
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
size_t retSize = 0;
|
||||
|
||||
CommandQueue *pCommandQueue = nullptr;
|
||||
Context *pContext = nullptr;
|
||||
MockKernel *pKernel = nullptr;
|
||||
MockProgram *pProgram = nullptr;
|
||||
constexpr static uint32_t numRootDevices = maxRootDeviceCount;
|
||||
constexpr static uint32_t testedRootDeviceIndex = rootDeviceIndex;
|
||||
cl_device_id testedClDevice = nullptr;
|
||||
std::unique_ptr<RootDeviceEnvironment> rootDeviceEnvironmentBackup;
|
||||
};
|
||||
|
||||
struct api_tests : public ApiFixture<>,
|
||||
public ::testing::Test {
|
||||
virtual void SetUp() override {
|
||||
ApiFixture::SetUp();
|
||||
}
|
||||
virtual void TearDown() override {
|
||||
ApiFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
struct api_fixture_using_aligned_memory_manager {
|
||||
public:
|
||||
virtual void SetUp();
|
||||
virtual void TearDown();
|
||||
|
||||
cl_int retVal;
|
||||
size_t retSize;
|
||||
|
||||
CommandQueue *commandQueue;
|
||||
Context *context;
|
||||
MockKernel *kernel;
|
||||
MockProgram *program;
|
||||
MockClDevice *device;
|
||||
};
|
||||
|
||||
using api_test_using_aligned_memory_manager = Test<api_fixture_using_aligned_memory_manager>;
|
||||
|
||||
} // namespace NEO
|
Reference in New Issue
Block a user