Skip to content

Commit fc0039a

Browse files
committed
Update cts tests.
1 parent 6f0c6f3 commit fc0039a

9 files changed

+140
-18
lines changed

test/conformance/context/urContextCreateWithNativeHandle.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@ TEST_P(urContextCreateWithNativeHandleTest, Success) {
3232
ASSERT_SUCCESS(urContextRelease(ctx));
3333
}
3434

35-
TEST_P(urContextCreateWithNativeHandleTest,
36-
SuccessExplicitUnOwnedNativeHandle) {
35+
TEST_P(urContextCreateWithNativeHandleTest, SuccessWithProperties) {
3736
ur_native_handle_t native_context = 0;
3837
{
3938
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
4039
urContextGetNativeHandle(context, &native_context));
4140
}
4241

4342
ur_context_handle_t ctx = nullptr;
43+
// We can't pass isNativeHandleOwned = true in the generic tests since
44+
// we always get the native handle from a UR object, and transferring
45+
// ownership from one UR object to another isn't allowed.
4446
ur_context_native_properties_t props{
4547
UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES, nullptr, false};
4648
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urContextCreateWithNativeHandle(

test/conformance/device/urDeviceCreateWithNativeHandle.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ TEST_F(urDeviceCreateWithNativeHandleTest, Success) {
2929
}
3030
}
3131

32-
TEST_F(urDeviceCreateWithNativeHandleTest,
33-
SuccessWithExplicitUnOwnedNativeHandle) {
32+
TEST_F(urDeviceCreateWithNativeHandleTest, SuccessWithProperties) {
3433
for (auto device : devices) {
3534
ur_native_handle_t native_handle = 0;
3635
{
@@ -39,6 +38,9 @@ TEST_F(urDeviceCreateWithNativeHandleTest,
3938
}
4039

4140
ur_device_handle_t dev = nullptr;
41+
// We can't pass isNativeHandleOwned = true in the generic tests since
42+
// we always get the native handle from a UR object, and transferring
43+
// ownership from one UR object to another isn't allowed.
4244
ur_device_native_properties_t props{
4345
UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES, nullptr, false};
4446
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urDeviceCreateWithNativeHandle(

test/conformance/event/urEventCreateWithNativeHandle.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,26 @@ TEST_P(urEventCreateWithNativeHandleTest, Success) {
3030
sizeof(ur_execution_info_t), &exec_info,
3131
nullptr));
3232
}
33+
34+
TEST_P(urEventCreateWithNativeHandleTest, SuccessWithProperties) {
35+
ur_native_handle_t native_event = 0;
36+
{
37+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
38+
urEventGetNativeHandle(event, &native_event));
39+
}
40+
41+
uur::raii::Event evt = nullptr;
42+
// We can't pass isNativeHandleOwned = true in the generic tests since
43+
// we always get the native handle from a UR object, and transferring
44+
// ownership from one UR object to another isn't allowed.
45+
ur_event_native_properties_t props = {
46+
UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES, nullptr, false};
47+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urEventCreateWithNativeHandle(
48+
native_event, context, &props, evt.ptr()));
49+
ASSERT_NE(evt, nullptr);
50+
51+
ur_execution_info_t exec_info;
52+
ASSERT_SUCCESS(urEventGetInfo(evt, UR_EVENT_INFO_COMMAND_EXECUTION_STATUS,
53+
sizeof(ur_execution_info_t), &exec_info,
54+
nullptr));
55+
}

test/conformance/kernel/urKernelCreateWithNativeHandle.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ struct urKernelCreateWithNativeHandleTest : uur::urKernelTest {
2323

2424
ur_native_handle_t native_kernel_handle = 0;
2525
ur_kernel_handle_t native_kernel = nullptr;
26+
// We can't pass isNativeHandleOwned = true in the generic tests since
27+
// we always get the native handle from a UR object, and transferring
28+
// ownership from one UR object to another isn't allowed.
2629
ur_kernel_native_properties_t properties = {
2730
UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES, /*sType*/
2831
nullptr, /*pNext*/
@@ -32,6 +35,18 @@ struct urKernelCreateWithNativeHandleTest : uur::urKernelTest {
3235
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelCreateWithNativeHandleTest);
3336

3437
TEST_P(urKernelCreateWithNativeHandleTest, Success) {
38+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urKernelCreateWithNativeHandle(
39+
native_kernel_handle, context, program, nullptr, &native_kernel));
40+
41+
uint32_t ref_count = 0;
42+
ASSERT_SUCCESS(urKernelGetInfo(native_kernel,
43+
UR_KERNEL_INFO_REFERENCE_COUNT,
44+
sizeof(ref_count), &ref_count, nullptr));
45+
46+
ASSERT_NE(ref_count, 0);
47+
}
48+
49+
TEST_P(urKernelCreateWithNativeHandleTest, SuccessWithProperties) {
3550
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urKernelCreateWithNativeHandle(
3651
native_kernel_handle, context, program, &properties, &native_kernel));
3752

test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@ TEST_P(urMemBufferCreateWithNativeHandleTest, Success) {
2020
// We can however convert the native_handle back into a unified-runtime handle
2121
// and perform some query on it to verify that it works.
2222
ur_mem_handle_t mem = nullptr;
23+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
24+
urMemBufferCreateWithNativeHandle(hNativeMem, context, nullptr, &mem));
25+
ASSERT_NE(mem, nullptr);
26+
27+
size_t alloc_size = 0;
28+
ASSERT_SUCCESS(urMemGetInfo(mem, UR_MEM_INFO_SIZE, sizeof(size_t),
29+
&alloc_size, nullptr));
30+
31+
ASSERT_SUCCESS(urMemRelease(mem));
32+
}
33+
34+
TEST_P(urMemBufferCreateWithNativeHandleTest, SuccessWithProperties) {
35+
ur_native_handle_t hNativeMem = 0;
36+
{
37+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
38+
urMemGetNativeHandle(buffer, device, &hNativeMem));
39+
}
40+
41+
ur_mem_handle_t mem = nullptr;
42+
// We can't pass isNativeHandleOwned = true in the generic tests since
43+
// we always get the native handle from a UR object, and transferring
44+
// ownership from one UR object to another isn't allowed.
2345
ur_mem_native_properties_t props = {
2446
/*.stype =*/UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES,
2547
/*.pNext =*/nullptr,

test/conformance/memory/urMemImageCreateWithNativeHandle.cpp

+26-7
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,34 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemImageCreateWithNativeHandleTest);
1010

1111
TEST_P(urMemImageCreateWithNativeHandleTest, Success) {
1212
ur_native_handle_t native_handle = 0;
13-
if (urMemGetNativeHandle(image, device, &native_handle)) {
14-
GTEST_SKIP();
15-
}
13+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
14+
urMemGetNativeHandle(image, device, &native_handle));
1615

1716
ur_mem_handle_t mem = nullptr;
18-
ASSERT_EQ_RESULT(
19-
UR_RESULT_ERROR_INVALID_NULL_HANDLE,
20-
urMemImageCreateWithNativeHandle(native_handle, context, &image_format,
21-
&image_desc, nullptr, &mem));
17+
ASSERT_SUCCESS(urMemImageCreateWithNativeHandle(
18+
native_handle, context, &image_format, &image_desc, nullptr, &mem));
19+
ASSERT_NE(nullptr, mem);
20+
21+
ur_context_handle_t mem_context = nullptr;
22+
ASSERT_SUCCESS(urMemGetInfo(mem, UR_MEM_INFO_CONTEXT,
23+
sizeof(ur_context_handle_t), &mem_context,
24+
nullptr));
25+
ASSERT_EQ(context, mem_context);
26+
}
27+
28+
TEST_P(urMemImageCreateWithNativeHandleTest, SuccessWithProperties) {
29+
ur_native_handle_t native_handle = 0;
30+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
31+
urMemGetNativeHandle(image, device, &native_handle));
32+
33+
ur_mem_handle_t mem = nullptr;
34+
ur_mem_native_properties_t props = {UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES,
35+
nullptr, false};
36+
// We can't pass isNativeHandleOwned = true in the generic tests since
37+
// we always get the native handle from a UR object, and transferring
38+
// ownership from one UR object to another isn't allowed.
39+
ASSERT_SUCCESS(urMemImageCreateWithNativeHandle(
40+
native_handle, context, &image_format, &image_desc, &props, &mem));
2241
ASSERT_NE(nullptr, mem);
2342

2443
ur_context_handle_t mem_context = nullptr;

test/conformance/platform/urPlatformCreateWithNativeHandle.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,17 @@ TEST_F(urPlatformCreateWithNativeHandleTest, Success) {
3030
}
3131
}
3232

