mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Refactor unit tests
- refactor image fixture - add hwInfo fixture - add missing case to mockGmm Change-Id: I5f0886b8bd8f36938e1eedc5a0a63fe01248fcad Signed-off-by: Woloszyn, Wojciech <wojciech.woloszyn@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
71f6524197
commit
9a89426ec1
@@ -860,7 +860,7 @@ typedef HwHelperTest DeviceCapsWithModifiedHwInfoTest;
|
||||
TEST_F(DeviceCapsWithModifiedHwInfoTest, GivenLocalMemorySupportedAndOsEnableLocalMemoryAndEnableLocalMemoryDebugVarWhenSetThenGetEnableLocalMemoryReturnCorrectValue) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
VariableBackup<bool> orgOsEnableLocalMemory(&OSInterface::osEnableLocalMemory);
|
||||
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
|
||||
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfoHelper.hwInfo));
|
||||
bool orgHwCapsLocalMemorySupported = device->getHardwareCapabilities().localMemorySupported;
|
||||
|
||||
DebugManager.flags.EnableLocalMemory.set(false);
|
||||
@@ -889,9 +889,9 @@ TEST_F(DeviceCapsWithModifiedHwInfoTest, GivenLocalMemorySupportedAndOsEnableLoc
|
||||
|
||||
TEST_F(DeviceCapsWithModifiedHwInfoTest, givenPlatformWithSourceLevelDebuggerNotSupportedWhenDeviceIsCreatedThenSourceLevelDebuggerActiveIsSetToFalse) {
|
||||
|
||||
hwInfo.capabilityTable.sourceLevelDebuggerSupported = false;
|
||||
hwInfoHelper.hwInfo.capabilityTable.sourceLevelDebuggerSupported = false;
|
||||
|
||||
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
|
||||
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfoHelper.hwInfo));
|
||||
|
||||
const auto &caps = device->getDeviceInfo();
|
||||
EXPECT_EQ(nullptr, device->getSourceLevelDebugger());
|
||||
|
||||
@@ -40,4 +40,4 @@ set(IGDRCL_SRCS_tests_fixtures
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ult_command_stream_receiver_fixture.h
|
||||
)
|
||||
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_fixtures})
|
||||
set_property(GLOBAL PROPERTY IGDRCL_SRCS_tests_fixtures ${IGDRCL_SRCS_tests_fixtures})
|
||||
set_property(GLOBAL PROPERTY IGDRCL_SRCS_tests_fixtures ${IGDRCL_SRCS_tests_fixtures})
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "runtime/mem_obj/image.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "unit_tests/helpers/hw_info_helper.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "CL/cl.h"
|
||||
#include <cassert>
|
||||
@@ -108,18 +109,16 @@ class ImageClearColorFixture {
|
||||
public:
|
||||
using GmmHelper = OCLRT::GmmHelper;
|
||||
using MockContext = OCLRT::MockContext;
|
||||
using HardwareInfo = OCLRT::HardwareInfo;
|
||||
using Image = OCLRT::Image;
|
||||
using ImageHw = OCLRT::ImageHw<FamilyType>;
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
using AUXILIARY_SURFACE_MODE = typename FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
|
||||
|
||||
void SetUp() {
|
||||
localHwInfo = *OCLRT::platformDevices[0];
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedImages = true;
|
||||
hwInfoHelper.hwInfo.capabilityTable.ftrRenderCompressedImages = true;
|
||||
|
||||
OCLRT::platformImpl.reset();
|
||||
OCLRT::constructPlatform()->peekExecutionEnvironment()->initGmm(&localHwInfo);
|
||||
OCLRT::constructPlatform()->peekExecutionEnvironment()->initGmm(&hwInfoHelper.hwInfo);
|
||||
|
||||
surfaceState = RENDER_SURFACE_STATE::sInit();
|
||||
surfaceState.setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
|
||||
@@ -133,7 +132,7 @@ class ImageClearColorFixture {
|
||||
}
|
||||
|
||||
RENDER_SURFACE_STATE surfaceState;
|
||||
HardwareInfo localHwInfo = {};
|
||||
HwInfoHelper hwInfoHelper;
|
||||
|
||||
protected:
|
||||
MockContext context;
|
||||
|
||||
@@ -18,8 +18,8 @@ GEN10TEST_F(HwHelperTestCnl, whenCnlRevIdForStepCThenSetCapabilityCoherencyFlagF
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
|
||||
bool coherency = true;
|
||||
HardwareInfo testHwInfo = hwInfo;
|
||||
PLATFORM testPlatform = *hwInfo.pPlatform;
|
||||
HardwareInfo testHwInfo = hwInfoHelper.hwInfo;
|
||||
PLATFORM testPlatform = *hwInfoHelper.hwInfo.pPlatform;
|
||||
testHwInfo.pPlatform = &testPlatform;
|
||||
testPlatform.usRevId = 0x3;
|
||||
helper.setCapabilityCoherencyFlag(&testHwInfo, coherency);
|
||||
@@ -30,8 +30,8 @@ GEN10TEST_F(HwHelperTestCnl, whenCnlRevIdForStepDThenSetCapabilityCoherencyFlagT
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
|
||||
bool coherency = false;
|
||||
HardwareInfo testHwInfo = hwInfo;
|
||||
PLATFORM testPlatform = *hwInfo.pPlatform;
|
||||
HardwareInfo testHwInfo = hwInfoHelper.hwInfo;
|
||||
PLATFORM testPlatform = *hwInfoHelper.hwInfo.pPlatform;
|
||||
testHwInfo.pPlatform = &testPlatform;
|
||||
testPlatform.usRevId = 0x4;
|
||||
helper.setCapabilityCoherencyFlag(&testHwInfo, coherency);
|
||||
@@ -42,28 +42,28 @@ GEN10TEST_F(HwHelperTestCnl, setupPreemptionRegisters) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
|
||||
bool preemption = false;
|
||||
preemption = helper.setupPreemptionRegisters(&hwInfo, preemption);
|
||||
preemption = helper.setupPreemptionRegisters(&hwInfoHelper.hwInfo, preemption);
|
||||
EXPECT_FALSE(preemption);
|
||||
EXPECT_FALSE(hwInfo.capabilityTable.whitelistedRegisters.csChicken1_0x2580);
|
||||
EXPECT_FALSE(hwInfoHelper.hwInfo.capabilityTable.whitelistedRegisters.csChicken1_0x2580);
|
||||
|
||||
preemption = true;
|
||||
preemption = helper.setupPreemptionRegisters(&hwInfo, preemption);
|
||||
preemption = helper.setupPreemptionRegisters(&hwInfoHelper.hwInfo, preemption);
|
||||
EXPECT_TRUE(preemption);
|
||||
EXPECT_TRUE(hwInfo.capabilityTable.whitelistedRegisters.csChicken1_0x2580);
|
||||
EXPECT_TRUE(hwInfoHelper.hwInfo.capabilityTable.whitelistedRegisters.csChicken1_0x2580);
|
||||
}
|
||||
|
||||
GEN10TEST_F(HwHelperTestCnl, adjustDefaultEngineType) {
|
||||
auto engineType = hwInfo.capabilityTable.defaultEngineType;
|
||||
auto engineType = hwInfoHelper.hwInfo.capabilityTable.defaultEngineType;
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
helper.adjustDefaultEngineType(&hwInfo);
|
||||
EXPECT_EQ(engineType, hwInfo.capabilityTable.defaultEngineType);
|
||||
helper.adjustDefaultEngineType(&hwInfoHelper.hwInfo);
|
||||
EXPECT_EQ(engineType, hwInfoHelper.hwInfo.capabilityTable.defaultEngineType);
|
||||
}
|
||||
|
||||
GEN10TEST_F(HwHelperTestCnl, givenGen10PlatformWhenSetupHardwareCapabilitiesIsCalledThenDefaultImplementationIsUsed) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
|
||||
// Test default method implementation
|
||||
testDefaultImplementationOfSetupHardwareCapabilities(helper, hwInfo);
|
||||
testDefaultImplementationOfSetupHardwareCapabilities(helper, hwInfoHelper.hwInfo);
|
||||
}
|
||||
|
||||
GEN10TEST_F(HwHelperTestCnl, whenGetConfigureAddressSpaceModeThenReturnZero) {
|
||||
|
||||
@@ -20,7 +20,7 @@ GEN8TEST_F(HwHelperTestBdw, setCapabilityCoherencyFlag) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
|
||||
bool coherency = false;
|
||||
helper.setCapabilityCoherencyFlag(&hwInfo, coherency);
|
||||
helper.setCapabilityCoherencyFlag(&hwInfoHelper.hwInfo, coherency);
|
||||
EXPECT_TRUE(coherency);
|
||||
}
|
||||
|
||||
@@ -28,25 +28,25 @@ GEN8TEST_F(HwHelperTestBdw, setupPreemptionRegisters) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
|
||||
bool preemption = false;
|
||||
preemption = helper.setupPreemptionRegisters(&hwInfo, preemption);
|
||||
preemption = helper.setupPreemptionRegisters(&hwInfoHelper.hwInfo, preemption);
|
||||
EXPECT_FALSE(preemption);
|
||||
|
||||
preemption = true;
|
||||
preemption = helper.setupPreemptionRegisters(&hwInfo, preemption);
|
||||
preemption = helper.setupPreemptionRegisters(&hwInfoHelper.hwInfo, preemption);
|
||||
EXPECT_FALSE(preemption);
|
||||
}
|
||||
|
||||
GEN8TEST_F(HwHelperTestBdw, adjustDefaultEngineType) {
|
||||
auto engineType = hwInfo.capabilityTable.defaultEngineType;
|
||||
auto engineType = hwInfoHelper.hwInfo.capabilityTable.defaultEngineType;
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
helper.adjustDefaultEngineType(&hwInfo);
|
||||
EXPECT_EQ(engineType, hwInfo.capabilityTable.defaultEngineType);
|
||||
helper.adjustDefaultEngineType(&hwInfoHelper.hwInfo);
|
||||
EXPECT_EQ(engineType, hwInfoHelper.hwInfo.capabilityTable.defaultEngineType);
|
||||
}
|
||||
|
||||
GEN8TEST_F(HwHelperTestBdw, givenGen8PlatformWhenSetupHardwareCapabilitiesIsCalledThenSpecificImplementationIsUsed) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
HardwareCapabilities hwCaps = {0};
|
||||
helper.setupHardwareCapabilities(&hwCaps, hwInfo);
|
||||
helper.setupHardwareCapabilities(&hwCaps, hwInfoHelper.hwInfo);
|
||||
|
||||
EXPECT_EQ(2048u, hwCaps.image3DMaxHeight);
|
||||
EXPECT_EQ(2048u, hwCaps.image3DMaxWidth);
|
||||
@@ -57,4 +57,4 @@ GEN8TEST_F(HwHelperTestBdw, givenGen8PlatformWhenSetupHardwareCapabilitiesIsCall
|
||||
GEN8TEST_F(HwHelperTestBdw, whenGetConfigureAddressSpaceModeThenReturnZero) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
EXPECT_EQ(0u, helper.getConfigureAddressSpaceMode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ GEN9TEST_F(HwHelperTestSkl, setCapabilityCoherencyFlag) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
|
||||
bool coherency = false;
|
||||
helper.setCapabilityCoherencyFlag(&hwInfo, coherency);
|
||||
helper.setCapabilityCoherencyFlag(&hwInfoHelper.hwInfo, coherency);
|
||||
EXPECT_TRUE(coherency);
|
||||
}
|
||||
|
||||
@@ -26,28 +26,28 @@ GEN9TEST_F(HwHelperTestSkl, setupPreemptionRegisters) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
|
||||
bool preemption = false;
|
||||
preemption = helper.setupPreemptionRegisters(&hwInfo, preemption);
|
||||
preemption = helper.setupPreemptionRegisters(&hwInfoHelper.hwInfo, preemption);
|
||||
EXPECT_FALSE(preemption);
|
||||
EXPECT_FALSE(hwInfo.capabilityTable.whitelistedRegisters.csChicken1_0x2580);
|
||||
EXPECT_FALSE(hwInfoHelper.hwInfo.capabilityTable.whitelistedRegisters.csChicken1_0x2580);
|
||||
|
||||
preemption = true;
|
||||
preemption = helper.setupPreemptionRegisters(&hwInfo, preemption);
|
||||
preemption = helper.setupPreemptionRegisters(&hwInfoHelper.hwInfo, preemption);
|
||||
EXPECT_TRUE(preemption);
|
||||
EXPECT_TRUE(hwInfo.capabilityTable.whitelistedRegisters.csChicken1_0x2580);
|
||||
EXPECT_TRUE(hwInfoHelper.hwInfo.capabilityTable.whitelistedRegisters.csChicken1_0x2580);
|
||||
}
|
||||
|
||||
GEN9TEST_F(HwHelperTestSkl, adjustDefaultEngineType) {
|
||||
auto engineType = hwInfo.capabilityTable.defaultEngineType;
|
||||
auto engineType = hwInfoHelper.hwInfo.capabilityTable.defaultEngineType;
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
helper.adjustDefaultEngineType(&hwInfo);
|
||||
EXPECT_EQ(engineType, hwInfo.capabilityTable.defaultEngineType);
|
||||
helper.adjustDefaultEngineType(&hwInfoHelper.hwInfo);
|
||||
EXPECT_EQ(engineType, hwInfoHelper.hwInfo.capabilityTable.defaultEngineType);
|
||||
}
|
||||
|
||||
GEN9TEST_F(HwHelperTestSkl, givenGen9PlatformWhenSetupHardwareCapabilitiesIsCalledThenDefaultImplementationIsUsed) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
|
||||
// Test default method implementation
|
||||
testDefaultImplementationOfSetupHardwareCapabilities(helper, hwInfo);
|
||||
testDefaultImplementationOfSetupHardwareCapabilities(helper, hwInfoHelper.hwInfo);
|
||||
}
|
||||
|
||||
GEN9TEST_F(HwHelperTestSkl, givenDebuggingActiveWhenSipKernelTypeIsQueriedThenDbgCsrLocalTypeIsReturned) {
|
||||
@@ -60,4 +60,4 @@ GEN9TEST_F(HwHelperTestSkl, givenDebuggingActiveWhenSipKernelTypeIsQueriedThenDb
|
||||
GEN9TEST_F(HwHelperTestSkl, whenGetConfigureAddressSpaceModeThenReturnZero) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
EXPECT_EQ(0u, helper.getConfigureAddressSpaceMode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ set(IGDRCL_SRCS_tests_helpers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_default_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_parse.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_parse.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_commands_tests.cpp
|
||||
|
||||
@@ -11,15 +11,6 @@
|
||||
#include "unit_tests/helpers/unit_test_helper.h"
|
||||
|
||||
void HwHelperTest::SetUp() {
|
||||
memcpy(&testPlatform, platformDevices[0]->pPlatform, sizeof(testPlatform));
|
||||
memcpy(&testFtrTable, platformDevices[0]->pSkuTable, sizeof(testFtrTable));
|
||||
memcpy(&testWaTable, platformDevices[0]->pWaTable, sizeof(testWaTable));
|
||||
memcpy(&testSysInfo, platformDevices[0]->pSysInfo, sizeof(testSysInfo));
|
||||
hwInfo.capabilityTable = platformDevices[0]->capabilityTable;
|
||||
hwInfo.pPlatform = &testPlatform;
|
||||
hwInfo.pSkuTable = &testFtrTable;
|
||||
hwInfo.pSysInfo = &testSysInfo;
|
||||
hwInfo.pWaTable = &testWaTable;
|
||||
}
|
||||
void HwHelperTest::TearDown() {
|
||||
}
|
||||
@@ -80,7 +71,7 @@ TEST_F(HwHelperTest, givenEngineTypeRcsWhenCsTraitsAreQueiredThenCorrectNameInTr
|
||||
|
||||
HWTEST_F(HwHelperTest, givenHwHelperWhenAskedForPageTableManagerSupportThenReturnCorrectValue) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
EXPECT_EQ(helper.isPageTableManagerSupported(hwInfo), UnitTestHelper<FamilyType>::isPageTableManagerSupported(hwInfo));
|
||||
EXPECT_EQ(helper.isPageTableManagerSupported(hwInfoHelper.hwInfo), UnitTestHelper<FamilyType>::isPageTableManagerSupported(hwInfoHelper.hwInfo));
|
||||
}
|
||||
|
||||
TEST(DwordBuilderTest, setNonMaskedBits) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/hw_helper.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/helpers/hw_info_helper.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
@@ -17,12 +18,7 @@ class HwHelperTest : public testing::Test {
|
||||
protected:
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
PLATFORM testPlatform;
|
||||
FeatureTable testFtrTable;
|
||||
WorkaroundTable testWaTable;
|
||||
GT_SYSTEM_INFO testSysInfo;
|
||||
HardwareInfo hwInfo;
|
||||
HwInfoHelper hwInfoHelper;
|
||||
};
|
||||
|
||||
void testDefaultImplementationOfSetupHardwareCapabilities(HwHelper &hwHelper, const HardwareInfo &hwInfo);
|
||||
|
||||
31
unit_tests/helpers/hw_info_helper.h
Normal file
31
unit_tests/helpers/hw_info_helper.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
struct HwInfoHelper {
|
||||
HwInfoHelper() {
|
||||
memcpy(&testPlatform, platformDevices[0]->pPlatform, sizeof(testPlatform));
|
||||
memcpy(&testFtrTable, platformDevices[0]->pSkuTable, sizeof(testFtrTable));
|
||||
memcpy(&testWaTable, platformDevices[0]->pWaTable, sizeof(testWaTable));
|
||||
memcpy(&testSysInfo, platformDevices[0]->pSysInfo, sizeof(testSysInfo));
|
||||
hwInfo.capabilityTable = platformDevices[0]->capabilityTable;
|
||||
hwInfo.pPlatform = &testPlatform;
|
||||
hwInfo.pSkuTable = &testFtrTable;
|
||||
hwInfo.pSysInfo = &testSysInfo;
|
||||
hwInfo.pWaTable = &testWaTable;
|
||||
}
|
||||
|
||||
PLATFORM testPlatform;
|
||||
FeatureTable testFtrTable;
|
||||
WorkaroundTable testWaTable;
|
||||
GT_SYSTEM_INFO testSysInfo;
|
||||
HardwareInfo hwInfo;
|
||||
};
|
||||
@@ -87,6 +87,11 @@ void MockGmmResourceInfo::setSurfaceFormat() {
|
||||
}
|
||||
};
|
||||
|
||||
if (mockResourceCreateParams.Format == GMM_RESOURCE_FORMAT::GMM_FORMAT_P010) {
|
||||
tempSurface.GMMSurfaceFormat = GMM_RESOURCE_FORMAT::GMM_FORMAT_P010;
|
||||
surfaceFormatInfo = &tempSurface;
|
||||
}
|
||||
|
||||
iterate(SurfaceFormats::readOnly());
|
||||
iterate(SurfaceFormats::writeOnly());
|
||||
iterate(SurfaceFormats::readWrite());
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "runtime/gmm_helper/resource_info.h"
|
||||
#include "runtime/helpers/surface_formats.h"
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#if defined(__clang__)
|
||||
@@ -83,6 +84,7 @@ class MockGmmResourceInfo : public GmmResourceInfo {
|
||||
|
||||
uint32_t getOffsetCalled = 0u;
|
||||
uint32_t arrayIndexPassedToGetOffset = 0;
|
||||
SurfaceFormatInfo tempSurface{};
|
||||
|
||||
protected:
|
||||
MockGmmResourceInfo();
|
||||
|
||||
Reference in New Issue
Block a user