diff --git a/tests/common/common.h b/tests/common/common.h index 4469681d1..b42f09df7 100644 --- a/tests/common/common.h +++ b/tests/common/common.h @@ -159,6 +159,25 @@ void check_get_info_param(const ObjectT& object) { check_return_type(returnValue, "object::get_info()"); } +/** + * @brief Helper function to check an info parameter for specific backend. + */ +template +void check_get_info_param_backend_specific(const ObjectT& object) { + try { + check_get_info_param(object); + CHECK(object.get_backend() == Backend); + } catch (const sycl::exception& e) { +#ifndef SYCL_CTS_COMPILING_WITH_HIPSYCL + CHECK(e.code() == sycl::make_error_code(sycl::errc::invalid)); +#endif + CHECK(object.get_backend() != Backend); + } catch (...) { + FAIL("Unexpected exception"); + } +} + /** * @deprecated Use overload without logger. */ diff --git a/tests/device/device_info.cpp b/tests/device/device_info.cpp index 9f3853d7b..27075076c 100644 --- a/tests/device/device_info.cpp +++ b/tests/device/device_info.cpp @@ -220,7 +220,9 @@ TEST_CASE("device info", "[device]") { check_get_info_param(dev); check_get_info_param(dev); check_get_info_param(dev); - check_get_info_param(dev); + check_get_info_param_backend_specific( + dev); check_get_info_param(dev); check_get_info_param(dev); @@ -230,8 +232,9 @@ TEST_CASE("device info", "[device]") { check_get_info_param>(dev); check_get_info_param(dev); - check_get_info_param( - dev); + check_get_info_param_backend_specific< + sycl::info::device::preferred_interop_user_sync, bool, + sycl::backend::opencl>(dev); auto SupportedProperties = dev.get_info(); if (std::find(SupportedProperties.begin(), SupportedProperties.end(),