|
4 | 4 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
5 | 5 | #include <uur/fixtures.h> |
6 | 6 |
|
7 | | -using urDeviceCreateWithNativeHandleTest = uur::urAllDevicesTest; |
| 7 | +using urDeviceCreateWithNativeHandleTest = uur::urDeviceTest; |
| 8 | +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urDeviceCreateWithNativeHandleTest); |
8 | 9 |
|
9 | | -TEST_F(urDeviceCreateWithNativeHandleTest, Success) { |
10 | | - for (auto device : devices) { |
11 | | - ur_native_handle_t native_handle = 0; |
| 10 | +TEST_P(urDeviceCreateWithNativeHandleTest, Success) { |
| 11 | + ur_native_handle_t native_handle = 0; |
12 | 12 |
|
13 | | - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( |
14 | | - urDeviceGetNativeHandle(device, &native_handle)); |
| 13 | + UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( |
| 14 | + urDeviceGetNativeHandle(device, &native_handle)); |
15 | 15 |
|
16 | | - // We cannot assume anything about a native_handle, not even if it's |
17 | | - // `nullptr` since this could be a valid representation within a backend. |
18 | | - // We can however convert the native_handle back into a unified-runtime handle |
19 | | - // and perform some query on it to verify that it works. |
20 | | - ur_device_handle_t dev = nullptr; |
21 | | - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urDeviceCreateWithNativeHandle( |
22 | | - native_handle, adapter, nullptr, &dev)); |
23 | | - ASSERT_NE(dev, nullptr); |
| 16 | + // We cannot assume anything about a native_handle, not even if it's |
| 17 | + // `nullptr` since this could be a valid representation within a backend. |
| 18 | + // We can however convert the native_handle back into a unified-runtime handle |
| 19 | + // and perform some query on it to verify that it works. |
| 20 | + ur_device_handle_t dev = nullptr; |
| 21 | + UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( |
| 22 | + urDeviceCreateWithNativeHandle(native_handle, adapter, nullptr, &dev)); |
| 23 | + ASSERT_NE(dev, nullptr); |
24 | 24 |
|
25 | | - uint32_t dev_id = 0; |
26 | | - ASSERT_SUCCESS(urDeviceGetInfo(dev, UR_DEVICE_INFO_TYPE, |
27 | | - sizeof(uint32_t), &dev_id, nullptr)); |
28 | | - } |
| 25 | + uint32_t dev_id = 0; |
| 26 | + ASSERT_SUCCESS(urDeviceGetInfo(dev, UR_DEVICE_INFO_TYPE, sizeof(uint32_t), |
| 27 | + &dev_id, nullptr)); |
29 | 28 | } |
30 | 29 |
|
31 | | -TEST_F(urDeviceCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) { |
32 | | - for (auto device : devices) { |
33 | | - ur_native_handle_t native_handle = 0; |
| 30 | +TEST_P(urDeviceCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) { |
| 31 | + ur_native_handle_t native_handle = 0; |
34 | 32 |
|
35 | | - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( |
36 | | - urDeviceGetNativeHandle(device, &native_handle)); |
| 33 | + UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( |
| 34 | + urDeviceGetNativeHandle(device, &native_handle)); |
37 | 35 |
|
38 | | - ur_device_handle_t dev = nullptr; |
39 | | - ur_device_native_properties_t props{ |
40 | | - UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES, nullptr, true}; |
41 | | - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urDeviceCreateWithNativeHandle( |
42 | | - native_handle, adapter, &props, &dev)); |
43 | | - ASSERT_NE(dev, nullptr); |
44 | | - } |
| 36 | + ur_device_handle_t dev = nullptr; |
| 37 | + ur_device_native_properties_t props{ |
| 38 | + UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES, nullptr, true}; |
| 39 | + UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( |
| 40 | + urDeviceCreateWithNativeHandle(native_handle, adapter, &props, &dev)); |
| 41 | + ASSERT_NE(dev, nullptr); |
45 | 42 | } |
46 | 43 |
|
47 | | -TEST_F(urDeviceCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) { |
48 | | - for (auto device : devices) { |
49 | | - ur_native_handle_t native_handle = 0; |
| 44 | +TEST_P(urDeviceCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) { |
| 45 | + ur_native_handle_t native_handle = 0; |
50 | 46 |
|
51 | | - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( |
52 | | - urDeviceGetNativeHandle(device, &native_handle)); |
| 47 | + UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( |
| 48 | + urDeviceGetNativeHandle(device, &native_handle)); |
53 | 49 |
|
54 | | - ur_device_handle_t dev = nullptr; |
55 | | - ur_device_native_properties_t props{ |
56 | | - UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES, nullptr, false}; |
57 | | - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urDeviceCreateWithNativeHandle( |
58 | | - native_handle, adapter, &props, &dev)); |
59 | | - ASSERT_NE(dev, nullptr); |
60 | | - } |
| 50 | + ur_device_handle_t dev = nullptr; |
| 51 | + ur_device_native_properties_t props{ |
| 52 | + UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES, nullptr, false}; |
| 53 | + UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( |
| 54 | + urDeviceCreateWithNativeHandle(native_handle, adapter, &props, &dev)); |
| 55 | + ASSERT_NE(dev, nullptr); |
61 | 56 | } |
62 | 57 |
|
63 | | -TEST_F(urDeviceCreateWithNativeHandleTest, InvalidNullHandlePlatform) { |
64 | | - for (auto device : devices) { |
65 | | - ur_native_handle_t native_handle = 0; |
66 | | - ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle)); |
| 58 | +TEST_P(urDeviceCreateWithNativeHandleTest, InvalidNullHandlePlatform) { |
| 59 | + ur_native_handle_t native_handle = 0; |
| 60 | + ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle)); |
67 | 61 |
|
68 | | - ur_device_handle_t dev = nullptr; |
69 | | - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, |
70 | | - urDeviceCreateWithNativeHandle(native_handle, nullptr, |
71 | | - nullptr, &dev)); |
72 | | - } |
| 62 | + ur_device_handle_t dev = nullptr; |
| 63 | + ASSERT_EQ_RESULT( |
| 64 | + UR_RESULT_ERROR_INVALID_NULL_HANDLE, |
| 65 | + urDeviceCreateWithNativeHandle(native_handle, nullptr, nullptr, &dev)); |
73 | 66 | } |
74 | 67 |
|
75 | | -TEST_F(urDeviceCreateWithNativeHandleTest, InvalidNullPointerDevice) { |
76 | | - for (auto device : devices) { |
77 | | - ur_native_handle_t native_handle = 0; |
78 | | - ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle)); |
| 68 | +TEST_P(urDeviceCreateWithNativeHandleTest, InvalidNullPointerDevice) { |
| 69 | + ur_native_handle_t native_handle = 0; |
| 70 | + ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle)); |
79 | 71 |
|
80 | | - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, |
81 | | - urDeviceCreateWithNativeHandle(native_handle, adapter, |
82 | | - nullptr, nullptr)); |
83 | | - } |
| 72 | + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, |
| 73 | + urDeviceCreateWithNativeHandle(native_handle, adapter, |
| 74 | + nullptr, nullptr)); |
84 | 75 | } |
0 commit comments