|
| 1 | +//==---------- support_native.cpp --- Check support is correctly reported --==// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | + |
| 9 | +#include "ur_mock_helpers.hpp" |
| 10 | + |
| 11 | +#include <sycl/sycl.hpp> |
| 12 | + |
| 13 | +#include <helpers/UrMock.hpp> |
| 14 | + |
| 15 | +#include <gtest/gtest.h> |
| 16 | + |
| 17 | +template <bool Support> |
| 18 | +static ur_result_t redefinedDeviceGetInfoAfter(void *pParams) { |
| 19 | + auto &Params = *reinterpret_cast<ur_device_get_info_params_t *>(pParams); |
| 20 | + if (*Params.ppropName == UR_DEVICE_INFO_USE_NATIVE_ASSERT) { |
| 21 | + if (*Params.ppPropValue) |
| 22 | + *reinterpret_cast<ur_bool_t *>(*Params.ppPropValue) = Support; |
| 23 | + if (*Params.ppPropSizeRet) |
| 24 | + **Params.ppPropSizeRet = sizeof(ur_bool_t); |
| 25 | + } |
| 26 | + return UR_RESULT_SUCCESS; |
| 27 | +} |
| 28 | + |
| 29 | +TEST(SupportNativeAssert, True) { |
| 30 | + mock::getCallbacks().set_after_callback("urDeviceGetInfo", |
| 31 | + &redefinedDeviceGetInfoAfter<true>); |
| 32 | + |
| 33 | + sycl::unittest::UrMock<> Mock; |
| 34 | + sycl::platform Plt = sycl::platform(); |
| 35 | + |
| 36 | + const sycl::device Dev = Plt.get_devices()[0]; |
| 37 | + |
| 38 | + ASSERT_TRUE(Dev.has(sycl::aspect::ext_oneapi_native_assert)); |
| 39 | +} |
| 40 | + |
| 41 | +TEST(SupportNativeAssert, False) { |
| 42 | + mock::getCallbacks().set_after_callback("urDeviceGetInfo", |
| 43 | + &redefinedDeviceGetInfoAfter<false>); |
| 44 | + |
| 45 | + sycl::unittest::UrMock<> Mock; |
| 46 | + sycl::platform Plt = sycl::platform(); |
| 47 | + |
| 48 | + const sycl::device Dev = Plt.get_devices()[0]; |
| 49 | + |
| 50 | + ASSERT_FALSE(Dev.has(sycl::aspect::ext_oneapi_native_assert)); |
| 51 | +} |
0 commit comments