refactor regex when scanning pci paths

Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
This commit is contained in:
Artur Harasimiuk
2021-10-26 17:29:17 +00:00
committed by Compute-Runtime-Automation
parent ba767dfbaf
commit 6769df2f5d
3 changed files with 40 additions and 7 deletions

View File

@ -853,3 +853,25 @@ TEST_F(DrmTests, givenValidPciPathThenPciBusInfoIsAvailable) {
EXPECT_EQ(drm->getPciBusInfo().pciFunction, referenceData[idx - 7][3]);
}
}
TEST_F(DrmTests, givenInValidPciPathThenNothingIsReturned) {
VariableBackup<decltype(openFull)> backupOpenFull(&openFull);
VariableBackup<decltype(failOnOpenDir)> backupOpenDir(&failOnOpenDir, false);
VariableBackup<decltype(entryIndex)> backupEntryIndex(&entryIndex, 0u);
openFull = openWithCounter;
entryIndex = 11;
openCounter = 1;
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
EXPECT_TRUE(hwDeviceIds.empty());
entryIndex = 12;
openCounter = 1;
hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
EXPECT_TRUE(hwDeviceIds.empty());
entryIndex = 13;
openCounter = 1;
hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
EXPECT_TRUE(hwDeviceIds.empty());
}

View File

@ -115,6 +115,9 @@ struct dirent entries[] = {
{0, 0, 0, 0, "pci-0000:b3:03.1-render"},
{0, 0, 0, 0, "pci-0000:00:b3.1-render"},
{0, 0, 0, 0, "pci-0000:00:03.a-render"},
{0, 0, 0, 0, "pci-0000:00:03.a-render-12"},
{0, 0, 0, 0, "pcii0000:00:03.a-render"},
{0, 0, 0, 0, "pcii-render"},
};
uint32_t entryIndex = 0u;