33-
TEST_F(urPlatformCreateWithNativeHandleTest,
34-
SuccessWithExplicitUnOwnedNativeHandle) {
33+
TEST_F(urPlatformCreateWithNativeHandleTest, SuccessWithProperties) {
3534
for (auto platform : platforms) {
3635
ur_native_handle_t native_handle = 0;
3736
{
3837
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
3938
urPlatformGetNativeHandle(platform, &native_handle));
4039
}
4140

42-
// We cannot assume anything about a native_handle, not even if it's
43-
// `nullptr` since this could be a valid representation within a backend.
44-
// We can however convert the native_handle back into a unified-runtime
45-
// handle and perform some query on it to verify that it works.
41+
// We can't pass isNativeHandleOwned = true in the generic tests since
42+
// we always get the native handle from a UR object, and transferring
43+
// ownership from one UR object to another isn't allowed.
4644
ur_platform_native_properties_t props = {
4745
UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES, nullptr, false};
4846
ur_platform_handle_t plat = nullptr;

test/conformance/program/urProgramCreateWithNativeHandle.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,24 @@ TEST_P(urProgramCreateWithNativeHandleTest, Success) {
3838
ASSERT_NE(ref_count, 0);
3939
}
4040

41+
TEST_P(urProgramCreateWithNativeHandleTest, SuccessWithProperties) {
42+
// We can't pass isNativeHandleOwned = true in the generic tests since
43+
// we always get the native handle from a UR object, and transferring
44+
// ownership from one UR object to another isn't allowed.
45+
ur_program_native_properties_t props = {
46+
UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES, nullptr, false};
47+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urProgramCreateWithNativeHandle(
48+
native_program_handle, context, &props, &native_program));
49+
50+
uint32_t ref_count = 0;
51+
52+
ASSERT_SUCCESS(urProgramGetInfo(native_program,
53+
UR_PROGRAM_INFO_REFERENCE_COUNT,
54+
sizeof(ref_count), &ref_count, nullptr));
55+
56+
ASSERT_NE(ref_count, 0);
57+
}
58+
4159
TEST_P(urProgramCreateWithNativeHandleTest, InvalidNullHandleContext) {
4260
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
4361
urProgramCreateWithNativeHandle(native_program_handle,

test/conformance/queue/urQueueCreateWithNativeHandle.cpp

+24-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,30 @@ TEST_P(urQueueCreateWithNativeHandleTest, Success) {
1919
// We can however convert the native_handle back into a unified-runtime handle
2020
// and perform some query on it to verify that it works.
2121
ur_queue_handle_t q = nullptr;
22-
ur_queue_native_properties_t properties{};
22+
ASSERT_SUCCESS(urQueueCreateWithNativeHandle(native_handle, context, device,
23+
nullptr, &q));
24+
ASSERT_NE(q, nullptr);
25+
26+
ur_context_handle_t q_context = nullptr;
27+
ASSERT_SUCCESS(urQueueGetInfo(q, UR_QUEUE_INFO_CONTEXT, sizeof(q_context),
28+
&q_context, nullptr));
29+
ASSERT_EQ(q_context, context);
30+
ASSERT_SUCCESS(urQueueRelease(q));
31+
}
32+
33+
TEST_P(urQueueCreateWithNativeHandleTest, SuccessWithProperties) {
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+
// We can't pass isNativeHandleOwned = true in the generic tests since
42+
// we always get the native handle from a UR object, and transferring
43+
// ownership from one UR object to another isn't allowed.
44+
ur_queue_native_properties_t properties = {
45+
UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES, nullptr, false};
2346
ASSERT_SUCCESS(urQueueCreateWithNativeHandle(native_handle, context, device,
2447
&properties, &q));
2548
ASSERT_NE(q, nullptr);

0 commit comments

Comments
 (0)