Skip to content

Commit ca9ae22

Browse files
Merge pull request #1500 from omarahmed1111/Add-more-coverage-to-CTS-tests
Add more coverage to CTS tests in various areas
2 parents e31ecae + 6e8b89b commit ca9ae22

29 files changed

+294
-43
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
urContextCreateWithNativeHandleTest.Success/NVIDIA_CUDA_BACKEND___{{.*}}_
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
urContextCreateWithNativeHandleTest.Success/AMD_HIP_BACKEND___{{.*}}_
2+
urContextCreateWithNativeHandleTest.SuccessWithOwnedNativeHandle/AMD_HIP_BACKEND___{{.*}}_
3+
urContextCreateWithNativeHandleTest.SuccessWithUnOwnedNativeHandle/AMD_HIP_BACKEND___{{.*}}_
24
urContextGetInfoTestWithInfoParam.Success/AMD_HIP_BACKEND___{{.*}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
urContextCreateWithNativeHandleTest.SuccessWithUnOwnedNativeHandle/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
12
urContextSetExtendedDeleterTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
urContextCreateWithNativeHandleTest.InvalidNullPointerDevices/SYCL_NATIVE_CPU___SYCL_Native_CPU_
2+
urContextCreateWithNativeHandleTest.InvalidNullPointerContext/SYCL_NATIVE_CPU___SYCL_Native_CPU_
13
urContextSetExtendedDeleterTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU_

test/conformance/context/urContextCreateWithNativeHandle.cpp

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urContextCreateWithNativeHandleTest);
1010

1111
TEST_P(urContextCreateWithNativeHandleTest, Success) {
1212
ur_native_handle_t native_context = nullptr;
13-
if (urContextGetNativeHandle(context, &native_context)) {
14-
GTEST_SKIP();
13+
{
14+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
15+
urContextGetNativeHandle(context, &native_context));
1516
}
1617

1718
// We cannot assume anything about a native_handle, not even if it's
@@ -20,8 +21,8 @@ TEST_P(urContextCreateWithNativeHandleTest, Success) {
2021
// and perform some query on it to verify that it works.
2122
ur_context_handle_t ctx = nullptr;
2223
ur_context_native_properties_t props{};
23-
ASSERT_SUCCESS(urContextCreateWithNativeHandle(native_context, 1, &device,
24-
&props, &ctx));
24+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urContextCreateWithNativeHandle(
25+
native_context, 1, &device, &props, &ctx));
2526
ASSERT_NE(ctx, nullptr);
2627

2728
uint32_t n_devices = 0;
@@ -30,3 +31,64 @@ TEST_P(urContextCreateWithNativeHandleTest, Success) {
3031

3132
ASSERT_SUCCESS(urContextRelease(ctx));
3233
}
34+
35+
TEST_P(urContextCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
36+
ur_native_handle_t native_context = nullptr;
37+
{
38+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
39+
urContextGetNativeHandle(context, &native_context));
40+
}
41+
42+
ur_context_handle_t ctx = nullptr;
43+
ur_context_native_properties_t props{
44+
UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES, nullptr, true};
45+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urContextCreateWithNativeHandle(
46+
native_context, 1, &device, &props, &ctx));
47+
ASSERT_NE(ctx, nullptr);
48+
49+
uint32_t ref_count = 0;
50+
ASSERT_SUCCESS(urContextGetInfo(ctx, UR_CONTEXT_INFO_REFERENCE_COUNT,
51+
sizeof(uint32_t), &ref_count, nullptr));
52+
ASSERT_EQ(ref_count, 1);
53+
}
54+
55+
TEST_P(urContextCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) {
56+
ur_native_handle_t native_context = nullptr;
57+
{
58+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
59+
urContextGetNativeHandle(context, &native_context));
60+
}
61+
62+
ur_context_handle_t ctx = nullptr;
63+
ur_context_native_properties_t props{
64+
UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES, nullptr, false};
65+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urContextCreateWithNativeHandle(
66+
native_context, 1, &device, &props, &ctx));
67+
ASSERT_NE(ctx, nullptr);
68+
69+
uint32_t ref_count = 0;
70+
ASSERT_SUCCESS(urContextGetInfo(ctx, UR_CONTEXT_INFO_REFERENCE_COUNT,
71+
sizeof(uint32_t), &ref_count, nullptr));
72+
ASSERT_EQ(ref_count, 2);
73+
74+
ASSERT_SUCCESS(urContextRelease(ctx));
75+
}
76+
77+
TEST_P(urContextCreateWithNativeHandleTest, InvalidNullPointerDevices) {
78+
ur_native_handle_t native_context = nullptr;
79+
ASSERT_SUCCESS(urContextGetNativeHandle(context, &native_context));
80+
81+
ur_context_handle_t ctx = nullptr;
82+
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
83+
urContextCreateWithNativeHandle(native_context, 1, nullptr,
84+
nullptr, &ctx));
85+
}
86+
87+
TEST_P(urContextCreateWithNativeHandleTest, InvalidNullPointerContext) {
88+
ur_native_handle_t native_context = nullptr;
89+
ASSERT_SUCCESS(urContextGetNativeHandle(context, &native_context));
90+
91+
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
92+
urContextCreateWithNativeHandle(native_context, 1, &device,
93+
nullptr, nullptr));
94+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
urDeviceCreateWithNativeHandleTest.SuccessWithUnOwnedNativeHandle
12
{{OPT}}urDeviceGetGlobalTimestampTest.SuccessSynchronizedTime
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
{{OPT}}urDeviceCreateWithNativeHandleTest.Success
2+
{{OPT}}urDeviceCreateWithNativeHandleTest.SuccessWithOwnedNativeHandle
3+
{{OPT}}urDeviceCreateWithNativeHandleTest.SuccessWithUnOwnedNativeHandle
24
{{OPT}}urDeviceGetGlobalTimestampTest.SuccessSynchronizedTime

test/conformance/device/device_adapter_level_zero.match

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
urDeviceCreateWithNativeHandleTest.SuccessWithUnOwnedNativeHandle
12
urDeviceGetInfoTest.Success/UR_DEVICE_INFO_GLOBAL_MEM_FREE
23
urDeviceGetInfoTest.Success/UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT
34
urDeviceGetInfoTest.Success/UR_DEVICE_INFO_HOST_UNIFIED_MEMORY

test/conformance/device/device_adapter_native_cpu.match

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
urDeviceCreateWithNativeHandleTest.InvalidNullHandlePlatform
2+
urDeviceCreateWithNativeHandleTest.InvalidNullPointerDevice
13
{{OPT}}urDeviceGetGlobalTimestampTest.SuccessSynchronizedTime
24
{{OPT}}urDeviceSelectBinaryTest.Success
35
urDeviceGetInfoTest.Success/UR_DEVICE_INFO_DEVICE_ID
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
urDeviceCreateWithNativeHandleTest.SuccessWithUnOwnedNativeHandle

0 commit comments

Comments
 (0)