Skip to content

Commit 76a9623

Browse files
authored
Merge pull request #2409 from aarongreig/aaron/parameterizePlatformTests
Enable platform CTS tests to run on all available platforms.
2 parents 54b3b86 + 52574d8 commit 76a9623

16 files changed

+267
-262
lines changed

test/adapters/cuda/urDeviceCreateWithNativeHandle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include "fixtures.h"
77

8-
using urCudaDeviceCreateWithNativeHandle = uur::urPlatformTest;
8+
using urCudaDeviceCreateWithNativeHandle = uur::urSelectedPlatformTest;
99

1010
TEST_F(urCudaDeviceCreateWithNativeHandle, Success) {
1111
// get a device from cuda

test/conformance/device/urDeviceGet.cpp

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#include <uur/fixtures.h>
77

88
using urDeviceGetTest = uur::urPlatformTest;
9+
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urDeviceGetTest);
910

10-
TEST_F(urDeviceGetTest, Success) {
11+
TEST_P(urDeviceGetTest, Success) {
1112
uint32_t count = 0;
1213
ASSERT_SUCCESS(
1314
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
@@ -20,7 +21,7 @@ TEST_F(urDeviceGetTest, Success) {
2021
}
2122
}
2223

23-
TEST_F(urDeviceGetTest, SuccessSubsetOfDevices) {
24+
TEST_P(urDeviceGetTest, SuccessSubsetOfDevices) {
2425
uint32_t count;
2526
ASSERT_SUCCESS(
2627
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
@@ -35,6 +36,41 @@ TEST_F(urDeviceGetTest, SuccessSubsetOfDevices) {
3536
}
3637
}
3738

39+
TEST_P(urDeviceGetTest, InvalidNullHandlePlatform) {
40+
uint32_t count;
41+
ASSERT_EQ_RESULT(
42+
UR_RESULT_ERROR_INVALID_NULL_HANDLE,
43+
urDeviceGet(nullptr, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
44+
}
45+
46+
TEST_P(urDeviceGetTest, InvalidEnumerationDevicesType) {
47+
uint32_t count;
48+
ASSERT_EQ_RESULT(
49+
UR_RESULT_ERROR_INVALID_ENUMERATION,
50+
urDeviceGet(platform, UR_DEVICE_TYPE_FORCE_UINT32, 0, nullptr, &count));
51+
}
52+
53+
TEST_P(urDeviceGetTest, InvalidSizeNumEntries) {
54+
uint32_t count = 0;
55+
ASSERT_SUCCESS(
56+
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
57+
ASSERT_NE(count, 0);
58+
std::vector<ur_device_handle_t> devices(count);
59+
ASSERT_EQ_RESULT(
60+
UR_RESULT_ERROR_INVALID_SIZE,
61+
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, devices.data(), nullptr));
62+
}
63+
64+
TEST_P(urDeviceGetTest, InvalidNullPointerDevices) {
65+
uint32_t count = 0;
66+
ASSERT_SUCCESS(
67+
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
68+
ASSERT_NE(count, 0);
69+
ASSERT_EQ_RESULT(
70+
UR_RESULT_ERROR_INVALID_NULL_POINTER,
71+
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, count, nullptr, nullptr));
72+
}
73+
3874
struct urDeviceGetTestWithDeviceTypeParam
3975
: uur::urAllDevicesTest,
4076
::testing::WithParamInterface<ur_device_type_t> {
@@ -70,38 +106,3 @@ TEST_P(urDeviceGetTestWithDeviceTypeParam, Success) {
70106
}
71107
}
72108
}
73-
74-
TEST_F(urDeviceGetTest, InvalidNullHandlePlatform) {
75-
uint32_t count;
76-
ASSERT_EQ_RESULT(
77-
UR_RESULT_ERROR_INVALID_NULL_HANDLE,
78-
urDeviceGet(nullptr, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
79-
}
80-
81-
TEST_F(urDeviceGetTest, InvalidEnumerationDevicesType) {
82-
uint32_t count;
83-
ASSERT_EQ_RESULT(
84-
UR_RESULT_ERROR_INVALID_ENUMERATION,
85-
urDeviceGet(platform, UR_DEVICE_TYPE_FORCE_UINT32, 0, nullptr, &count));
86-
}
87-
88-
TEST_F(urDeviceGetTest, InvalidSizeNumEntries) {
89-
uint32_t count = 0;
90-
ASSERT_SUCCESS(
91-
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
92-
ASSERT_NE(count, 0);
93-
std::vector<ur_device_handle_t> devices(count);
94-
ASSERT_EQ_RESULT(
95-
UR_RESULT_ERROR_INVALID_SIZE,
96-
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, devices.data(), nullptr));
97-
}
98-
99-
TEST_F(urDeviceGetTest, InvalidNullPointerDevices) {
100-
uint32_t count = 0;
101-
ASSERT_SUCCESS(
102-
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
103-
ASSERT_NE(count, 0);
104-
ASSERT_EQ_RESULT(
105-
UR_RESULT_ERROR_INVALID_NULL_POINTER,
106-
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, count, nullptr, nullptr));
107-
}

test/conformance/device/urDeviceGetSelected.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
#include <uur/fixtures.h>
88

99
using urDeviceGetSelectedTest = uur::urPlatformTest;
10+
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urDeviceGetSelectedTest);
1011

1112
/* adpater agnostic tests -- none assume the existence or support of any specific adapter */
1213

13-
TEST_F(urDeviceGetSelectedTest, Success) {
14+
TEST_P(urDeviceGetSelectedTest, Success) {
1415
unsetenv("ONEAPI_DEVICE_SELECTOR");
1516
uint32_t count = 0;
1617
ASSERT_SUCCESS(
@@ -24,7 +25,7 @@ TEST_F(urDeviceGetSelectedTest, Success) {
2425
}
2526
}
2627

27-
TEST_F(urDeviceGetSelectedTest, SuccessSubsetOfDevices) {
28+
TEST_P(urDeviceGetSelectedTest, SuccessSubsetOfDevices) {
2829
unsetenv("ONEAPI_DEVICE_SELECTOR");
2930
uint32_t count = 0;
3031
ASSERT_SUCCESS(
@@ -41,7 +42,7 @@ TEST_F(urDeviceGetSelectedTest, SuccessSubsetOfDevices) {
4142
}
4243
}
4344

44-
TEST_F(urDeviceGetSelectedTest, SuccessSelected_StarColonStar) {
45+
TEST_P(urDeviceGetSelectedTest, SuccessSelected_StarColonStar) {
4546
setenv("ONEAPI_DEVICE_SELECTOR", "*:*", 1);
4647
uint32_t count = 0;
4748
ASSERT_SUCCESS(
@@ -71,7 +72,7 @@ TEST_F(urDeviceGetSelectedTest, SuccessSelected_StarColonStar) {
7172
}
7273
}
7374

74-
TEST_F(urDeviceGetSelectedTest, SuccessSelected_StarColonZero) {
75+
TEST_P(urDeviceGetSelectedTest, SuccessSelected_StarColonZero) {
7576
setenv("ONEAPI_DEVICE_SELECTOR", "*:0", 1);
7677
uint32_t count = 0;
7778
ASSERT_SUCCESS(
@@ -85,7 +86,7 @@ TEST_F(urDeviceGetSelectedTest, SuccessSelected_StarColonZero) {
8586
}
8687
}
8788

88-
TEST_F(urDeviceGetSelectedTest, SuccessSelected_StarColonZeroCommaStar) {
89+
TEST_P(urDeviceGetSelectedTest, SuccessSelected_StarColonZeroCommaStar) {
8990
setenv("ONEAPI_DEVICE_SELECTOR", "*:0,*", 1);
9091
uint32_t count = 0;
9192
ASSERT_SUCCESS(
@@ -99,23 +100,23 @@ TEST_F(urDeviceGetSelectedTest, SuccessSelected_StarColonZeroCommaStar) {
99100
}
100101
}
101102

102-
TEST_F(urDeviceGetSelectedTest, SuccessSelected_DiscardStarColonStar) {
103+
TEST_P(urDeviceGetSelectedTest, SuccessSelected_DiscardStarColonStar) {
103104
setenv("ONEAPI_DEVICE_SELECTOR", "!*:*", 1);
104105
uint32_t count = 0;
105106
ASSERT_SUCCESS(
106107
urDeviceGetSelected(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
107108
ASSERT_EQ(count, 0);
108109
}
109110

110-
TEST_F(urDeviceGetSelectedTest, SuccessSelected_SelectAndDiscard) {
111+
TEST_P(urDeviceGetSelectedTest, SuccessSelected_SelectAndDiscard) {
111112
setenv("ONEAPI_DEVICE_SELECTOR", "*:0;!*:*", 1);
112113
uint32_t count = 0;
113114
ASSERT_SUCCESS(
114115
urDeviceGetSelected(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
115116
ASSERT_EQ(count, 0);
116117
}
117118

118-
TEST_F(urDeviceGetSelectedTest,
119+
TEST_P(urDeviceGetSelectedTest,
119120
SuccessSelected_SelectSomethingAndDiscardSomethingElse) {
120121
setenv("ONEAPI_DEVICE_SELECTOR", "*:0;!*:1", 1);
121122
uint32_t count = 0;
@@ -130,23 +131,23 @@ TEST_F(urDeviceGetSelectedTest,
130131
}
131132
}
132133

133-
TEST_F(urDeviceGetSelectedTest, InvalidNullHandlePlatform) {
134+
TEST_P(urDeviceGetSelectedTest, InvalidNullHandlePlatform) {
134135
unsetenv("ONEAPI_DEVICE_SELECTOR");
135136
uint32_t count = 0;
136137
ASSERT_EQ_RESULT(
137138
UR_RESULT_ERROR_INVALID_NULL_HANDLE,
138139
urDeviceGetSelected(nullptr, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
139140
}
140141

141-
TEST_F(urDeviceGetSelectedTest, InvalidEnumerationDevicesType) {
142+
TEST_P(urDeviceGetSelectedTest, InvalidEnumerationDevicesType) {
142143
unsetenv("ONEAPI_DEVICE_SELECTOR");
143144
uint32_t count = 0;
144145
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION,
145146
urDeviceGetSelected(platform, UR_DEVICE_TYPE_FORCE_UINT32,
146147
0, nullptr, &count));
147148
}
148149

149-
TEST_F(urDeviceGetSelectedTest, InvalidValueNumEntries) {
150+
TEST_P(urDeviceGetSelectedTest, InvalidValueNumEntries) {
150151
unsetenv("ONEAPI_DEVICE_SELECTOR");
151152
uint32_t count = 0;
152153
ASSERT_SUCCESS(
@@ -158,7 +159,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidValueNumEntries) {
158159
devices.data(), nullptr));
159160
}
160161

161-
TEST_F(urDeviceGetSelectedTest, InvalidMissingBackend) {
162+
TEST_P(urDeviceGetSelectedTest, InvalidMissingBackend) {
162163
setenv("ONEAPI_DEVICE_SELECTOR", ":garbage", 1);
163164
uint32_t count = 0;
164165
ASSERT_EQ_RESULT(
@@ -167,7 +168,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidMissingBackend) {
167168
ASSERT_EQ(count, 0);
168169
}
169170

170-
TEST_F(urDeviceGetSelectedTest, InvalidGarbageBackendString) {
171+
TEST_P(urDeviceGetSelectedTest, InvalidGarbageBackendString) {
171172
setenv("ONEAPI_DEVICE_SELECTOR", "garbage:0", 1);
172173
uint32_t count = 0;
173174
ASSERT_EQ_RESULT(
@@ -176,7 +177,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidGarbageBackendString) {
176177
ASSERT_EQ(count, 0);
177178
}
178179

179-
TEST_F(urDeviceGetSelectedTest, InvalidMissingFilterStrings) {
180+
TEST_P(urDeviceGetSelectedTest, InvalidMissingFilterStrings) {
180181
setenv("ONEAPI_DEVICE_SELECTOR", "*", 1);
181182
uint32_t count = 0;
182183
ASSERT_EQ_RESULT(
@@ -191,7 +192,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidMissingFilterStrings) {
191192
ASSERT_EQ(count2, 0);
192193
}
193194

194-
TEST_F(urDeviceGetSelectedTest, InvalidMissingFilterString) {
195+
TEST_P(urDeviceGetSelectedTest, InvalidMissingFilterString) {
195196
setenv("ONEAPI_DEVICE_SELECTOR", "*:0,,2", 1);
196197
uint32_t count = 0;
197198
ASSERT_EQ_RESULT(
@@ -200,7 +201,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidMissingFilterString) {
200201
ASSERT_EQ(count, 0);
201202
}
202203

203-
TEST_F(urDeviceGetSelectedTest, InvalidTooManyDotsInFilterString) {
204+
TEST_P(urDeviceGetSelectedTest, InvalidTooManyDotsInFilterString) {
204205
setenv("ONEAPI_DEVICE_SELECTOR", "*:0.1.2.3", 1);
205206
uint32_t count = 0;
206207
ASSERT_EQ_RESULT(
@@ -209,7 +210,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidTooManyDotsInFilterString) {
209210
ASSERT_EQ(count, 0);
210211
}
211212

212-
TEST_F(urDeviceGetSelectedTest, InvalidBadWildardInFilterString) {
213+
TEST_P(urDeviceGetSelectedTest, InvalidBadWildardInFilterString) {
213214
setenv("ONEAPI_DEVICE_SELECTOR", "*:*.", 1);
214215
uint32_t count = 0;
215216
ASSERT_EQ_RESULT(
@@ -224,23 +225,23 @@ TEST_F(urDeviceGetSelectedTest, InvalidBadWildardInFilterString) {
224225
ASSERT_EQ(count2, 0);
225226
}
226227

227-
TEST_F(urDeviceGetSelectedTest, InvalidSelectingNonexistentDevice) {
228+
TEST_P(urDeviceGetSelectedTest, InvalidSelectingNonexistentDevice) {
228229
setenv("ONEAPI_DEVICE_SELECTOR", "*:4321", 1);
229230
uint32_t count = 0;
230231
ASSERT_SUCCESS(
231232
urDeviceGetSelected(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
232233
ASSERT_EQ(count, 0);
233234
}
234235

235-
TEST_F(urDeviceGetSelectedTest, InvalidSelectingNonexistentSubDevice) {
236+
TEST_P(urDeviceGetSelectedTest, InvalidSelectingNonexistentSubDevice) {
236237
setenv("ONEAPI_DEVICE_SELECTOR", "*:0.4321", 1);
237238
uint32_t count = 0;
238239
ASSERT_SUCCESS(
239240
urDeviceGetSelected(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
240241
ASSERT_EQ(count, 0);
241242
}
242243

243-
TEST_F(urDeviceGetSelectedTest, InvalidSelectingNonexistentSubSubDevice) {
244+
TEST_P(urDeviceGetSelectedTest, InvalidSelectingNonexistentSubSubDevice) {
244245
setenv("ONEAPI_DEVICE_SELECTOR", "*:0.0.4321", 1);
245246
uint32_t count = 0;
246247
ASSERT_SUCCESS(

test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ struct urMultiDeviceContextMemBufferTest : urMultiDeviceContextTest {
148148
std::vector<ur_kernel_handle_t> kernels;
149149
std::vector<ur_program_metadata_t> metadatas{};
150150
};
151+
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urMultiDeviceContextMemBufferTest);
151152

152-
TEST_F(urMultiDeviceContextMemBufferTest, WriteRead) {
153+
TEST_P(urMultiDeviceContextMemBufferTest, WriteRead) {
153154
if (num_devices == 1) {
154155
GTEST_SKIP();
155156
}
@@ -173,7 +174,7 @@ TEST_F(urMultiDeviceContextMemBufferTest, WriteRead) {
173174
}
174175
}
175176

176-
TEST_F(urMultiDeviceContextMemBufferTest, FillRead) {
177+
TEST_P(urMultiDeviceContextMemBufferTest, FillRead) {
177178
if (num_devices == 1) {
178179
GTEST_SKIP();
179180
}
@@ -197,7 +198,7 @@ TEST_F(urMultiDeviceContextMemBufferTest, FillRead) {
197198
}
198199
}
199200

200-
TEST_F(urMultiDeviceContextMemBufferTest, WriteKernelRead) {
201+
TEST_P(urMultiDeviceContextMemBufferTest, WriteKernelRead) {
201202
if (num_devices == 1) {
202203
GTEST_SKIP();
203204
}
@@ -233,7 +234,7 @@ TEST_F(urMultiDeviceContextMemBufferTest, WriteKernelRead) {
233234
}
234235
}
235236

236-
TEST_F(urMultiDeviceContextMemBufferTest, WriteKernelKernelRead) {
237+
TEST_P(urMultiDeviceContextMemBufferTest, WriteKernelKernelRead) {
237238
if (num_devices == 1) {
238239
GTEST_SKIP();
239240
}

test/conformance/platform/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# See LICENSE.TXT
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6-
add_conformance_test(platform
6+
add_conformance_test_with_platform_environment(platform
77
urPlatformCreateWithNativeHandle.cpp
88
urPlatformGet.cpp
99
urPlatformGetApiVersion.cpp

0 commit comments

Comments
 (0)