-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Offload] Skip most liboffload tests if no devices #157417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
|
@llvm/pr-subscribers-offload Author: Ross Brunton (RossBrunton) ChangesIf there are no devices available for testing on liboffload, the test The tests will be silently skipped, but with a warning printed to Full diff: https://github.com/llvm/llvm-project/pull/157417.diff 2 Files Affected:
diff --git a/offload/unittests/OffloadAPI/common/Environment.cpp b/offload/unittests/OffloadAPI/common/Environment.cpp
index 80077138b8cc8..024094aec2e49 100644
--- a/offload/unittests/OffloadAPI/common/Environment.cpp
+++ b/offload/unittests/OffloadAPI/common/Environment.cpp
@@ -129,6 +129,9 @@ const std::vector<TestEnvironment::Device> &TestEnvironment::getDevices() {
}
}
+ if (Devices.size() <= 1)
+ errs() << "Warning: No devices found for OffloadAPI tests.\n";
+
return Devices;
}
diff --git a/offload/unittests/OffloadAPI/common/Fixtures.hpp b/offload/unittests/OffloadAPI/common/Fixtures.hpp
index 0538e60f276e3..c5a35faba7a27 100644
--- a/offload/unittests/OffloadAPI/common/Fixtures.hpp
+++ b/offload/unittests/OffloadAPI/common/Fixtures.hpp
@@ -250,9 +250,13 @@ struct OffloadEventTest : OffloadQueueTest {
ol_event_handle_t Event = nullptr;
};
+// Devices might not be available for offload testing, so allow uninstantiated
+// tests (as the device list will be empty). This means that all tests requiring
+// a device will be silently skipped.
#define OFFLOAD_TESTS_INSTANTIATE_DEVICE_FIXTURE(FIXTURE) \
INSTANTIATE_TEST_SUITE_P( \
, FIXTURE, ::testing::ValuesIn(TestEnvironment::getDevices()), \
[](const ::testing::TestParamInfo<TestEnvironment::Device> &info) { \
return SanitizeString(info.param.Name); \
- })
+ }); \
+ GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(FIXTURE)
|
mgorny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this. It's a bit verbose, but as long as the tests pass, I'm happy with it. Just one small comment.
mgorny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, still works for me, so I guess it's good for the GPU case as well.
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.