Correct CreateMultipleRootDevices logic on Linux

respect CreateMultipleRootDevices flag when more devices are available

Related-To: NEO-3691
Change-Id: I6ed3d018535e227f7d673e23c27cfd44d6ac453d
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-05-21 13:01:07 +02:00
committed by sys_ocldev
parent 5cea4d4a37
commit 7f02a39f75
2 changed files with 54 additions and 0 deletions

View File

@ -152,6 +152,54 @@ TEST(DrmTest, GivenSelectedExistingDeviceWhenOpenDirFailsThenRetryOpeningRenderD
EXPECT_STREQ("00:02.0", hwDeviceIds[1]->getPciPath());
}
TEST(DrmTest, GivenSelectedNonExistingDeviceWhenOpenDirFailsThenRetryOpeningRenderDevicesAndNoDevicesAreCreated) {
VariableBackup<decltype(openFull)> backupOpenFull(&openFull);
VariableBackup<decltype(failOnOpenDir)> backupOpenDir(&failOnOpenDir, true);
openFull = openWithCounter;
openCounter = 0;
ExecutionEnvironment executionEnvironment;
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
EXPECT_EQ(0u, hwDeviceIds.size());
}
TEST(DrmTest, GivenFailingOpenDirAndMultipleAvailableDevicesWhenCreateMultipleRootDevicesFlagIsSetThenTheFlagIsRespected) {
DebugManagerStateRestore stateRestore;
VariableBackup<decltype(openFull)> backupOpenFull(&openFull);
VariableBackup<decltype(failOnOpenDir)> backupOpenDir(&failOnOpenDir, true);
openFull = openWithCounter;
ExecutionEnvironment executionEnvironment;
const uint32_t requestedNumRootDevices = 2u;
DebugManager.flags.CreateMultipleRootDevices.set(requestedNumRootDevices);
openCounter = 4;
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
EXPECT_STREQ("/dev/dri/renderD129", lastOpenedPath.c_str());
EXPECT_EQ(requestedNumRootDevices, hwDeviceIds.size());
EXPECT_NE(nullptr, hwDeviceIds[0].get());
EXPECT_STREQ("00:02.0", hwDeviceIds[0]->getPciPath());
EXPECT_NE(nullptr, hwDeviceIds[1].get());
EXPECT_STREQ("00:02.0", hwDeviceIds[1]->getPciPath());
}
TEST(DrmTest, GivenMultipleAvailableDevicesWhenCreateMultipleRootDevicesFlagIsSetThenTheFlagIsRespected) {
DebugManagerStateRestore stateRestore;
VariableBackup<decltype(openFull)> backupOpenFull(&openFull);
openFull = openWithCounter;
ExecutionEnvironment executionEnvironment;
const uint32_t requestedNumRootDevices = 2u;
DebugManager.flags.CreateMultipleRootDevices.set(requestedNumRootDevices);
openCounter = 4;
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
EXPECT_STREQ("/dev/dri/by-path/pci-0000:test2-render", lastOpenedPath.c_str());
EXPECT_EQ(requestedNumRootDevices, hwDeviceIds.size());
EXPECT_NE(nullptr, hwDeviceIds[0].get());
EXPECT_STREQ("test1", hwDeviceIds[0]->getPciPath());
EXPECT_NE(nullptr, hwDeviceIds[1].get());
EXPECT_STREQ("test2", hwDeviceIds[1]->getPciPath());
}
TEST(DrmTest, GivenSelectedIncorectDeviceWhenGetDeviceFdThenFail) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.ForceDeviceId.set("1234");