Skip to content

Commit

Permalink
Check for unsupported on CreateWithNative as well as GetNative.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongreig committed Nov 11, 2024
1 parent 0ba9457 commit 48c91d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TEST_P(urMemBufferCreateWithNativeHandleTest, Success) {
// We can however convert the native_handle back into a unified-runtime handle
// and perform some query on it to verify that it works.
ur_mem_handle_t mem = nullptr;
ASSERT_SUCCESS(
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urMemBufferCreateWithNativeHandle(hNativeMem, context, nullptr, &mem));
ASSERT_NE(mem, nullptr);

Expand All @@ -44,7 +44,7 @@ TEST_P(urMemBufferCreateWithNativeHandleTest, SuccessWithProperties) {
/*.pNext =*/nullptr,
/*.isNativeHandleOwned =*/false,
};
ASSERT_SUCCESS(
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urMemBufferCreateWithNativeHandle(hNativeMem, context, &props, &mem));
ASSERT_NE(mem, nullptr);

Expand Down
10 changes: 6 additions & 4 deletions test/conformance/memory/urMemImageCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TEST_P(urMemImageCreateWithNativeHandleTest, Success) {
urMemGetNativeHandle(image, device, &native_handle));

ur_mem_handle_t mem = nullptr;
ASSERT_SUCCESS(urMemImageCreateWithNativeHandle(
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urMemImageCreateWithNativeHandle(
native_handle, context, &image_format, &image_desc, nullptr, &mem));
ASSERT_NE(nullptr, mem);

Expand All @@ -36,7 +36,7 @@ TEST_P(urMemImageCreateWithNativeHandleTest, SuccessWithProperties) {
// We can't pass isNativeHandleOwned = true in the generic tests since
// we always get the native handle from a UR object, and transferring
// ownership from one UR object to another isn't allowed.
ASSERT_SUCCESS(urMemImageCreateWithNativeHandle(
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urMemImageCreateWithNativeHandle(
native_handle, context, &image_format, &image_desc, &props, &mem));
ASSERT_NE(nullptr, mem);

Expand All @@ -49,7 +49,8 @@ TEST_P(urMemImageCreateWithNativeHandleTest, SuccessWithProperties) {

TEST_P(urMemImageCreateWithNativeHandleTest, InvalidNullHandle) {
ur_native_handle_t native_handle = 0;
ASSERT_SUCCESS(urMemGetNativeHandle(image, device, &native_handle));
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urMemGetNativeHandle(image, device, &native_handle));

ur_mem_handle_t mem = nullptr;
ASSERT_EQ_RESULT(
Expand All @@ -60,7 +61,8 @@ TEST_P(urMemImageCreateWithNativeHandleTest, InvalidNullHandle) {

TEST_P(urMemImageCreateWithNativeHandleTest, InvalidNullPointer) {
ur_native_handle_t native_handle = 0;
ASSERT_SUCCESS(urMemGetNativeHandle(image, device, &native_handle));
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urMemGetNativeHandle(image, device, &native_handle));

ASSERT_EQ_RESULT(
UR_RESULT_ERROR_INVALID_NULL_POINTER,
Expand Down
12 changes: 7 additions & 5 deletions test/conformance/testing/include/uur/fixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
(void)0

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

namespace uur {
Expand Down

0 comments on commit 48c91d1

Please sign in to comment.