Return vector of HwDeviceIds from OSInterface::discoverDevices

Resolves: NEO-4310
Related-To: NEO-4208
Change-Id: Ib4ce27a18a860214b76505f6e122666c86207783
Signed-off-by: Jablonski, Mateusz <mateusz.jablonski@intel.com>
This commit is contained in:
Jablonski, Mateusz
2020-02-17 16:14:22 +01:00
committed by sys_ocldev
parent 428b123bdd
commit 624b418756
10 changed files with 101 additions and 71 deletions

View File

@@ -15,9 +15,9 @@
class DrmWrap : public NEO::Drm {
public:
static NEO::Drm *createDrm(RootDeviceEnvironment &rootDeviceEnvironment) {
auto hwDeviceId = OSInterface::discoverDevices();
if (hwDeviceId != nullptr) {
return NEO::Drm::create(std::move(hwDeviceId), rootDeviceEnvironment);
auto hwDeviceIds = OSInterface::discoverDevices();
if (!hwDeviceIds.empty()) {
return NEO::Drm::create(std::move(hwDeviceIds[0]), rootDeviceEnvironment);
}
return nullptr;
}

View File

@@ -64,8 +64,8 @@ TEST(DrmTest, GivenSelectedNotExistingDeviceWhenGetDeviceFdThenFail) {
VariableBackup<decltype(openFull)> backupOpenFull(&openFull);
openFull = testOpen;
openRetVal = -1;
auto hwDeviceId = OSInterface::discoverDevices();
EXPECT_EQ(nullptr, hwDeviceId.get());
auto hwDeviceIds = OSInterface::discoverDevices();
EXPECT_TRUE(hwDeviceIds.empty());
}
TEST(DrmTest, GivenSelectedExistingDeviceWhenGetDeviceFdThenReturnFd) {
@@ -74,8 +74,9 @@ TEST(DrmTest, GivenSelectedExistingDeviceWhenGetDeviceFdThenReturnFd) {
VariableBackup<decltype(openFull)> backupOpenFull(&openFull);
openRetVal = 1023; // fakeFd
openFull = testOpen;
auto hwDeviceId = OSInterface::discoverDevices();
EXPECT_NE(nullptr, hwDeviceId.get());
auto hwDeviceIds = OSInterface::discoverDevices();
EXPECT_EQ(1u, hwDeviceIds.size());
EXPECT_NE(nullptr, hwDeviceIds[0].get());
}
TEST(DrmTest, GivenSelectedIncorectDeviceWhenGetDeviceFdThenFail) {
@@ -85,8 +86,8 @@ TEST(DrmTest, GivenSelectedIncorectDeviceWhenGetDeviceFdThenFail) {
openFull = testOpen;
openRetVal = 1024;
auto hwDeviceId = OSInterface::discoverDevices();
EXPECT_EQ(nullptr, hwDeviceId.get());
auto hwDeviceIds = OSInterface::discoverDevices();
EXPECT_TRUE(hwDeviceIds.empty());
}
TEST_F(DrmTests, createReturnsDrm) {