Override engine type used by device in Device ctor

AUB tests do not use DeviceFactory class to create Device objects but still
need to have a functionality to override default engine type

Change-Id: I6841cb0a9c5726ac4308c742c78cf7a61829f168
This commit is contained in:
Zdanowicz, Zbigniew
2018-02-12 11:48:31 +01:00
committed by sys_ocldev
parent b5dab07aa2
commit 5a175cf1cf
6 changed files with 21 additions and 29 deletions

View File

@ -118,6 +118,19 @@ TEST_F(DeviceTest, getEngineTypeDefault) {
EXPECT_EQ(defaultEngineType, actualEngineType);
}
TEST_F(DeviceTest, givenDebugVariableOverrideEngineTypeWhenDeviceIsCreatedThenUseDebugNotDefaul) {
EngineType expectedEngine = EngineType::ENGINE_VCS;
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.NodeOrdinal.set(static_cast<int32_t>(expectedEngine));
auto pTestDevice = std::unique_ptr<Device>(createWithUsDeviceId(0));
EngineType actualEngineType = pTestDevice->getEngineType();
EngineType defaultEngineType = hwInfoHelper.capabilityTable.defaultEngineType;
EXPECT_NE(defaultEngineType, actualEngineType);
EXPECT_EQ(expectedEngine, actualEngineType);
}
struct SmallMockDevice : public Device {
SmallMockDevice(const HardwareInfo &hwInfo, bool isRootDevice = true)
: Device(hwInfo, isRootDevice) {}
@ -129,4 +142,4 @@ TEST(DeviceCreation, givenDeviceWithUsedTagAllocationWhenItIsDestroyedThenThereA
std::unique_ptr<SmallMockDevice> device(Device::create<SmallMockDevice>(platformDevices[0]));
auto tagAllocation = device->peekTagAllocation();
tagAllocation->taskCount = 1;
}
}

View File

@ -116,19 +116,3 @@ TEST_F(DeviceFactoryTest, overrideKmdNotifySettings) {
DeviceFactory::releaseDevices();
}
TEST_F(DeviceFactoryTest, getEngineTypeDebugOverride) {
DebugManagerStateRestore dbgRestorer;
int32_t debugEngineType = 2;
DebugManager.flags.NodeOrdinal.set(debugEngineType);
HardwareInfo *hwInfoOverriden = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices);
ASSERT_TRUE(success);
ASSERT_NE(nullptr, hwInfoOverriden);
int32_t actualEngineType = static_cast<int32_t>(hwInfoOverriden->capabilityTable.defaultEngineType);
EXPECT_EQ(debugEngineType, actualEngineType);
DeviceFactory::releaseDevices();
}