Skip to content

Commit f9f71f1

Browse files
authored
Merge pull request #2320 from RossBrunton/ross/machygene
[NFC] Make macro in conf. test no longer leak
2 parents ca69634 + abb5d12 commit f9f71f1

File tree

8 files changed

+53
-67
lines changed

8 files changed

+53
-67
lines changed

test/conformance/context/urContextCreateWithNativeHandle.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urContextCreateWithNativeHandleTest);
1111

1212
TEST_P(urContextCreateWithNativeHandleTest, Success) {
1313
ur_native_handle_t native_context = 0;
14-
{
15-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
16-
urContextGetNativeHandle(context, &native_context));
17-
}
14+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
15+
urContextGetNativeHandle(context, &native_context));
1816

1917
// We cannot assume anything about a native_handle, not even if it's
2018
// `nullptr` since this could be a valid representation within a backend.
@@ -35,10 +33,9 @@ TEST_P(urContextCreateWithNativeHandleTest, Success) {
3533

3634
TEST_P(urContextCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
3735
ur_native_handle_t native_context = 0;
38-
{
39-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
40-
urContextGetNativeHandle(context, &native_context));
41-
}
36+
37+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
38+
urContextGetNativeHandle(context, &native_context));
4239

4340
ur_context_handle_t ctx = nullptr;
4441
ur_context_native_properties_t props{
@@ -50,10 +47,9 @@ TEST_P(urContextCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
5047

5148
TEST_P(urContextCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) {
5249
ur_native_handle_t native_context = 0;
53-
{
54-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
55-
urContextGetNativeHandle(context, &native_context));
56-
}
50+
51+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
52+
urContextGetNativeHandle(context, &native_context));
5753

5854
ur_context_handle_t ctx = nullptr;
5955
ur_context_native_properties_t props{

test/conformance/device/urDeviceCreateWithNativeHandle.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ using urDeviceCreateWithNativeHandleTest = uur::urAllDevicesTest;
99
TEST_F(urDeviceCreateWithNativeHandleTest, Success) {
1010
for (auto device : devices) {
1111
ur_native_handle_t native_handle = 0;
12-
{
13-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
14-
urDeviceGetNativeHandle(device, &native_handle));
15-
}
12+
13+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
14+
urDeviceGetNativeHandle(device, &native_handle));
1615

1716
// We cannot assume anything about a native_handle, not even if it's
1817
// `nullptr` since this could be a valid representation within a backend.
@@ -32,10 +31,9 @@ TEST_F(urDeviceCreateWithNativeHandleTest, Success) {
3231
TEST_F(urDeviceCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
3332
for (auto device : devices) {
3433
ur_native_handle_t native_handle = 0;
35-
{
36-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
37-
urDeviceGetNativeHandle(device, &native_handle));
38-
}
34+
35+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
36+
urDeviceGetNativeHandle(device, &native_handle));
3937

4038
ur_device_handle_t dev = nullptr;
4139
ur_device_native_properties_t props{
@@ -49,10 +47,9 @@ TEST_F(urDeviceCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
4947
TEST_F(urDeviceCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) {
5048
for (auto device : devices) {
5149
ur_native_handle_t native_handle = 0;
52-
{
53-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
54-
urDeviceGetNativeHandle(device, &native_handle));
55-
}
50+
51+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
52+
urDeviceGetNativeHandle(device, &native_handle));
5653

5754
ur_device_handle_t dev = nullptr;
5855
ur_device_native_properties_t props{

test/conformance/event/urEventCreateWithNativeHandle.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEventCreateWithNativeHandleTest);
1111

1212
TEST_P(urEventCreateWithNativeHandleTest, Success) {
1313
ur_native_handle_t native_event = 0;
14-
{
15-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
16-
urEventGetNativeHandle(event, &native_event));
17-
}
14+
15+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
16+
urEventGetNativeHandle(event, &native_event));
1817

1918
// We cannot assume anything about a native_handle, not even if it's
2019
// `nullptr` since this could be a valid representation within a backend.

test/conformance/kernel/urKernelCreateWithNativeHandle.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
struct urKernelCreateWithNativeHandleTest : uur::urKernelTest {
99
void SetUp() override {
1010
UUR_RETURN_ON_FATAL_FAILURE(urKernelTest::SetUp());
11-
{
12-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
13-
urKernelGetNativeHandle(kernel, &native_kernel_handle));
14-
}
11+
12+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
13+
urKernelGetNativeHandle(kernel, &native_kernel_handle));
1514
}
1615

1716
void TearDown() override {

test/conformance/platform/urPlatformCreateWithNativeHandle.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ using urPlatformCreateWithNativeHandleTest = uur::platform::urPlatformTest;
1010
TEST_F(urPlatformCreateWithNativeHandleTest, Success) {
1111
for (auto platform : platforms) {
1212
ur_native_handle_t native_handle = 0;
13-
{
14-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
15-
urPlatformGetNativeHandle(platform, &native_handle));
16-
}
13+
14+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
15+
urPlatformGetNativeHandle(platform, &native_handle));
1716

1817
// We cannot assume anything about a native_handle, not even if it's
1918
// `nullptr` since this could be a valid representation within a backend.
@@ -33,10 +32,9 @@ TEST_F(urPlatformCreateWithNativeHandleTest, Success) {
3332
TEST_F(urPlatformCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
3433
for (auto platform : platforms) {
3534
ur_native_handle_t native_handle = 0;
36-
{
37-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
38-
urPlatformGetNativeHandle(platform, &native_handle));
39-
}
35+
36+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
37+
urPlatformGetNativeHandle(platform, &native_handle));
4038

4139
// We cannot assume anything about a native_handle, not even if it's
4240
// `nullptr` since this could be a valid representation within a backend.
@@ -58,10 +56,9 @@ TEST_F(urPlatformCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
5856
TEST_F(urPlatformCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) {
5957
for (auto platform : platforms) {
6058
ur_native_handle_t native_handle = 0;
61-
{
62-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
63-
urPlatformGetNativeHandle(platform, &native_handle));
64-
}
59+
60+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
61+
urPlatformGetNativeHandle(platform, &native_handle));
6562

6663
// We cannot assume anything about a native_handle, not even if it's
6764
// `nullptr` since this could be a valid representation within a backend.

test/conformance/queue/urQueueCreateWithNativeHandle.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueCreateWithNativeHandleTest);
99

1010
TEST_P(urQueueCreateWithNativeHandleTest, Success) {
1111
ur_native_handle_t native_handle = 0;
12-
{
13-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
14-
urQueueGetNativeHandle(queue, nullptr, &native_handle));
15-
}
12+
13+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
14+
urQueueGetNativeHandle(queue, nullptr, &native_handle));
1615

1716
// We cannot assume anything about a native_handle, not even if it's
1817
// `nullptr` since this could be a valid representation within a backend.

test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urSamplerCreateWithNativeHandleTest);
1212

1313
TEST_P(urSamplerCreateWithNativeHandleTest, Success) {
1414
ur_native_handle_t native_sampler = 0;
15-
{
16-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
17-
urSamplerGetNativeHandle(sampler, &native_sampler));
18-
}
15+
16+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
17+
urSamplerGetNativeHandle(sampler, &native_sampler));
1918

2019
// We cannot assume anything about a native_handle, not even if it's
2120
// `nullptr` since this could be a valid representation within a backend.
@@ -36,10 +35,9 @@ TEST_P(urSamplerCreateWithNativeHandleTest, Success) {
3635

3736
TEST_P(urSamplerCreateWithNativeHandleTest, InvalidNullHandle) {
3837
ur_native_handle_t native_sampler = 0;
39-
{
40-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
41-
urSamplerGetNativeHandle(sampler, &native_sampler));
42-
}
38+
39+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
40+
urSamplerGetNativeHandle(sampler, &native_sampler));
4341

4442
ur_sampler_handle_t hSampler = nullptr;
4543
ur_sampler_native_properties_t props{};
@@ -50,10 +48,9 @@ TEST_P(urSamplerCreateWithNativeHandleTest, InvalidNullHandle) {
5048

5149
TEST_P(urSamplerCreateWithNativeHandleTest, InvalidNullPointer) {
5250
ur_native_handle_t native_sampler = 0;
53-
{
54-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
55-
urSamplerGetNativeHandle(sampler, &native_sampler));
56-
}
51+
52+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
53+
urSamplerGetNativeHandle(sampler, &native_sampler));
5754

5855
ur_sampler_native_properties_t props{};
5956
ASSERT_EQ(urSamplerCreateWithNativeHandle(native_sampler, context, &props,

test/conformance/testing/include/uur/fixtures.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
(void)0
2424

2525
#define UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(ret) \
26-
auto status = ret; \
27-
if (status == UR_RESULT_ERROR_UNSUPPORTED_FEATURE || \
28-
status == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) { \
29-
GTEST_SKIP(); \
30-
} else { \
31-
ASSERT_EQ(status, UR_RESULT_SUCCESS); \
32-
}
26+
do { \
27+
auto status = ret; \
28+
if (status == UR_RESULT_ERROR_UNSUPPORTED_FEATURE || \
29+
status == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) { \
30+
GTEST_SKIP(); \
31+
} else { \
32+
ASSERT_EQ(status, UR_RESULT_SUCCESS); \
33+
} \
34+
} while (0)
3335

3436
namespace uur {
3537

0 commit comments

Comments
 (0)