Skip to content

Commit 80c359c

Browse files
committed
Improvements to align CTS and Spec for Queue:
- Add UR_RESULT_ERROR_INVALID_NULL_HANDLE/POINTER for urQueueCreateWithNativeHandleTest - Add tests for urQueueCreateWithNativeHandleTest for creating an owned/unowned native queue handle - Removed urQueueGetInfoDeviceQueueTestWithInfoParam as it was redundant - already being checked with urQueueGetInfoTestWithInfoParam - Added missing enum queries for urQueueGetInfoTestWithInfoParam
1 parent e3247c2 commit 80c359c

File tree

2 files changed

+73
-29
lines changed

2 files changed

+73
-29
lines changed

test/conformance/queue/urQueueCreateWithNativeHandle.cpp

+55
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,58 @@ TEST_P(urQueueCreateWithNativeHandleTest, Success) {
2929
ASSERT_EQ(q_context, context);
3030
ASSERT_SUCCESS(urQueueRelease(q));
3131
}
32+
33+
TEST_P(urQueueCreateWithNativeHandleTest, InvalidNullHandle) {
34+
ur_native_handle_t native_handle = 0;
35+
{
36+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
37+
urQueueGetNativeHandle(queue, nullptr, &native_handle));
38+
}
39+
40+
ur_queue_handle_t q = nullptr;
41+
ASSERT_EQ(urQueueCreateWithNativeHandle(native_handle, nullptr, device,
42+
nullptr, &q),
43+
UR_RESULT_ERROR_INVALID_NULL_HANDLE);
44+
}
45+
46+
TEST_P(urQueueCreateWithNativeHandleTest, InvalidNullPointer) {
47+
ur_native_handle_t native_handle = 0;
48+
{
49+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
50+
urQueueGetNativeHandle(queue, nullptr, &native_handle));
51+
}
52+
53+
ASSERT_EQ(urQueueCreateWithNativeHandle(native_handle, context, device,
54+
nullptr, nullptr),
55+
UR_RESULT_ERROR_INVALID_NULL_POINTER);
56+
}
57+
58+
TEST_P(urQueueCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
59+
ur_native_handle_t native_handle = 0;
60+
{
61+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
62+
urQueueGetNativeHandle(queue, nullptr, &native_handle));
63+
}
64+
65+
ur_queue_handle_t q = nullptr;
66+
ur_queue_native_properties_t properties{
67+
UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES, nullptr, true};
68+
ASSERT_SUCCESS(urQueueCreateWithNativeHandle(native_handle, context, device,
69+
&properties, &q));
70+
ASSERT_NE(q, nullptr);
71+
}
72+
73+
TEST_P(urQueueCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) {
74+
ur_native_handle_t native_handle = 0;
75+
{
76+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
77+
urQueueGetNativeHandle(queue, nullptr, &native_handle));
78+
}
79+
80+
ur_queue_handle_t q = nullptr;
81+
ur_queue_native_properties_t properties{
82+
UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES, nullptr, false};
83+
ASSERT_SUCCESS(urQueueCreateWithNativeHandle(native_handle, context, device,
84+
&properties, &q));
85+
ASSERT_NE(q, nullptr);
86+
}

test/conformance/queue/urQueueGetInfo.cpp

+18-29
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,30 @@ TEST_P(urQueueGetInfoTestWithInfoParam, Success) {
5555
ASSERT_EQ(*returned_device, device);
5656
break;
5757
}
58+
case UR_QUEUE_INFO_DEVICE_DEFAULT: {
59+
auto returned_default_queue =
60+
reinterpret_cast<ur_queue_handle_t *>(data.data());
61+
ASSERT_EQ(*returned_default_queue, queue);
62+
break;
63+
}
64+
case UR_QUEUE_INFO_FLAGS: {
65+
auto returned_flags =
66+
reinterpret_cast<ur_queue_flags_t *>(data.data());
67+
EXPECT_EQ(*returned_flags, *returned_flags & UR_QUEUE_FLAGS_MASK);
68+
break;
69+
}
5870
case UR_QUEUE_INFO_REFERENCE_COUNT: {
5971
auto returned_reference_count =
6072
reinterpret_cast<uint32_t *>(data.data());
6173
ASSERT_GT(*returned_reference_count, 0U);
6274
break;
6375
}
76+
case UR_QUEUE_INFO_EMPTY: {
77+
auto returned_empty_queue =
78+
reinterpret_cast<ur_bool_t *>(data.data());
79+
ASSERT_TRUE(returned_empty_queue);
80+
break;
81+
}
6482
default:
6583
break;
6684
}
@@ -99,35 +117,6 @@ struct urQueueGetInfoDeviceQueueTestWithInfoParam
99117
UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE};
100118
};
101119

102-
UUR_TEST_SUITE_P(urQueueGetInfoDeviceQueueTestWithInfoParam,
103-
::testing::Values(UR_QUEUE_INFO_CONTEXT, UR_QUEUE_INFO_DEVICE,
104-
UR_QUEUE_INFO_DEVICE_DEFAULT,
105-
UR_QUEUE_INFO_FLAGS,
106-
UR_QUEUE_INFO_REFERENCE_COUNT,
107-
UR_QUEUE_INFO_SIZE, UR_QUEUE_INFO_EMPTY),
108-
uur::deviceTestWithParamPrinter<ur_queue_info_t>);
109-
110-
TEST_P(urQueueGetInfoDeviceQueueTestWithInfoParam, Success) {
111-
ur_queue_info_t info_type = getParam();
112-
size_t size = 0;
113-
auto result = urQueueGetInfo(queue, info_type, 0, nullptr, &size);
114-
115-
if (result == UR_RESULT_SUCCESS) {
116-
ASSERT_NE(size, 0);
117-
118-
if (const auto expected_size = queue_info_size_map.find(info_type);
119-
expected_size != queue_info_size_map.end()) {
120-
ASSERT_EQ(expected_size->second, size);
121-
}
122-
123-
std::vector<uint8_t> data(size);
124-
ASSERT_SUCCESS(
125-
urQueueGetInfo(queue, info_type, size, data.data(), nullptr));
126-
} else {
127-
ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION);
128-
}
129-
}
130-
131120
using urQueueGetInfoTest = uur::urQueueTest;
132121
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueGetInfoTest);
133122

0 commit comments

Comments
 (0)