Skip to content

Commit 40579f9

Browse files
committed
Improvements to align CTS and Spec for Event.
* Added test case for urEventGetProfilingInfo return UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE * Added test case for urEventCreateWithNativeHandle return UR_RESULT_ERROR_INVALID_NULL_HANDLE * Added test case for urEventCreateWithNativeHandle return UR_RESULT_ERROR_INVALID_NULL_POINTER * Added test case for urEventSetCallback return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
1 parent be058f4 commit 40579f9

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

test/conformance/event/urEventCreateWithNativeHandle.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,35 @@ TEST_P(urEventCreateWithNativeHandleTest, SuccessWithProperties) {
5656
sizeof(ur_execution_info_t), &exec_info,
5757
nullptr));
5858
}
59+
60+
TEST_P(urEventCreateWithNativeHandleTest, InvalidNullHandle) {
61+
ur_native_handle_t native_event = 0;
62+
63+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
64+
urEventGetNativeHandle(event, &native_event));
65+
66+
// We cannot assume anything about a native_handle, not even if it's
67+
// `nullptr` since this could be a valid representation within a backend.
68+
// We can however convert the native_handle back into a unified-runtime handle
69+
// and perform some query on it to verify that it works.
70+
uur::raii::Event evt = nullptr;
71+
ASSERT_EQ_RESULT(
72+
urEventCreateWithNativeHandle(native_event, nullptr, nullptr, evt.ptr()),
73+
UR_RESULT_ERROR_INVALID_NULL_HANDLE);
74+
}
75+
76+
TEST_P(urEventCreateWithNativeHandleTest, InvalidNullPointer) {
77+
ur_native_handle_t native_event = 0;
78+
79+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
80+
urEventGetNativeHandle(event, &native_event));
81+
82+
// We cannot assume anything about a native_handle, not even if it's
83+
// `nullptr` since this could be a valid representation within a backend.
84+
// We can however convert the native_handle back into a unified-runtime handle
85+
// and perform some query on it to verify that it works.
86+
uur::raii::Event evt = nullptr;
87+
ASSERT_EQ_RESULT(
88+
urEventCreateWithNativeHandle(native_event, context, nullptr, nullptr),
89+
UR_RESULT_ERROR_INVALID_NULL_POINTER);
90+
}

test/conformance/event/urEventGetProfilingInfo.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,41 @@ TEST_P(urEventGetProfilingInfoForWaitWithBarrier, Success) {
215215

216216
ASSERT_GE(complete_value, submit_value);
217217
}
218+
219+
struct urEventGetProfilingInfoInvalidQueue : uur::urQueueTest {
220+
void SetUp() override {
221+
UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::SetUp());
222+
ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_WRITE_ONLY, size,
223+
nullptr, &buffer));
224+
225+
input.assign(count, 42);
226+
ASSERT_SUCCESS(urEnqueueMemBufferWrite(queue, buffer, false, 0, size,
227+
input.data(), 0, nullptr, &event));
228+
ASSERT_SUCCESS(urEventWait(1, &event));
229+
}
230+
231+
void TearDown() override {
232+
if (buffer) {
233+
EXPECT_SUCCESS(urMemRelease(buffer));
234+
}
235+
UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::TearDown());
236+
};
237+
238+
const size_t count = 1024;
239+
const size_t size = sizeof(uint32_t) * count;
240+
ur_mem_handle_t buffer = nullptr;
241+
ur_event_handle_t event = nullptr;
242+
std::vector<uint32_t> input;
243+
};
244+
245+
UUR_INSTANTIATE_DEVICE_TEST_SUITE(urEventGetProfilingInfoInvalidQueue);
246+
247+
TEST_P(urEventGetProfilingInfoInvalidQueue, ProfilingInfoNotAvailable) {
248+
UUR_KNOWN_FAILURE_ON(uur::NativeCPU{});
249+
250+
const ur_profiling_info_t property_name = UR_PROFILING_INFO_COMMAND_QUEUED;
251+
size_t property_size;
252+
ASSERT_EQ_RESULT(
253+
urEventGetProfilingInfo(event, property_name, 0, nullptr, &property_size),
254+
UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE);
255+
}

test/conformance/event/urEventSetCallback.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,11 @@ TEST_P(urEventSetCallbackNegativeTest, InvalidEnumeration) {
189189
UR_RESULT_ERROR_INVALID_ENUMERATION);
190190
}
191191

192+
TEST_P(urEventSetCallbackNegativeTest, UnsupportedEnumeration) {
193+
ASSERT_EQ_RESULT(
194+
urEventSetCallback(event, ur_execution_info_t::UR_EXECUTION_INFO_QUEUED,
195+
emptyCallback, nullptr),
196+
UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION);
197+
}
198+
192199
UUR_INSTANTIATE_DEVICE_TEST_SUITE(urEventSetCallbackNegativeTest);

0 commit comments

Comments
 (0)