mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
Added DeviceId filtering under Linux
Change-Id: Ie4b91d139beb8f31d50737d829e9d8fe801dcfa1 Signed-off-by: Koska <andrzej.koska@intel.com> Related-To: NEO-3239
This commit is contained in:
committed by
sys_ocldev
parent
68d152a3d9
commit
1f6dde3f02
@@ -48,6 +48,55 @@ void initializeTestedDevice() {
|
||||
}
|
||||
}
|
||||
|
||||
int openRetVal = 0;
|
||||
int testOpen(const char *fullPath, int, ...) {
|
||||
return openRetVal;
|
||||
};
|
||||
|
||||
TEST(DrmTest, GivenSelectedNotExistingDeviceWhenGetDeviceFdThenFail) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.ForceDeviceId.set("1234");
|
||||
struct DrmTest : public NEO::Drm {
|
||||
using NEO::Drm::getDeviceFd;
|
||||
};
|
||||
VariableBackup<decltype(openFull)> backupOpenFull(&openFull);
|
||||
openFull = testOpen;
|
||||
openRetVal = -1;
|
||||
int fd = DrmTest::getDeviceFd(0);
|
||||
EXPECT_EQ(fd, -1);
|
||||
}
|
||||
|
||||
TEST(DrmTest, GivenSelectedExistingDeviceWhenGetDeviceFdThenReturnFd) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.ForceDeviceId.set("1234");
|
||||
struct DrmTest : public NEO::Drm {
|
||||
using NEO::Drm::getDeviceFd;
|
||||
};
|
||||
VariableBackup<decltype(openFull)> backupOpenFull(&openFull);
|
||||
openRetVal = 1023; // fakeFd
|
||||
openFull = testOpen;
|
||||
int fd = DrmTest::getDeviceFd(0);
|
||||
EXPECT_NE(fd, -1);
|
||||
}
|
||||
|
||||
TEST(DrmTest, GivenSelectedIncorectDeviceWhenGetDeviceFdThenFail) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.ForceDeviceId.set("1234");
|
||||
struct DrmTest : public NEO::Drm {
|
||||
using NEO::Drm::getDeviceFd;
|
||||
};
|
||||
VariableBackup<decltype(openFull)> backupOpenFull(&openFull);
|
||||
VariableBackup<decltype(Drm::pIsi915Version)> backupIsi915Version(&Drm::pIsi915Version);
|
||||
VariableBackup<decltype(Drm::pClose)> backupClose(&Drm::pClose);
|
||||
openFull = testOpen;
|
||||
openRetVal = 1023;
|
||||
Drm::pIsi915Version = [](int x) -> bool { return false; };
|
||||
Drm::pClose = [](int x) -> int { return 0; };
|
||||
|
||||
int fd = DrmTest::getDeviceFd(0);
|
||||
EXPECT_EQ(fd, -1);
|
||||
}
|
||||
|
||||
TEST_F(DrmTests, getReturnsNull) {
|
||||
auto drm = Drm::get(0);
|
||||
EXPECT_EQ(drm, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user