Skip to content

Commit 54a2173

Browse files
committed
[L0] Add workaround in test for segfault on older drivers
1 parent 606f269 commit 54a2173

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

test/adapters/level_zero/event_cache_tests.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ extern std::map<std::string, int> *ZeCallCount;
1919
using FlagsTupleType = std::tuple<ur_queue_flags_t, ur_queue_flags_t,
2020
ur_queue_flags_t, ur_queue_flags_t>;
2121

22+
// TODO: get rid of this, this is a workaround for fails on older driver
23+
// where for some reason continuing the test leads to a segfault
24+
#define UUR_ASSERT_SUCCESS_OR_EXIT_IF_UNSUPPORTED(ret) \
25+
auto status = ret; \
26+
if (status == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { \
27+
exit(0); \
28+
} else { \
29+
ASSERT_EQ(status, UR_RESULT_SUCCESS); \
30+
}
31+
2232
struct urEventCacheTest : uur::urContextTestWithParam<FlagsTupleType> {
2333
void SetUp() override {
2434
UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp());
@@ -42,20 +52,20 @@ struct urEventCacheTest : uur::urContextTestWithParam<FlagsTupleType> {
4252
EXPECT_SUCCESS(urMemRelease(buffer));
4353
}
4454
if (queue) {
45-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urQueueRelease(queue));
55+
UUR_ASSERT_SUCCESS_OR_EXIT_IF_UNSUPPORTED(urQueueRelease(queue));
4656
}
4757
UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::TearDown());
4858
}
4959

5060
auto enqueueWork(ur_event_handle_t *hEvent, int data) {
5161
input.assign(count, data);
52-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urEnqueueMemBufferWrite(
62+
UUR_ASSERT_SUCCESS_OR_EXIT_IF_UNSUPPORTED(urEnqueueMemBufferWrite(
5363
queue, buffer, false, 0, size, input.data(), 0, nullptr, hEvent));
5464
}
5565

5666
void verifyData() {
5767
std::vector<uint32_t> output(count, 1);
58-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urEnqueueMemBufferRead(
68+
UUR_ASSERT_SUCCESS_OR_EXIT_IF_UNSUPPORTED(urEnqueueMemBufferRead(
5969
queue, buffer, true, 0, size, output.data(), 0, nullptr, nullptr));
6070

6171
if (!(flags & UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE)) {
@@ -79,7 +89,7 @@ TEST_P(urEventCacheTest, eventsReuseNoVisibleEvent) {
7989
for (int j = 0; j < numEnqueues; j++) {
8090
enqueueWork(nullptr, i * numEnqueues + j);
8191
}
82-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urQueueFinish(queue));
92+
UUR_ASSERT_SUCCESS_OR_EXIT_IF_UNSUPPORTED(urQueueFinish(queue));
8393
verifyData();
8494
}
8595

@@ -101,7 +111,7 @@ TEST_P(urEventCacheTest, eventsReuseWithVisibleEvent) {
101111
for (int j = 0; j < numEnqueues; j++) {
102112
enqueueWork(events[j].ptr(), i * numEnqueues + j);
103113
}
104-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urQueueFinish(queue));
114+
UUR_ASSERT_SUCCESS_OR_EXIT_IF_UNSUPPORTED(urQueueFinish(queue));
105115
verifyData();
106116
}
107117

@@ -126,7 +136,7 @@ TEST_P(urEventCacheTest, eventsReuseWithVisibleEventAndWait) {
126136
events.clear();
127137
}
128138
}
129-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urQueueFinish(queue));
139+
UUR_ASSERT_SUCCESS_OR_EXIT_IF_UNSUPPORTED(urQueueFinish(queue));
130140
}
131141

132142
ASSERT_GE((*ZeCallCount)["zeEventCreate"], waitEveryN);

0 commit comments

Comments
 (0)