Improve driverstore compatibility checker

make checker case-insensitive
handle HostDriverStore scenarios

Related-To: NEO-5182, NEO-6025
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2021-07-01 18:26:01 +00:00
committed by Compute-Runtime-Automation
parent bcf93a6aeb
commit 294045071b
2 changed files with 66 additions and 19 deletions

View File

@ -1494,28 +1494,31 @@ TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentAndWaitPagingThenEx
EXPECT_EQ(MockGdi::pagingFenceReturnValue, logger->startWaitPagingFenceSave);
}
TEST(DiscoverDevices, whenDriverInfoHasIncompatibleDriverStoreThenHwDeviceIdIsNotCreated) {
class MockRegistryReader : public SettingsReader {
public:
std::string getSetting(const char *settingName, const std::string &value) override {
std::string key(settingName);
if (key == "DriverStorePathForComputeRuntime") {
return driverStorePath;
}
return value;
class MockRegistryReaderWithDriverStorePath : public SettingsReader {
public:
MockRegistryReaderWithDriverStorePath(const char *driverStorePathArg) : driverStorePath(driverStorePathArg){};
std::string getSetting(const char *settingName, const std::string &value) override {
std::string key(settingName);
if (key == "DriverStorePathForComputeRuntime") {
return driverStorePath;
} else if (key == "OpenCLDriverName") {
return driverStorePath;
}
return value;
}
bool getSetting(const char *settingName, bool defaultValue) override { return defaultValue; };
int64_t getSetting(const char *settingName, int64_t defaultValue) override { return defaultValue; };
int32_t getSetting(const char *settingName, int32_t defaultValue) override { return defaultValue; };
const char *appSpecificLocation(const std::string &name) override { return name.c_str(); };
bool getSetting(const char *settingName, bool defaultValue) override { return defaultValue; };
int64_t getSetting(const char *settingName, int64_t defaultValue) override { return defaultValue; };
int32_t getSetting(const char *settingName, int32_t defaultValue) override { return defaultValue; };
const char *appSpecificLocation(const std::string &name) override { return name.c_str(); };
std::string driverStorePath = "driverStore\\0x8086";
};
const std::string driverStorePath;
};
TEST(DiscoverDevices, whenDriverInfoHasIncompatibleDriverStoreThenHwDeviceIdIsNotCreated) {
VariableBackup<decltype(DriverInfoWindows::createRegistryReaderFunc)> createFuncBackup{&DriverInfoWindows::createRegistryReaderFunc};
DriverInfoWindows::createRegistryReaderFunc = [](const std::string &) -> std::unique_ptr<SettingsReader> {
return std::make_unique<MockRegistryReader>();
return std::make_unique<MockRegistryReaderWithDriverStorePath>("driverStore\\0x8086");
};
VariableBackup<const wchar_t *> currentLibraryPathBackup(&SysCalls::currentLibraryPath);
currentLibraryPathBackup = L"driverStore\\different_driverStore\\myLib.dll";
@ -1524,6 +1527,42 @@ TEST(DiscoverDevices, whenDriverInfoHasIncompatibleDriverStoreThenHwDeviceIdIsNo
EXPECT_TRUE(hwDeviceIds.empty());
}
TEST(DiscoverDevices, givenDifferentCaseInLibPathAndInDriverStorePathWhenDiscoveringDeviceThenHwDeviceIdIsCreated) {
VariableBackup<decltype(DriverInfoWindows::createRegistryReaderFunc)> createFuncBackup{&DriverInfoWindows::createRegistryReaderFunc};
DriverInfoWindows::createRegistryReaderFunc = [](const std::string &) -> std::unique_ptr<SettingsReader> {
return std::make_unique<MockRegistryReaderWithDriverStorePath>("\\SystemRoot\\driverStore\\0x8086");
};
VariableBackup<const wchar_t *> currentLibraryPathBackup(&SysCalls::currentLibraryPath);
currentLibraryPathBackup = L"\\SyStEmrOOt\\driverstore\\0x8086\\myLib.dll";
ExecutionEnvironment executionEnvironment;
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
EXPECT_EQ(1u, hwDeviceIds.size());
}
TEST(DiscoverDevices, givenLibFromHostDriverStoreAndRegistryWithDriverStoreWhenDiscoveringDeviceThenHwDeviceIdIsCreated) {
VariableBackup<decltype(DriverInfoWindows::createRegistryReaderFunc)> createFuncBackup{&DriverInfoWindows::createRegistryReaderFunc};
DriverInfoWindows::createRegistryReaderFunc = [](const std::string &) -> std::unique_ptr<SettingsReader> {
return std::make_unique<MockRegistryReaderWithDriverStorePath>("\\SystemRoot\\driverStore\\0x8086");
};
VariableBackup<const wchar_t *> currentLibraryPathBackup(&SysCalls::currentLibraryPath);
currentLibraryPathBackup = L"\\SystemRoot\\hostdriverStore\\0x8086\\myLib.dll";
ExecutionEnvironment executionEnvironment;
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
EXPECT_EQ(1u, hwDeviceIds.size());
}
TEST(DiscoverDevices, givenLibFromDriverStoreAndRegistryWithHostDriverStoreWhenDiscoveringDeviceThenHwDeviceIdIsCreated) {
VariableBackup<decltype(DriverInfoWindows::createRegistryReaderFunc)> createFuncBackup{&DriverInfoWindows::createRegistryReaderFunc};
DriverInfoWindows::createRegistryReaderFunc = [](const std::string &) -> std::unique_ptr<SettingsReader> {
return std::make_unique<MockRegistryReaderWithDriverStorePath>("\\SystemRoot\\driverStore\\0x8086");
};
VariableBackup<const wchar_t *> currentLibraryPathBackup(&SysCalls::currentLibraryPath);
currentLibraryPathBackup = L"\\SystemRoot\\hostdriverStore\\0x8086\\myLib.dll";
ExecutionEnvironment executionEnvironment;
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
EXPECT_EQ(1u, hwDeviceIds.size());
}
TEST(VerifyAdapterType, whenAdapterDoesntSupportRenderThenDontCreateHwDeviceId) {
auto gdi = std::make_unique<MockGdi>();
auto osEnv = std::make_unique<OsEnvironmentWin>();