Skip to content

Commit

Permalink
Improvements to align CTS and Spec for Event.
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
isaacault committed Feb 10, 2025
1 parent 95e03b4 commit a4c673d
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/conformance/event/urEventCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,35 @@ TEST_P(urEventCreateWithNativeHandleTest, SuccessWithProperties) {
sizeof(ur_execution_info_t), &exec_info,
nullptr));
}

TEST_P(urEventCreateWithNativeHandleTest, InvalidNullHandle) {
ur_native_handle_t native_event = 0;

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urEventGetNativeHandle(event, &native_event));

// We cannot assume anything about a native_handle, not even if it's
// `nullptr` since this could be a valid representation within a backend.
// We can however convert the native_handle back into a unified-runtime handle
// and perform some query on it to verify that it works.
uur::raii::Event evt = nullptr;
ASSERT_EQ_RESULT(
urEventCreateWithNativeHandle(native_event, nullptr, nullptr, evt.ptr()),
UR_RESULT_ERROR_INVALID_NULL_HANDLE);
}

TEST_P(urEventCreateWithNativeHandleTest, InvalidNullPointer) {
ur_native_handle_t native_event = 0;

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urEventGetNativeHandle(event, &native_event));

// We cannot assume anything about a native_handle, not even if it's
// `nullptr` since this could be a valid representation within a backend.
// We can however convert the native_handle back into a unified-runtime handle
// and perform some query on it to verify that it works.
uur::raii::Event evt = nullptr;
ASSERT_EQ_RESULT(
urEventCreateWithNativeHandle(native_event, context, nullptr, nullptr),
UR_RESULT_ERROR_INVALID_NULL_POINTER);
}
36 changes: 36 additions & 0 deletions test/conformance/event/urEventGetProfilingInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,39 @@ TEST_P(urEventGetProfilingInfoForWaitWithBarrier, Success) {

ASSERT_GE(complete_value, submit_value);
}

struct urEventGetProfilingInfoInvalidQueue : uur::urQueueTest {
void SetUp() override {
UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::SetUp());
ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_WRITE_ONLY, size,
nullptr, &buffer));

input.assign(count, 42);
ASSERT_SUCCESS(urEnqueueMemBufferWrite(queue, buffer, false, 0, size,
input.data(), 0, nullptr, &event));
ASSERT_SUCCESS(urEventWait(1, &event));
}

void TearDown() override {
if (buffer) {
EXPECT_SUCCESS(urMemRelease(buffer));
}
UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::TearDown());
};

const size_t count = 1024;
const size_t size = sizeof(uint32_t) * count;
ur_mem_handle_t buffer = nullptr;
ur_event_handle_t event = nullptr;
std::vector<uint32_t> input;
};

UUR_INSTANTIATE_DEVICE_TEST_SUITE(urEventGetProfilingInfoInvalidQueue);

TEST_P(urEventGetProfilingInfoInvalidQueue, ProfilingInfoNotAvailable) {
const ur_profiling_info_t property_name = UR_PROFILING_INFO_COMMAND_QUEUED;
size_t property_size;
ASSERT_EQ_RESULT(
urEventGetProfilingInfo(event, property_name, 0, nullptr, &property_size),
UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE);
}
7 changes: 7 additions & 0 deletions test/conformance/event/urEventSetCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,11 @@ TEST_P(urEventSetCallbackNegativeTest, InvalidEnumeration) {
UR_RESULT_ERROR_INVALID_ENUMERATION);
}

TEST_P(urEventSetCallbackNegativeTest, UnsupportedEnumeration) {
ASSERT_EQ_RESULT(
urEventSetCallback(event, ur_execution_info_t::UR_EXECUTION_INFO_QUEUED,
emptyCallback, nullptr),
UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION);
}

UUR_INSTANTIATE_DEVICE_TEST_SUITE(urEventSetCallbackNegativeTest);

0 comments on commit a4c673d

Please sign in to comment.