Skip to content

Commit 5fb6e13

Browse files
committed
[Offload] Skip most liboffload testts if no devices
If there are no devices available for testing on liboffload, the test will no longer throw an error when it fails to instantiate. The tests will be silently skipped, but with a warning printed to stderr.
1 parent 04518e7 commit 5fb6e13

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

offload/unittests/OffloadAPI/common/Environment.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ const std::vector<TestEnvironment::Device> &TestEnvironment::getDevices() {
129129
}
130130
}
131131

132+
if (Devices.size() <= 1)
133+
errs() << "Warning: No devices found for OffloadAPI tests.\n";
134+
132135
return Devices;
133136
}
134137

offload/unittests/OffloadAPI/common/Fixtures.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,13 @@ struct OffloadEventTest : OffloadQueueTest {
250250
ol_event_handle_t Event = nullptr;
251251
};
252252

253+
// Devices might not be available for offload testing, so allow uninstantiated
254+
// tests (as the device list will be empty). This means that all tests requiring
255+
// a device will be silently skipped.
253256
#define OFFLOAD_TESTS_INSTANTIATE_DEVICE_FIXTURE(FIXTURE) \
254257
INSTANTIATE_TEST_SUITE_P( \
255258
, FIXTURE, ::testing::ValuesIn(TestEnvironment::getDevices()), \
256259
[](const ::testing::TestParamInfo<TestEnvironment::Device> &info) { \
257260
return SanitizeString(info.param.Name); \
258-
})
261+
}); \
262+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(FIXTURE)

0 commit comments

Comments
 (0)