22// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
33// See LICENSE.TXT
44// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+ #include " ur_api.h"
6+ #include < gtest/gtest.h>
57#include < uur/fixtures.h>
68
79using urMemGetNativeHandleTest = uur::urMemBufferTest;
@@ -14,6 +16,26 @@ TEST_P(urMemGetNativeHandleTest, Success) {
1416 }
1517}
1618
19+ TEST_P (urMemGetNativeHandleTest, SuccessNullDeviceTwice) {
20+ ur_native_handle_t hNativeMem = 0 ;
21+ if (auto error = urMemGetNativeHandle (buffer, nullptr , &hNativeMem)) {
22+ ASSERT_TRUE (error == UR_RESULT_ERROR_UNSUPPORTED_FEATURE ||
23+ error == UR_RESULT_ERROR_INVALID_NULL_HANDLE);
24+ }
25+ if (auto error = urMemGetNativeHandle (buffer, nullptr , &hNativeMem)) {
26+ ASSERT_TRUE (error == UR_RESULT_ERROR_UNSUPPORTED_FEATURE ||
27+ error == UR_RESULT_ERROR_INVALID_NULL_HANDLE);
28+ }
29+ }
30+
31+ TEST_P (urMemGetNativeHandleTest, SuccessNullDevice) {
32+ ur_native_handle_t hNativeMem = 0 ;
33+ if (auto error = urMemGetNativeHandle (buffer, nullptr , &hNativeMem)) {
34+ ASSERT_TRUE (error == UR_RESULT_ERROR_UNSUPPORTED_FEATURE ||
35+ error == UR_RESULT_ERROR_INVALID_NULL_HANDLE);
36+ }
37+ }
38+
1739TEST_P (urMemGetNativeHandleTest, InvalidNullHandleMem) {
1840 ur_native_handle_t phNativeMem;
1941 ASSERT_EQ_RESULT (UR_RESULT_ERROR_INVALID_NULL_HANDLE,
0 commit comments