mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
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:

committed by
Compute-Runtime-Automation

parent
bcf93a6aeb
commit
294045071b
@ -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>();
|
||||
|
Reference in New Issue
Block a user