@@ -1494,28 +1494,31 @@ TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentAndWaitPagingThenEx
14941494 EXPECT_EQ (MockGdi::pagingFenceReturnValue, logger->startWaitPagingFenceSave );
14951495}
14961496
1497- TEST (DiscoverDevices, whenDriverInfoHasIncompatibleDriverStoreThenHwDeviceIdIsNotCreated) {
1498-
1499- class MockRegistryReader : public SettingsReader {
1500- public:
1501- std::string getSetting (const char *settingName, const std::string &value) override {
1502- std::string key (settingName);
1503- if (key == " DriverStorePathForComputeRuntime" ) {
1504- return driverStorePath;
1505- }
1506- return value;
1497+ class MockRegistryReaderWithDriverStorePath : public SettingsReader {
1498+ public:
1499+ MockRegistryReaderWithDriverStorePath (const char *driverStorePathArg) : driverStorePath(driverStorePathArg){};
1500+ std::string getSetting (const char *settingName, const std::string &value) override {
1501+ std::string key (settingName);
1502+ if (key == " DriverStorePathForComputeRuntime" ) {
1503+ return driverStorePath;
1504+ } else if (key == " OpenCLDriverName" ) {
1505+ return driverStorePath;
15071506 }
1507+ return value;
1508+ }
15081509
1509- bool getSetting (const char *settingName, bool defaultValue) override { return defaultValue; };
1510- int64_t getSetting (const char *settingName, int64_t defaultValue) override { return defaultValue; };
1511- int32_t getSetting (const char *settingName, int32_t defaultValue) override { return defaultValue; };
1512- const char *appSpecificLocation (const std::string &name) override { return name.c_str (); };
1510+ bool getSetting (const char *settingName, bool defaultValue) override { return defaultValue; };
1511+ int64_t getSetting (const char *settingName, int64_t defaultValue) override { return defaultValue; };
1512+ int32_t getSetting (const char *settingName, int32_t defaultValue) override { return defaultValue; };
1513+ const char *appSpecificLocation (const std::string &name) override { return name.c_str (); };
15131514
1514- std::string driverStorePath = " driverStore\\ 0x8086" ;
1515- };
1515+ const std::string driverStorePath;
1516+ };
1517+
1518+ TEST (DiscoverDevices, whenDriverInfoHasIncompatibleDriverStoreThenHwDeviceIdIsNotCreated) {
15161519 VariableBackup<decltype (DriverInfoWindows::createRegistryReaderFunc)> createFuncBackup{&DriverInfoWindows::createRegistryReaderFunc};
15171520 DriverInfoWindows::createRegistryReaderFunc = [](const std::string &) -> std::unique_ptr<SettingsReader> {
1518- return std::make_unique<MockRegistryReader>( );
1521+ return std::make_unique<MockRegistryReaderWithDriverStorePath>( " driverStore \\ 0x8086 " );
15191522 };
15201523 VariableBackup<const wchar_t *> currentLibraryPathBackup (&SysCalls::currentLibraryPath);
15211524 currentLibraryPathBackup = L" driverStore\\ different_driverStore\\ myLib.dll" ;
@@ -1524,6 +1527,42 @@ TEST(DiscoverDevices, whenDriverInfoHasIncompatibleDriverStoreThenHwDeviceIdIsNo
15241527 EXPECT_TRUE (hwDeviceIds.empty ());
15251528}
15261529
1530+ TEST (DiscoverDevices, givenDifferentCaseInLibPathAndInDriverStorePathWhenDiscoveringDeviceThenHwDeviceIdIsCreated) {
1531+ VariableBackup<decltype (DriverInfoWindows::createRegistryReaderFunc)> createFuncBackup{&DriverInfoWindows::createRegistryReaderFunc};
1532+ DriverInfoWindows::createRegistryReaderFunc = [](const std::string &) -> std::unique_ptr<SettingsReader> {
1533+ return std::make_unique<MockRegistryReaderWithDriverStorePath>(" \\ SystemRoot\\ driverStore\\ 0x8086" );
1534+ };
1535+ VariableBackup<const wchar_t *> currentLibraryPathBackup (&SysCalls::currentLibraryPath);
1536+ currentLibraryPathBackup = L" \\ SyStEmrOOt\\ driverstore\\ 0x8086\\ myLib.dll" ;
1537+ ExecutionEnvironment executionEnvironment;
1538+ auto hwDeviceIds = OSInterface::discoverDevices (executionEnvironment);
1539+ EXPECT_EQ (1u , hwDeviceIds.size ());
1540+ }
1541+
1542+ TEST (DiscoverDevices, givenLibFromHostDriverStoreAndRegistryWithDriverStoreWhenDiscoveringDeviceThenHwDeviceIdIsCreated) {
1543+ VariableBackup<decltype (DriverInfoWindows::createRegistryReaderFunc)> createFuncBackup{&DriverInfoWindows::createRegistryReaderFunc};
1544+ DriverInfoWindows::createRegistryReaderFunc = [](const std::string &) -> std::unique_ptr<SettingsReader> {
1545+ return std::make_unique<MockRegistryReaderWithDriverStorePath>(" \\ SystemRoot\\ driverStore\\ 0x8086" );
1546+ };
1547+ VariableBackup<const wchar_t *> currentLibraryPathBackup (&SysCalls::currentLibraryPath);
1548+ currentLibraryPathBackup = L" \\ SystemRoot\\ hostdriverStore\\ 0x8086\\ myLib.dll" ;
1549+ ExecutionEnvironment executionEnvironment;
1550+ auto hwDeviceIds = OSInterface::discoverDevices (executionEnvironment);
1551+ EXPECT_EQ (1u , hwDeviceIds.size ());
1552+ }
1553+
1554+ TEST (DiscoverDevices, givenLibFromDriverStoreAndRegistryWithHostDriverStoreWhenDiscoveringDeviceThenHwDeviceIdIsCreated) {
1555+ VariableBackup<decltype (DriverInfoWindows::createRegistryReaderFunc)> createFuncBackup{&DriverInfoWindows::createRegistryReaderFunc};
1556+ DriverInfoWindows::createRegistryReaderFunc = [](const std::string &) -> std::unique_ptr<SettingsReader> {
1557+ return std::make_unique<MockRegistryReaderWithDriverStorePath>(" \\ SystemRoot\\ driverStore\\ 0x8086" );
1558+ };
1559+ VariableBackup<const wchar_t *> currentLibraryPathBackup (&SysCalls::currentLibraryPath);
1560+ currentLibraryPathBackup = L" \\ SystemRoot\\ hostdriverStore\\ 0x8086\\ myLib.dll" ;
1561+ ExecutionEnvironment executionEnvironment;
1562+ auto hwDeviceIds = OSInterface::discoverDevices (executionEnvironment);
1563+ EXPECT_EQ (1u , hwDeviceIds.size ());
1564+ }
1565+
15271566TEST (VerifyAdapterType, whenAdapterDoesntSupportRenderThenDontCreateHwDeviceId) {
15281567 auto gdi = std::make_unique<MockGdi>();
15291568 auto osEnv = std::make_unique<OsEnvironmentWin>();
0 commit comments