Skip to content

Commit 976df78

Browse files
committed
Initial attempt at parameterizing the cts over all available devices.
1 parent f4c384d commit 976df78

File tree

76 files changed

+917
-928
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+917
-928
lines changed

test/adapters/level_zero/event_cache_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ TEST_P(urEventCacheTest, eventsReuseWithVisibleEventAndWait) {
167167
template <typename T>
168168
inline std::string
169169
printFlags(const testing::TestParamInfo<typename T::ParamType> &info) {
170-
const auto device_handle = std::get<0>(info.param);
170+
const auto device_handle = std::get<0>(info.param).device;
171171
const auto platform_device_name =
172172
uur::GetPlatformAndDeviceName(device_handle);
173173
auto flags = combineFlags(std::get<1>(info.param));
@@ -181,7 +181,7 @@ printFlags(const testing::TestParamInfo<typename T::ParamType> &info) {
181181
return platform_device_name + "__" + str;
182182
}
183183

184-
UUR_TEST_SUITE_P(
184+
UUR_DEVICE_TEST_SUITE_P(
185185
urEventCacheTest,
186186
::testing::Combine(
187187
testing::Values(0, UR_QUEUE_FLAG_DISCARD_EVENTS),

test/conformance/context/urContextCreate.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,11 @@ TEST_P(urContextCreateTest, InvalidNullPointerDevices) {
3131
}
3232

3333
TEST_P(urContextCreateTest, InvalidNullPointerContext) {
34-
auto device = GetParam();
3534
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
3635
urContextCreate(1, &device, nullptr, nullptr));
3736
}
3837

3938
TEST_P(urContextCreateTest, InvalidEnumeration) {
40-
auto device = GetParam();
41-
4239
ur_context_properties_t properties{UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES,
4340
nullptr, UR_CONTEXT_FLAGS_MASK};
4441
uur::raii::Context context = nullptr;
@@ -48,7 +45,9 @@ TEST_P(urContextCreateTest, InvalidEnumeration) {
4845
}
4946

5047
using urContextCreateMultiDeviceTest = uur::urAllDevicesTest;
51-
TEST_F(urContextCreateMultiDeviceTest, Success) {
48+
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urContextCreateMultiDeviceTest);
49+
50+
TEST_P(urContextCreateMultiDeviceTest, Success) {
5251
if (devices.size() < 2) {
5352
GTEST_SKIP();
5453
}

test/conformance/context/urContextCreateWithNativeHandle.cpp

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

6-
#include "uur/environment.h"
76
#include <uur/fixtures.h>
87

98
using urContextCreateWithNativeHandleTest = uur::urContextTest;

test/conformance/context/urContextGetInfo.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ TEST_P(urContextGetInfoTest, SuccessNumDevices) {
1818
ASSERT_SUCCESS(
1919
urContextGetInfo(context, info_type, size, &nDevices, nullptr));
2020

21-
ASSERT_GE(uur::DevicesEnvironment::instance->devices.size(), nDevices);
21+
ASSERT_EQ(nDevices, 1);
2222
}
2323

2424
TEST_P(urContextGetInfoTest, SuccessDevices) {
@@ -28,12 +28,13 @@ TEST_P(urContextGetInfoTest, SuccessDevices) {
2828
ASSERT_SUCCESS(urContextGetInfo(context, info_type, 0, nullptr, &size));
2929
ASSERT_NE(size, 0);
3030

31-
ur_device_handle_t devices = 0;
31+
ur_device_handle_t queried_device = nullptr;
3232
ASSERT_SUCCESS(
33-
urContextGetInfo(context, info_type, size, &devices, nullptr));
33+
urContextGetInfo(context, info_type, size, &queried_device, nullptr));
3434

3535
size_t devices_count = size / sizeof(ur_device_handle_t);
36-
ASSERT_GT(devices_count, 0);
36+
ASSERT_EQ(devices_count, 1);
37+
ASSERT_EQ(queried_device, device);
3738

3839
for (uint32_t i = 0; i < devices_count; i++) {
3940
auto &devices = uur::DevicesEnvironment::instance->devices;

test/conformance/device/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_with_platform_environment(device
6+
add_conformance_test_with_devices_environment(device
77
urDeviceCreateWithNativeHandle.cpp
88
urDeviceGet.cpp
99
urDeviceGetGlobalTimestamps.cpp

test/conformance/device/urDeviceCreateWithNativeHandle.cpp

Lines changed: 50 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,81 +4,72 @@
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
#include <uur/fixtures.h>
66

7-
using urDeviceCreateWithNativeHandleTest = uur::urAllDevicesTest;
7+
using urDeviceCreateWithNativeHandleTest = uur::urDeviceTest;
8+
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urDeviceCreateWithNativeHandleTest);
89

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;
1212

13-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
14-
urDeviceGetNativeHandle(device, &native_handle));
13+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
14+
urDeviceGetNativeHandle(device, &native_handle));
1515

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);
2424

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));
2928
}
3029

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;
3432

35-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
36-
urDeviceGetNativeHandle(device, &native_handle));
33+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
34+
urDeviceGetNativeHandle(device, &native_handle));
3735

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);
4542
}
4643

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;
5046

51-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
52-
urDeviceGetNativeHandle(device, &native_handle));
47+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
48+
urDeviceGetNativeHandle(device, &native_handle));
5349

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);
6156
}
6257

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));
6761

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));
7366
}
7467

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));
7971

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));
8475
}

test/conformance/device/urDeviceGet.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,31 +71,20 @@ TEST_P(urDeviceGetTest, InvalidNullPointerDevices) {
7171
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, count, nullptr, nullptr));
7272
}
7373

74-
struct urDeviceGetTestWithDeviceTypeParam
75-
: uur::urAllDevicesTest,
76-
::testing::WithParamInterface<ur_device_type_t> {
74+
using urDeviceGetTestWithDeviceTypeParam =
75+
uur::urPlatformTestWithParam<ur_device_type_t>;
7776

78-
void SetUp() override {
79-
UUR_RETURN_ON_FATAL_FAILURE(uur::urAllDevicesTest::SetUp());
80-
}
81-
};
82-
83-
INSTANTIATE_TEST_SUITE_P(
84-
, urDeviceGetTestWithDeviceTypeParam,
77+
UUR_PLATFORM_TEST_SUITE_P(
78+
urDeviceGetTestWithDeviceTypeParam,
8579
::testing::Values(UR_DEVICE_TYPE_DEFAULT, UR_DEVICE_TYPE_GPU,
8680
UR_DEVICE_TYPE_CPU, UR_DEVICE_TYPE_FPGA,
8781
UR_DEVICE_TYPE_MCA, UR_DEVICE_TYPE_VPU),
88-
[](const ::testing::TestParamInfo<ur_device_type_t> &info) {
89-
std::stringstream ss;
90-
ss << info.param;
91-
return ss.str();
92-
});
82+
uur::platformTestWithParamPrinter<ur_device_type_t>);
9383

9484
TEST_P(urDeviceGetTestWithDeviceTypeParam, Success) {
95-
ur_device_type_t device_type = GetParam();
85+
ur_device_type_t device_type = getParam();
9686
uint32_t count = 0;
9787
ASSERT_SUCCESS(urDeviceGet(platform, device_type, 0, nullptr, &count));
98-
ASSERT_GE(devices.size(), count);
9988

10089
if (count > 0) {
10190
std::vector<ur_device_handle_t> devices(count);

0 commit comments

Comments
 (0)