@@ -10,15 +10,34 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemImageCreateWithNativeHandleTest);
10
10
11
11
TEST_P (urMemImageCreateWithNativeHandleTest, Success) {
12
12
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));
16
15
17
16
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));
22
41
ASSERT_NE (nullptr , mem);
23
42
24
43
ur_context_handle_t mem_context = nullptr ;
0 commit comments