Skip to content

Commit

Permalink
Merge pull request #2320 from RossBrunton/ross/machygene
Browse files Browse the repository at this point in the history
[NFC] Make macro in conf. test no longer leak
  • Loading branch information
RossBrunton authored Nov 14, 2024
2 parents ca69634 + abb5d12 commit f9f71f1
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 67 deletions.
20 changes: 8 additions & 12 deletions test/conformance/context/urContextCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urContextCreateWithNativeHandleTest);

TEST_P(urContextCreateWithNativeHandleTest, Success) {
ur_native_handle_t native_context = 0;
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urContextGetNativeHandle(context, &native_context));
}
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urContextGetNativeHandle(context, &native_context));

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

TEST_P(urContextCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
ur_native_handle_t native_context = 0;
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urContextGetNativeHandle(context, &native_context));
}

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urContextGetNativeHandle(context, &native_context));

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

TEST_P(urContextCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) {
ur_native_handle_t native_context = 0;
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urContextGetNativeHandle(context, &native_context));
}

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urContextGetNativeHandle(context, &native_context));

ur_context_handle_t ctx = nullptr;
ur_context_native_properties_t props{
Expand Down
21 changes: 9 additions & 12 deletions test/conformance/device/urDeviceCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ using urDeviceCreateWithNativeHandleTest = uur::urAllDevicesTest;
TEST_F(urDeviceCreateWithNativeHandleTest, Success) {
for (auto device : devices) {
ur_native_handle_t native_handle = 0;
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urDeviceGetNativeHandle(device, &native_handle));
}

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urDeviceGetNativeHandle(device, &native_handle));

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

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urDeviceGetNativeHandle(device, &native_handle));

ur_device_handle_t dev = nullptr;
ur_device_native_properties_t props{
Expand All @@ -49,10 +47,9 @@ TEST_F(urDeviceCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
TEST_F(urDeviceCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) {
for (auto device : devices) {
ur_native_handle_t native_handle = 0;
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urDeviceGetNativeHandle(device, &native_handle));
}

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urDeviceGetNativeHandle(device, &native_handle));

ur_device_handle_t dev = nullptr;
ur_device_native_properties_t props{
Expand Down
7 changes: 3 additions & 4 deletions test/conformance/event/urEventCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEventCreateWithNativeHandleTest);

TEST_P(urEventCreateWithNativeHandleTest, Success) {
ur_native_handle_t native_event = 0;
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urEventGetNativeHandle(event, &native_event));
}

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urEventGetNativeHandle(event, &native_event));

// We cannot assume anything about a native_handle, not even if it's
// `nullptr` since this could be a valid representation within a backend.
Expand Down
7 changes: 3 additions & 4 deletions test/conformance/kernel/urKernelCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
struct urKernelCreateWithNativeHandleTest : uur::urKernelTest {
void SetUp() override {
UUR_RETURN_ON_FATAL_FAILURE(urKernelTest::SetUp());
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urKernelGetNativeHandle(kernel, &native_kernel_handle));
}

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urKernelGetNativeHandle(kernel, &native_kernel_handle));
}

void TearDown() override {
Expand Down
21 changes: 9 additions & 12 deletions test/conformance/platform/urPlatformCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ using urPlatformCreateWithNativeHandleTest = uur::platform::urPlatformTest;
TEST_F(urPlatformCreateWithNativeHandleTest, Success) {
for (auto platform : platforms) {
ur_native_handle_t native_handle = 0;
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urPlatformGetNativeHandle(platform, &native_handle));
}

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urPlatformGetNativeHandle(platform, &native_handle));

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

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urPlatformGetNativeHandle(platform, &native_handle));

// We cannot assume anything about a native_handle, not even if it's
// `nullptr` since this could be a valid representation within a backend.
Expand All @@ -58,10 +56,9 @@ TEST_F(urPlatformCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
TEST_F(urPlatformCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) {
for (auto platform : platforms) {
ur_native_handle_t native_handle = 0;
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urPlatformGetNativeHandle(platform, &native_handle));
}

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urPlatformGetNativeHandle(platform, &native_handle));

// We cannot assume anything about a native_handle, not even if it's
// `nullptr` since this could be a valid representation within a backend.
Expand Down
7 changes: 3 additions & 4 deletions test/conformance/queue/urQueueCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueCreateWithNativeHandleTest);

TEST_P(urQueueCreateWithNativeHandleTest, Success) {
ur_native_handle_t native_handle = 0;
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urQueueGetNativeHandle(queue, nullptr, &native_handle));
}

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urQueueGetNativeHandle(queue, nullptr, &native_handle));

// We cannot assume anything about a native_handle, not even if it's
// `nullptr` since this could be a valid representation within a backend.
Expand Down
21 changes: 9 additions & 12 deletions test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urSamplerCreateWithNativeHandleTest);

TEST_P(urSamplerCreateWithNativeHandleTest, Success) {
ur_native_handle_t native_sampler = 0;
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urSamplerGetNativeHandle(sampler, &native_sampler));
}

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urSamplerGetNativeHandle(sampler, &native_sampler));

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

TEST_P(urSamplerCreateWithNativeHandleTest, InvalidNullHandle) {
ur_native_handle_t native_sampler = 0;
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urSamplerGetNativeHandle(sampler, &native_sampler));
}

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urSamplerGetNativeHandle(sampler, &native_sampler));

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

TEST_P(urSamplerCreateWithNativeHandleTest, InvalidNullPointer) {
ur_native_handle_t native_sampler = 0;
{
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urSamplerGetNativeHandle(sampler, &native_sampler));
}

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urSamplerGetNativeHandle(sampler, &native_sampler));

ur_sampler_native_properties_t props{};
ASSERT_EQ(urSamplerCreateWithNativeHandle(native_sampler, context, &props,
Expand Down
16 changes: 9 additions & 7 deletions test/conformance/testing/include/uur/fixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
(void)0

#define UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(ret) \
auto status = ret; \
if (status == UR_RESULT_ERROR_UNSUPPORTED_FEATURE || \
status == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) { \
GTEST_SKIP(); \
} else { \
ASSERT_EQ(status, UR_RESULT_SUCCESS); \
}
do { \
auto status = ret; \
if (status == UR_RESULT_ERROR_UNSUPPORTED_FEATURE || \
status == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) { \
GTEST_SKIP(); \
} else { \
ASSERT_EQ(status, UR_RESULT_SUCCESS); \
} \
} while (0)

namespace uur {

Expand Down

0 comments on commit f9f71f1

Please sign in to comment.