mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Correct detection of compatible adapters
compare current library path with driver store path Resolves: NEO-4457 Change-Id: Ibf5463d6f51595fbb45ad9b23d6f2cfcceb907bf Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
1ce4f56c9f
commit
e46142be4d
@ -28,6 +28,10 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
namespace SysCalls {
|
||||
extern const wchar_t *currentLibraryPath;
|
||||
}
|
||||
|
||||
extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[IGFX_MAX_CORE];
|
||||
|
||||
CommandStreamReceiver *createMockCommandStreamReceiver(bool withAubDump, ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex);
|
||||
@ -99,44 +103,58 @@ TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWithoutCorrectOSInterfaceThenDont
|
||||
EXPECT_EQ(nullptr, device->driverInfo.get());
|
||||
}
|
||||
|
||||
class RegistryReaderMock : public SettingsReader {
|
||||
class MockRegistryReader : public SettingsReader {
|
||||
public:
|
||||
std::string nameString;
|
||||
std::string versionString;
|
||||
std::string getSetting(const char *settingName, const std::string &value) {
|
||||
std::string getSetting(const char *settingName, const std::string &value) override {
|
||||
std::string key(settingName);
|
||||
if (key == "HardwareInformation.AdapterString") {
|
||||
properNameKey = true;
|
||||
} else if (key == "DriverVersion") {
|
||||
properVersionKey = true;
|
||||
}
|
||||
if (key == "DriverStorePathForComputeRuntime") {
|
||||
return driverStorePath;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
bool getSetting(const char *settingName, bool defaultValue) { return defaultValue; };
|
||||
int32_t getSetting(const char *settingName, int32_t defaultValue) { return defaultValue; };
|
||||
const char *appSpecificLocation(const std::string &name) { return name.c_str(); };
|
||||
bool getSetting(const char *settingName, bool 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 properNameKey = false;
|
||||
bool properVersionKey = false;
|
||||
std::string driverStorePath = "driverStore\\0x8086";
|
||||
};
|
||||
|
||||
TEST(DriverInfo, GivenDriverInfoWhenThenReturnNonNullptr) {
|
||||
MockDriverInfoWindows driverInfo("");
|
||||
RegistryReaderMock *registryReaderMock = new RegistryReaderMock();
|
||||
struct DriverInfoWindowsTest : public ::testing::Test {
|
||||
|
||||
driverInfo.registryReader.reset(registryReaderMock);
|
||||
void SetUp() override {
|
||||
DriverInfoWindows::createRegistryReaderFunc = [](const std::string &) -> std::unique_ptr<SettingsReader> {
|
||||
return std::make_unique<MockRegistryReader>();
|
||||
};
|
||||
driverInfo = std::make_unique<MockDriverInfoWindows>("");
|
||||
}
|
||||
|
||||
VariableBackup<decltype(DriverInfoWindows::createRegistryReaderFunc)> createFuncBackup{&DriverInfoWindows::createRegistryReaderFunc};
|
||||
std::unique_ptr<MockDriverInfoWindows> driverInfo;
|
||||
};
|
||||
|
||||
TEST_F(DriverInfoWindowsTest, GivenDriverInfoWhenThenReturnNonNullptr) {
|
||||
auto registryReaderMock = static_cast<MockRegistryReader *>(driverInfo->registryReader.get());
|
||||
|
||||
std::string defaultName = "defaultName";
|
||||
|
||||
auto name = driverInfo.getDeviceName(defaultName);
|
||||
auto name = driverInfo->getDeviceName(defaultName);
|
||||
|
||||
EXPECT_STREQ(defaultName.c_str(), name.c_str());
|
||||
EXPECT_TRUE(registryReaderMock->properNameKey);
|
||||
|
||||
std::string defaultVersion = "defaultVersion";
|
||||
|
||||
auto driverVersion = driverInfo.getVersion(defaultVersion);
|
||||
auto driverVersion = driverInfo->getVersion(defaultVersion);
|
||||
|
||||
EXPECT_STREQ(defaultVersion.c_str(), driverVersion.c_str());
|
||||
EXPECT_TRUE(registryReaderMock->properVersionKey);
|
||||
@ -176,9 +194,21 @@ TEST(DriverInfo, givenNotInitializedOsInterfaceWhenCreateDriverInfoThenReturnDri
|
||||
TEST(DriverInfo, givenInitializedOsInterfaceWhenCreateDriverInfoWindowsThenSetRegistryReaderWithExpectRegKey) {
|
||||
std::string path = "";
|
||||
std::unique_ptr<MockDriverInfoWindows> driverInfo(MockDriverInfoWindows::create(path));
|
||||
std::unique_ptr<TestedRegistryReader> reader(new TestedRegistryReader(path));
|
||||
EXPECT_NE(nullptr, reader);
|
||||
EXPECT_STREQ(driverInfo->getRegistryReaderRegKey(), reader->getRegKey());
|
||||
EXPECT_STREQ(driverInfo->getRegistryReaderRegKey(), driverInfo->reader->getRegKey());
|
||||
};
|
||||
|
||||
TEST_F(DriverInfoWindowsTest, whenCurrentLibraryIsLoadedFromDriverStorePointedByDriverInfoThenItIsCompatible) {
|
||||
VariableBackup<const wchar_t *> currentLibraryPathBackup(&SysCalls::currentLibraryPath);
|
||||
currentLibraryPathBackup = L"driverStore\\0x8086\\myLib.dll";
|
||||
|
||||
EXPECT_TRUE(driverInfo->isCompatibleDriverStore());
|
||||
}
|
||||
|
||||
TEST_F(DriverInfoWindowsTest, whenCurrentLibraryIsLoadedFromDifferentDriverStoreThanPointedByDriverInfoThenItIsNotCompatible) {
|
||||
VariableBackup<const wchar_t *> currentLibraryPathBackup(&SysCalls::currentLibraryPath);
|
||||
currentLibraryPathBackup = L"driverStore\\different_driverStore\\myLib.dll";
|
||||
|
||||
EXPECT_FALSE(driverInfo->isCompatibleDriverStore());
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
@ -16,7 +16,7 @@ constexpr uintptr_t dummyHandle = static_cast<uintptr_t>(0x7);
|
||||
BOOL systemPowerStatusRetVal = 1;
|
||||
BYTE systemPowerStatusACLineStatusOverride = 1;
|
||||
HMODULE handleValue = reinterpret_cast<HMODULE>(dummyHandle);
|
||||
const wchar_t *igdrclFilePath = L"";
|
||||
const wchar_t *currentLibraryPath = L"";
|
||||
|
||||
HANDLE createEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) {
|
||||
return reinterpret_cast<HANDLE>(dummyHandle);
|
||||
@ -42,7 +42,7 @@ DWORD getModuleFileName(HMODULE hModule, LPWSTR lpFilename, DWORD nSize) {
|
||||
if (hModule != handleValue) {
|
||||
return FALSE;
|
||||
}
|
||||
lstrcpyW(lpFilename, igdrclFilePath);
|
||||
lstrcpyW(lpFilename, currentLibraryPath);
|
||||
return TRUE;
|
||||
}
|
||||
} // namespace SysCalls
|
||||
|
@ -12,9 +12,11 @@
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
#include "shared/source/os_interface/os_time.h"
|
||||
#include "shared/source/os_interface/windows/driver_info_windows.h"
|
||||
#include "shared/source/os_interface/windows/os_context_win.h"
|
||||
#include "shared/source/os_interface/windows/os_environment_win.h"
|
||||
#include "shared/source/os_interface/windows/os_interface.h"
|
||||
#include "shared/source/os_interface/windows/sys_calls.h"
|
||||
#include "shared/source/os_interface/windows/wddm/wddm_interface.h"
|
||||
#include "shared/source/os_interface/windows/wddm_allocation.h"
|
||||
#include "shared/source/os_interface/windows/wddm_engine_mapper.h"
|
||||
@ -40,7 +42,7 @@
|
||||
|
||||
namespace NEO {
|
||||
namespace SysCalls {
|
||||
extern const wchar_t *igdrclFilePath;
|
||||
extern const wchar_t *currentLibraryPath;
|
||||
}
|
||||
extern uint32_t numRootDevicesToEnum;
|
||||
} // namespace NEO
|
||||
@ -105,28 +107,6 @@ TEST(WddmDiscoverDevices, WhenNoHwDeviceIdIsProvidedToWddmThenWddmIsNotCreated)
|
||||
EXPECT_THROW(auto wddm = std::make_unique<MockWddm>(nullptr, rootDeviceEnvironment), std::exception);
|
||||
}
|
||||
|
||||
TEST(WddmDiscoverDevices, WhenAdapterDescriptionContainsDCHDAndgdrclPathDoesntContainDchDThenNoDeviceIsDiscovered) {
|
||||
VariableBackup<const wchar_t *> descriptionBackup(&UltIDXGIAdapter1::description);
|
||||
descriptionBackup = L"Intel DCH-D";
|
||||
VariableBackup<const wchar_t *> igdrclPathBackup(&SysCalls::igdrclFilePath);
|
||||
igdrclPathBackup = L"intel_dch.inf";
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
|
||||
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
|
||||
EXPECT_TRUE(hwDeviceIds.empty());
|
||||
}
|
||||
|
||||
TEST(WddmDiscoverDevices, WhenAdapterDescriptionContainsDCHIAndgdrclPathDoesntContainDchIThenNoDeviceIsDiscovered) {
|
||||
VariableBackup<const wchar_t *> descriptionBackup(&UltIDXGIAdapter1::description);
|
||||
descriptionBackup = L"Intel DCH-I";
|
||||
VariableBackup<const wchar_t *> igdrclPathBackup(&SysCalls::igdrclFilePath);
|
||||
igdrclPathBackup = L"intel_dch.inf";
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
|
||||
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
|
||||
EXPECT_TRUE(hwDeviceIds.empty());
|
||||
}
|
||||
|
||||
TEST(WddmDiscoverDevices, WhenMultipleRootDevicesAreAvailableThenAllAreDiscovered) {
|
||||
VariableBackup<uint32_t> backup{&numRootDevicesToEnum};
|
||||
numRootDevicesToEnum = 3u;
|
||||
@ -135,30 +115,6 @@ TEST(WddmDiscoverDevices, WhenMultipleRootDevicesAreAvailableThenAllAreDiscovere
|
||||
EXPECT_EQ(numRootDevicesToEnum, hwDeviceIds.size());
|
||||
}
|
||||
|
||||
TEST(WddmDiscoverDevices, WhenAdapterDescriptionContainsDCHDAndgdrclPathContainsDchDThenAdapterIsDiscovered) {
|
||||
VariableBackup<const wchar_t *> descriptionBackup(&UltIDXGIAdapter1::description);
|
||||
descriptionBackup = L"Intel DCH-D";
|
||||
VariableBackup<const wchar_t *> igdrclPathBackup(&SysCalls::igdrclFilePath);
|
||||
igdrclPathBackup = L"intel_dch_d.inf";
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
|
||||
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
|
||||
EXPECT_EQ(1u, hwDeviceIds.size());
|
||||
EXPECT_NE(nullptr, hwDeviceIds[0].get());
|
||||
}
|
||||
|
||||
TEST(Wddm20EnumAdaptersTest, WhenAdapterDescriptionContainsDCHIAndgdrclPathContainsDchIThenAdapterIsDiscovered) {
|
||||
VariableBackup<const wchar_t *> descriptionBackup(&UltIDXGIAdapter1::description);
|
||||
descriptionBackup = L"Intel DCH-I";
|
||||
VariableBackup<const wchar_t *> igdrclPathBackup(&SysCalls::igdrclFilePath);
|
||||
igdrclPathBackup = L"intel_dch_i.inf";
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
|
||||
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
|
||||
EXPECT_EQ(1u, hwDeviceIds.size());
|
||||
EXPECT_NE(nullptr, hwDeviceIds[0].get());
|
||||
}
|
||||
|
||||
TEST(WddmDiscoverDevices, WhenAdapterDescriptionContainsVirtualRenderThenAdapterIsDiscovered) {
|
||||
VariableBackup<const wchar_t *> descriptionBackup(&UltIDXGIAdapter1::description);
|
||||
descriptionBackup = L"Virtual Render";
|
||||
@ -1399,3 +1355,32 @@ TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentAndWaitPagingThenEx
|
||||
EXPECT_FALSE(logger->makeResidentCall);
|
||||
EXPECT_FALSE(logger->enterWait);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool getSetting(const char *settingName, bool 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";
|
||||
};
|
||||
VariableBackup<decltype(DriverInfoWindows::createRegistryReaderFunc)> createFuncBackup{&DriverInfoWindows::createRegistryReaderFunc};
|
||||
DriverInfoWindows::createRegistryReaderFunc = [](const std::string &) -> std::unique_ptr<SettingsReader> {
|
||||
return std::make_unique<MockRegistryReader>();
|
||||
};
|
||||
VariableBackup<const wchar_t *> currentLibraryPathBackup(&SysCalls::currentLibraryPath);
|
||||
currentLibraryPathBackup = L"driverStore\\different_driverStore\\myLib.dll";
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
|
||||
EXPECT_TRUE(hwDeviceIds.empty());
|
||||
}
|
||||
|
Reference in New Issue
Block a user