Skip to content

Commit 7e03dfe

Browse files
committed
Update MemBufferCreate with unsupported checks
Functions in this test are optional, so the test should allow them to return "not supported".
1 parent 3f96aa2 commit 7e03dfe

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@ using urMemBufferCreateWithNativeHandleTest = uur::urMemBufferTest;
1111
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemBufferCreateWithNativeHandleTest);
1212

1313
TEST_P(urMemBufferCreateWithNativeHandleTest, Success) {
14-
UUR_KNOWN_FAILURE_ON(uur::CUDA{}, uur::LevelZeroV2{}, uur::HIP{},
15-
uur::NativeCPU{});
16-
1714
ur_native_handle_t hNativeMem = 0;
18-
ASSERT_SUCCESS(urMemGetNativeHandle(buffer, device, &hNativeMem));
15+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
16+
urMemGetNativeHandle(buffer, device, &hNativeMem));
1917

2018
// We cannot assume anything about a native_handle, not even if it's
2119
// `nullptr` since this could be a valid representation within a backend.
2220
// We can however convert the native_handle back into a unified-runtime handle
2321
// and perform some query on it to verify that it works.
2422
ur_mem_handle_t mem = nullptr;
25-
ASSERT_SUCCESS(
23+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
2624
urMemBufferCreateWithNativeHandle(hNativeMem, context, nullptr, &mem));
2725
ASSERT_NE(mem, nullptr);
2826

@@ -34,20 +32,18 @@ TEST_P(urMemBufferCreateWithNativeHandleTest, Success) {
3432
}
3533

3634
TEST_P(urMemBufferCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
37-
UUR_KNOWN_FAILURE_ON(uur::CUDA{}, uur::LevelZeroV2{}, uur::HIP{},
38-
uur::NativeCPU{});
39-
4035
ur_native_handle_t native_handle = 0;
41-
ASSERT_SUCCESS(urMemGetNativeHandle(buffer, device, &native_handle));
36+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
37+
urMemGetNativeHandle(buffer, device, &native_handle));
4238

4339
ur_mem_handle_t mem = nullptr;
4440
ur_mem_native_properties_t props = {
4541
/*.stype =*/UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES,
4642
/*.pNext =*/nullptr,
4743
/*.isNativeHandleOwned =*/true,
4844
};
49-
ASSERT_SUCCESS(urMemBufferCreateWithNativeHandle(native_handle, context,
50-
&props, &mem));
45+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urMemBufferCreateWithNativeHandle(
46+
native_handle, context, &props, &mem));
5147
ASSERT_NE(nullptr, mem);
5248

5349
ur_context_handle_t mem_context = nullptr;
@@ -58,20 +54,18 @@ TEST_P(urMemBufferCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
5854
}
5955

6056
TEST_P(urMemBufferCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) {
61-
UUR_KNOWN_FAILURE_ON(uur::CUDA{}, uur::LevelZeroV2{}, uur::HIP{},
62-
uur::NativeCPU{});
63-
6457
ur_native_handle_t native_handle = 0;
65-
ASSERT_SUCCESS(urMemGetNativeHandle(buffer, device, &native_handle));
58+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
59+
urMemGetNativeHandle(buffer, device, &native_handle));
6660

6761
ur_mem_handle_t mem = nullptr;
6862
ur_mem_native_properties_t props = {
6963
/*.stype =*/UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES,
7064
/*.pNext =*/nullptr,
7165
/*.isNativeHandleOwned =*/false,
7266
};
73-
ASSERT_SUCCESS(urMemBufferCreateWithNativeHandle(native_handle, context,
74-
&props, &mem));
67+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urMemBufferCreateWithNativeHandle(
68+
native_handle, context, &props, &mem));
7569
ASSERT_NE(nullptr, mem);
7670

7771
ur_context_handle_t mem_context = nullptr;
@@ -82,36 +76,36 @@ TEST_P(urMemBufferCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) {
8276
}
8377

8478
TEST_P(urMemBufferCreateWithNativeHandleTest, InvalidNullHandle) {
85-
UUR_KNOWN_FAILURE_ON(uur::LevelZeroV2{}, uur::NativeCPU{});
86-
8779
ur_native_handle_t hNativeMem = 0;
88-
ASSERT_SUCCESS(urMemGetNativeHandle(buffer, device, &hNativeMem));
80+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
81+
urMemGetNativeHandle(buffer, device, &hNativeMem));
8982

9083
ur_mem_handle_t mem = nullptr;
9184
ur_mem_native_properties_t props = {
9285
/*.stype =*/UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES,
9386
/*.pNext =*/nullptr,
9487
/*.isNativeHandleOwned =*/false,
9588
};
96-
ASSERT_EQ(
97-
urMemBufferCreateWithNativeHandle(hNativeMem, nullptr, &props, &mem),
98-
UR_RESULT_ERROR_INVALID_NULL_HANDLE);
89+
auto err =
90+
urMemBufferCreateWithNativeHandle(hNativeMem, nullptr, &props, &mem);
91+
ASSERT_TRUE(err == UR_RESULT_ERROR_INVALID_NULL_HANDLE ||
92+
err == UR_RESULT_ERROR_UNSUPPORTED_FEATURE);
9993
}
10094

10195
TEST_P(urMemBufferCreateWithNativeHandleTest, InvalidNullPointer) {
102-
UUR_KNOWN_FAILURE_ON(uur::LevelZeroV2{}, uur::NativeCPU{});
103-
10496
ur_native_handle_t hNativeMem = 0;
105-
ASSERT_SUCCESS(urMemGetNativeHandle(buffer, device, &hNativeMem));
97+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
98+
urMemGetNativeHandle(buffer, device, &hNativeMem));
10699

107100
ur_mem_native_properties_t props = {
108101
/*.stype =*/UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES,
109102
/*.pNext =*/nullptr,
110103
/*.isNativeHandleOwned =*/false,
111104
};
112-
ASSERT_EQ(
113-
urMemBufferCreateWithNativeHandle(hNativeMem, context, &props, nullptr),
114-
UR_RESULT_ERROR_INVALID_NULL_POINTER);
105+
auto err =
106+
urMemBufferCreateWithNativeHandle(hNativeMem, context, &props, nullptr);
107+
ASSERT_TRUE(err == UR_RESULT_ERROR_INVALID_NULL_POINTER ||
108+
err == UR_RESULT_ERROR_UNSUPPORTED_FEATURE);
115109
}
116110

117111
using urMemBufferMultiQueueMemBufferTest = uur::urMultiDeviceMemBufferQueueTest;

0 commit comments

Comments
 (0)