diff --git a/test/adapters/cuda/urDeviceCreateWithNativeHandle.cpp b/test/adapters/cuda/urDeviceCreateWithNativeHandle.cpp index e4ac022507..615e6e95dd 100644 --- a/test/adapters/cuda/urDeviceCreateWithNativeHandle.cpp +++ b/test/adapters/cuda/urDeviceCreateWithNativeHandle.cpp @@ -5,7 +5,7 @@ #include "fixtures.h" -using urCudaDeviceCreateWithNativeHandle = uur::urPlatformTest; +using urCudaDeviceCreateWithNativeHandle = uur::urSelectedPlatformTest; TEST_F(urCudaDeviceCreateWithNativeHandle, Success) { // get a device from cuda diff --git a/test/conformance/device/urDeviceGet.cpp b/test/conformance/device/urDeviceGet.cpp index 5ce4c45906..f6ec9d82aa 100644 --- a/test/conformance/device/urDeviceGet.cpp +++ b/test/conformance/device/urDeviceGet.cpp @@ -6,8 +6,9 @@ #include using urDeviceGetTest = uur::urPlatformTest; +UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urDeviceGetTest); -TEST_F(urDeviceGetTest, Success) { +TEST_P(urDeviceGetTest, Success) { uint32_t count = 0; ASSERT_SUCCESS( urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count)); @@ -20,7 +21,7 @@ TEST_F(urDeviceGetTest, Success) { } } -TEST_F(urDeviceGetTest, SuccessSubsetOfDevices) { +TEST_P(urDeviceGetTest, SuccessSubsetOfDevices) { uint32_t count; ASSERT_SUCCESS( urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count)); @@ -35,6 +36,41 @@ TEST_F(urDeviceGetTest, SuccessSubsetOfDevices) { } } +TEST_P(urDeviceGetTest, InvalidNullHandlePlatform) { + uint32_t count; + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urDeviceGet(nullptr, UR_DEVICE_TYPE_ALL, 0, nullptr, &count)); +} + +TEST_P(urDeviceGetTest, InvalidEnumerationDevicesType) { + uint32_t count; + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_ENUMERATION, + urDeviceGet(platform, UR_DEVICE_TYPE_FORCE_UINT32, 0, nullptr, &count)); +} + +TEST_P(urDeviceGetTest, InvalidSizeNumEntries) { + uint32_t count = 0; + ASSERT_SUCCESS( + urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count)); + ASSERT_NE(count, 0); + std::vector devices(count); + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_SIZE, + urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, devices.data(), nullptr)); +} + +TEST_P(urDeviceGetTest, InvalidNullPointerDevices) { + uint32_t count = 0; + ASSERT_SUCCESS( + urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count)); + ASSERT_NE(count, 0); + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_NULL_POINTER, + urDeviceGet(platform, UR_DEVICE_TYPE_ALL, count, nullptr, nullptr)); +} + struct urDeviceGetTestWithDeviceTypeParam : uur::urAllDevicesTest, ::testing::WithParamInterface { @@ -70,38 +106,3 @@ TEST_P(urDeviceGetTestWithDeviceTypeParam, Success) { } } } - -TEST_F(urDeviceGetTest, InvalidNullHandlePlatform) { - uint32_t count; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urDeviceGet(nullptr, UR_DEVICE_TYPE_ALL, 0, nullptr, &count)); -} - -TEST_F(urDeviceGetTest, InvalidEnumerationDevicesType) { - uint32_t count; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_ENUMERATION, - urDeviceGet(platform, UR_DEVICE_TYPE_FORCE_UINT32, 0, nullptr, &count)); -} - -TEST_F(urDeviceGetTest, InvalidSizeNumEntries) { - uint32_t count = 0; - ASSERT_SUCCESS( - urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count)); - ASSERT_NE(count, 0); - std::vector devices(count); - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_SIZE, - urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, devices.data(), nullptr)); -} - -TEST_F(urDeviceGetTest, InvalidNullPointerDevices) { - uint32_t count = 0; - ASSERT_SUCCESS( - urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count)); - ASSERT_NE(count, 0); - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_POINTER, - urDeviceGet(platform, UR_DEVICE_TYPE_ALL, count, nullptr, nullptr)); -} diff --git a/test/conformance/device/urDeviceGetSelected.cpp b/test/conformance/device/urDeviceGetSelected.cpp index 953b418e24..2099d226c4 100644 --- a/test/conformance/device/urDeviceGetSelected.cpp +++ b/test/conformance/device/urDeviceGetSelected.cpp @@ -7,10 +7,11 @@ #include using urDeviceGetSelectedTest = uur::urPlatformTest; +UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urDeviceGetSelectedTest); /* adpater agnostic tests -- none assume the existence or support of any specific adapter */ -TEST_F(urDeviceGetSelectedTest, Success) { +TEST_P(urDeviceGetSelectedTest, Success) { unsetenv("ONEAPI_DEVICE_SELECTOR"); uint32_t count = 0; ASSERT_SUCCESS( @@ -24,7 +25,7 @@ TEST_F(urDeviceGetSelectedTest, Success) { } } -TEST_F(urDeviceGetSelectedTest, SuccessSubsetOfDevices) { +TEST_P(urDeviceGetSelectedTest, SuccessSubsetOfDevices) { unsetenv("ONEAPI_DEVICE_SELECTOR"); uint32_t count = 0; ASSERT_SUCCESS( @@ -41,7 +42,7 @@ TEST_F(urDeviceGetSelectedTest, SuccessSubsetOfDevices) { } } -TEST_F(urDeviceGetSelectedTest, SuccessSelected_StarColonStar) { +TEST_P(urDeviceGetSelectedTest, SuccessSelected_StarColonStar) { setenv("ONEAPI_DEVICE_SELECTOR", "*:*", 1); uint32_t count = 0; ASSERT_SUCCESS( @@ -71,7 +72,7 @@ TEST_F(urDeviceGetSelectedTest, SuccessSelected_StarColonStar) { } } -TEST_F(urDeviceGetSelectedTest, SuccessSelected_StarColonZero) { +TEST_P(urDeviceGetSelectedTest, SuccessSelected_StarColonZero) { setenv("ONEAPI_DEVICE_SELECTOR", "*:0", 1); uint32_t count = 0; ASSERT_SUCCESS( @@ -85,7 +86,7 @@ TEST_F(urDeviceGetSelectedTest, SuccessSelected_StarColonZero) { } } -TEST_F(urDeviceGetSelectedTest, SuccessSelected_StarColonZeroCommaStar) { +TEST_P(urDeviceGetSelectedTest, SuccessSelected_StarColonZeroCommaStar) { setenv("ONEAPI_DEVICE_SELECTOR", "*:0,*", 1); uint32_t count = 0; ASSERT_SUCCESS( @@ -99,7 +100,7 @@ TEST_F(urDeviceGetSelectedTest, SuccessSelected_StarColonZeroCommaStar) { } } -TEST_F(urDeviceGetSelectedTest, SuccessSelected_DiscardStarColonStar) { +TEST_P(urDeviceGetSelectedTest, SuccessSelected_DiscardStarColonStar) { setenv("ONEAPI_DEVICE_SELECTOR", "!*:*", 1); uint32_t count = 0; ASSERT_SUCCESS( @@ -107,7 +108,7 @@ TEST_F(urDeviceGetSelectedTest, SuccessSelected_DiscardStarColonStar) { ASSERT_EQ(count, 0); } -TEST_F(urDeviceGetSelectedTest, SuccessSelected_SelectAndDiscard) { +TEST_P(urDeviceGetSelectedTest, SuccessSelected_SelectAndDiscard) { setenv("ONEAPI_DEVICE_SELECTOR", "*:0;!*:*", 1); uint32_t count = 0; ASSERT_SUCCESS( @@ -115,7 +116,7 @@ TEST_F(urDeviceGetSelectedTest, SuccessSelected_SelectAndDiscard) { ASSERT_EQ(count, 0); } -TEST_F(urDeviceGetSelectedTest, +TEST_P(urDeviceGetSelectedTest, SuccessSelected_SelectSomethingAndDiscardSomethingElse) { setenv("ONEAPI_DEVICE_SELECTOR", "*:0;!*:1", 1); uint32_t count = 0; @@ -130,7 +131,7 @@ TEST_F(urDeviceGetSelectedTest, } } -TEST_F(urDeviceGetSelectedTest, InvalidNullHandlePlatform) { +TEST_P(urDeviceGetSelectedTest, InvalidNullHandlePlatform) { unsetenv("ONEAPI_DEVICE_SELECTOR"); uint32_t count = 0; ASSERT_EQ_RESULT( @@ -138,7 +139,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidNullHandlePlatform) { urDeviceGetSelected(nullptr, UR_DEVICE_TYPE_ALL, 0, nullptr, &count)); } -TEST_F(urDeviceGetSelectedTest, InvalidEnumerationDevicesType) { +TEST_P(urDeviceGetSelectedTest, InvalidEnumerationDevicesType) { unsetenv("ONEAPI_DEVICE_SELECTOR"); uint32_t count = 0; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, @@ -146,7 +147,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidEnumerationDevicesType) { 0, nullptr, &count)); } -TEST_F(urDeviceGetSelectedTest, InvalidValueNumEntries) { +TEST_P(urDeviceGetSelectedTest, InvalidValueNumEntries) { unsetenv("ONEAPI_DEVICE_SELECTOR"); uint32_t count = 0; ASSERT_SUCCESS( @@ -158,7 +159,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidValueNumEntries) { devices.data(), nullptr)); } -TEST_F(urDeviceGetSelectedTest, InvalidMissingBackend) { +TEST_P(urDeviceGetSelectedTest, InvalidMissingBackend) { setenv("ONEAPI_DEVICE_SELECTOR", ":garbage", 1); uint32_t count = 0; ASSERT_EQ_RESULT( @@ -167,7 +168,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidMissingBackend) { ASSERT_EQ(count, 0); } -TEST_F(urDeviceGetSelectedTest, InvalidGarbageBackendString) { +TEST_P(urDeviceGetSelectedTest, InvalidGarbageBackendString) { setenv("ONEAPI_DEVICE_SELECTOR", "garbage:0", 1); uint32_t count = 0; ASSERT_EQ_RESULT( @@ -176,7 +177,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidGarbageBackendString) { ASSERT_EQ(count, 0); } -TEST_F(urDeviceGetSelectedTest, InvalidMissingFilterStrings) { +TEST_P(urDeviceGetSelectedTest, InvalidMissingFilterStrings) { setenv("ONEAPI_DEVICE_SELECTOR", "*", 1); uint32_t count = 0; ASSERT_EQ_RESULT( @@ -191,7 +192,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidMissingFilterStrings) { ASSERT_EQ(count2, 0); } -TEST_F(urDeviceGetSelectedTest, InvalidMissingFilterString) { +TEST_P(urDeviceGetSelectedTest, InvalidMissingFilterString) { setenv("ONEAPI_DEVICE_SELECTOR", "*:0,,2", 1); uint32_t count = 0; ASSERT_EQ_RESULT( @@ -200,7 +201,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidMissingFilterString) { ASSERT_EQ(count, 0); } -TEST_F(urDeviceGetSelectedTest, InvalidTooManyDotsInFilterString) { +TEST_P(urDeviceGetSelectedTest, InvalidTooManyDotsInFilterString) { setenv("ONEAPI_DEVICE_SELECTOR", "*:0.1.2.3", 1); uint32_t count = 0; ASSERT_EQ_RESULT( @@ -209,7 +210,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidTooManyDotsInFilterString) { ASSERT_EQ(count, 0); } -TEST_F(urDeviceGetSelectedTest, InvalidBadWildardInFilterString) { +TEST_P(urDeviceGetSelectedTest, InvalidBadWildardInFilterString) { setenv("ONEAPI_DEVICE_SELECTOR", "*:*.", 1); uint32_t count = 0; ASSERT_EQ_RESULT( @@ -224,7 +225,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidBadWildardInFilterString) { ASSERT_EQ(count2, 0); } -TEST_F(urDeviceGetSelectedTest, InvalidSelectingNonexistentDevice) { +TEST_P(urDeviceGetSelectedTest, InvalidSelectingNonexistentDevice) { setenv("ONEAPI_DEVICE_SELECTOR", "*:4321", 1); uint32_t count = 0; ASSERT_SUCCESS( @@ -232,7 +233,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidSelectingNonexistentDevice) { ASSERT_EQ(count, 0); } -TEST_F(urDeviceGetSelectedTest, InvalidSelectingNonexistentSubDevice) { +TEST_P(urDeviceGetSelectedTest, InvalidSelectingNonexistentSubDevice) { setenv("ONEAPI_DEVICE_SELECTOR", "*:0.4321", 1); uint32_t count = 0; ASSERT_SUCCESS( @@ -240,7 +241,7 @@ TEST_F(urDeviceGetSelectedTest, InvalidSelectingNonexistentSubDevice) { ASSERT_EQ(count, 0); } -TEST_F(urDeviceGetSelectedTest, InvalidSelectingNonexistentSubSubDevice) { +TEST_P(urDeviceGetSelectedTest, InvalidSelectingNonexistentSubSubDevice) { setenv("ONEAPI_DEVICE_SELECTOR", "*:0.0.4321", 1); uint32_t count = 0; ASSERT_SUCCESS( diff --git a/test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp b/test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp index f7617a2940..040634898f 100644 --- a/test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp +++ b/test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp @@ -148,8 +148,9 @@ struct urMultiDeviceContextMemBufferTest : urMultiDeviceContextTest { std::vector kernels; std::vector metadatas{}; }; +UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urMultiDeviceContextMemBufferTest); -TEST_F(urMultiDeviceContextMemBufferTest, WriteRead) { +TEST_P(urMultiDeviceContextMemBufferTest, WriteRead) { if (num_devices == 1) { GTEST_SKIP(); } @@ -173,7 +174,7 @@ TEST_F(urMultiDeviceContextMemBufferTest, WriteRead) { } } -TEST_F(urMultiDeviceContextMemBufferTest, FillRead) { +TEST_P(urMultiDeviceContextMemBufferTest, FillRead) { if (num_devices == 1) { GTEST_SKIP(); } @@ -197,7 +198,7 @@ TEST_F(urMultiDeviceContextMemBufferTest, FillRead) { } } -TEST_F(urMultiDeviceContextMemBufferTest, WriteKernelRead) { +TEST_P(urMultiDeviceContextMemBufferTest, WriteKernelRead) { if (num_devices == 1) { GTEST_SKIP(); } @@ -233,7 +234,7 @@ TEST_F(urMultiDeviceContextMemBufferTest, WriteKernelRead) { } } -TEST_F(urMultiDeviceContextMemBufferTest, WriteKernelKernelRead) { +TEST_P(urMultiDeviceContextMemBufferTest, WriteKernelKernelRead) { if (num_devices == 1) { GTEST_SKIP(); } diff --git a/test/conformance/platform/CMakeLists.txt b/test/conformance/platform/CMakeLists.txt index eec1e9bee3..e07689324b 100644 --- a/test/conformance/platform/CMakeLists.txt +++ b/test/conformance/platform/CMakeLists.txt @@ -3,7 +3,7 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_conformance_test(platform +add_conformance_test_with_platform_environment(platform urPlatformCreateWithNativeHandle.cpp urPlatformGet.cpp urPlatformGetApiVersion.cpp diff --git a/test/conformance/platform/fixtures.h b/test/conformance/platform/fixtures.h index a11426b25c..60928d50c0 100644 --- a/test/conformance/platform/fixtures.h +++ b/test/conformance/platform/fixtures.h @@ -7,76 +7,42 @@ #define UR_CONFORMANCE_PLATFORM_FIXTURES_H_INCLUDED #include +#include + namespace uur { namespace platform { -struct urTest : ::testing::Test { - - void SetUp() override { - ur_device_init_flags_t device_flags = 0; - ASSERT_SUCCESS(urLoaderConfigCreate(&loader_config)); - ASSERT_SUCCESS(urLoaderConfigEnableLayer(loader_config, - "UR_LAYER_FULL_VALIDATION")); - ASSERT_SUCCESS(urLoaderInit(device_flags, loader_config)); - - uint32_t adapter_count; - ASSERT_SUCCESS(urAdapterGet(0, nullptr, &adapter_count)); - adapters.resize(adapter_count); - ASSERT_SUCCESS(urAdapterGet(adapter_count, adapters.data(), nullptr)); - } - - void TearDown() override { - for (auto adapter : adapters) { - ASSERT_SUCCESS(urAdapterRelease(adapter)); - } - if (loader_config) { - ASSERT_SUCCESS(urLoaderConfigRelease(loader_config)); - } - ASSERT_SUCCESS(urLoaderTearDown()); - } - - ur_loader_config_handle_t loader_config = nullptr; - std::vector adapters; -}; - -struct urPlatformsTest : urTest { - - void SetUp() override { - UUR_RETURN_ON_FATAL_FAILURE(urTest::SetUp()); - uint32_t count; - ASSERT_SUCCESS(urPlatformGet(adapters.data(), - static_cast(adapters.size()), 0, - nullptr, &count)); - ASSERT_NE(count, 0); - platforms.resize(count); - ASSERT_SUCCESS(urPlatformGet(adapters.data(), - static_cast(adapters.size()), - count, platforms.data(), nullptr)); - } - - std::vector platforms; +template +struct urPlatformTestWithParam + : ::testing::Test, + ::testing::WithParamInterface> { + void SetUp() override { platform = std::get<0>(this->GetParam()); } + const T &getParam() const { return std::get<1>(this->GetParam()); } + ur_platform_handle_t platform; }; -struct urPlatformTest : urPlatformsTest { +template +std::string platformTestWithParamPrinter( + const ::testing::TestParamInfo> &info) { + auto platform = std::get<0>(info.param); + auto param = std::get<1>(info.param); - void SetUp() override { - UUR_RETURN_ON_FATAL_FAILURE(urPlatformsTest::SetUp()); - ASSERT_GE(platforms.size(), 1); - platform = platforms[0]; // TODO - which to choose? - } + std::stringstream ss; + ss << param; + return uur::GetPlatformNameWithID(platform) + "__" + + GTestSanitizeString(ss.str()); +} - ur_platform_handle_t platform; -}; +} // namespace platform +} // namespace uur -#define UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(FIXTURE) \ +#define UUR_PLATFORM_TEST_SUITE_P(FIXTURE, VALUES, TYPE) \ INSTANTIATE_TEST_SUITE_P( \ , FIXTURE, \ - ::testing::ValuesIn(uur::DevicesEnvironment::instance->devices), \ - [](const ::testing::TestParamInfo &info) { \ - return uur::GetPlatformAndDeviceName(info.param); \ - }) - -} // namespace platform -} // namespace uur + testing::Combine( \ + ::testing::ValuesIn( \ + uur::PlatformEnvironment::instance->all_platforms), \ + VALUES), \ + uur::platform::platformTestWithParamPrinter) #endif // UR_CONFORMANCE_PLATFORM_FIXTURES_H_INCLUDED diff --git a/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp b/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp index 6b56f9b661..763c6efcac 100644 --- a/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp +++ b/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp @@ -3,87 +3,88 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include "fixtures.h" +#include -using urPlatformCreateWithNativeHandleTest = uur::platform::urPlatformTest; +struct urPlatformCreateWithNativeHandleTest : uur::urPlatformTest { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(uur::urPlatformTest::SetUp()); + ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_ADAPTER, + sizeof(ur_adapter_handle_t), &adapter, + nullptr)); + } + ur_adapter_handle_t adapter = nullptr; +}; +UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urPlatformCreateWithNativeHandleTest); -TEST_F(urPlatformCreateWithNativeHandleTest, Success) { - for (auto platform : platforms) { - ur_native_handle_t native_handle = 0; +TEST_P(urPlatformCreateWithNativeHandleTest, Success) { + 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. - // 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_platform_handle_t plat = nullptr; - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urPlatformCreateWithNativeHandle( - native_handle, adapters[0], nullptr, &plat)); - ASSERT_NE(plat, nullptr); + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // 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_platform_handle_t plat = nullptr; + UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urPlatformCreateWithNativeHandle( + native_handle, adapter, nullptr, &plat)); + ASSERT_NE(plat, nullptr); - std::string input_platform_name = uur::GetPlatformName(platform); - std::string created_platform_name = uur::GetPlatformName(plat); - ASSERT_EQ(input_platform_name, created_platform_name); - } + std::string input_platform_name = uur::GetPlatformName(platform); + std::string created_platform_name = uur::GetPlatformName(plat); + ASSERT_EQ(input_platform_name, created_platform_name); } -TEST_F(urPlatformCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) { - for (auto platform : platforms) { - ur_native_handle_t native_handle = 0; +TEST_P(urPlatformCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) { + 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. - // 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_platform_native_properties_t props = { - UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES, nullptr, true}; - ur_platform_handle_t plat = nullptr; - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urPlatformCreateWithNativeHandle( - native_handle, adapters[0], &props, &plat)); - ASSERT_NE(plat, nullptr); + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // 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_platform_native_properties_t props = { + UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES, nullptr, true}; + ur_platform_handle_t plat = nullptr; + UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urPlatformCreateWithNativeHandle( + native_handle, adapter, &props, &plat)); + ASSERT_NE(plat, nullptr); - std::string input_platform_name = uur::GetPlatformName(platform); - std::string created_platform_name = uur::GetPlatformName(plat); - ASSERT_EQ(input_platform_name, created_platform_name); - } + std::string input_platform_name = uur::GetPlatformName(platform); + std::string created_platform_name = uur::GetPlatformName(plat); + ASSERT_EQ(input_platform_name, created_platform_name); } -TEST_F(urPlatformCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) { - for (auto platform : platforms) { - ur_native_handle_t native_handle = 0; +TEST_P(urPlatformCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) { + 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. - // 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_platform_native_properties_t props = { - UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES, nullptr, false}; - ur_platform_handle_t plat = nullptr; - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urPlatformCreateWithNativeHandle( - native_handle, adapters[0], &props, &plat)); - ASSERT_NE(plat, nullptr); + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // 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_platform_native_properties_t props = { + UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES, nullptr, false}; + ur_platform_handle_t plat = nullptr; + UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urPlatformCreateWithNativeHandle( + native_handle, adapter, &props, &plat)); + ASSERT_NE(plat, nullptr); - std::string input_platform_name = uur::GetPlatformName(platform); - std::string created_platform_name = uur::GetPlatformName(plat); - ASSERT_EQ(input_platform_name, created_platform_name); - } + std::string input_platform_name = uur::GetPlatformName(platform); + std::string created_platform_name = uur::GetPlatformName(plat); + ASSERT_EQ(input_platform_name, created_platform_name); } -TEST_F(urPlatformCreateWithNativeHandleTest, InvalidNullPointerPlatform) { - for (auto platform : platforms) { - ur_native_handle_t native_handle = 0; - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( - urPlatformGetNativeHandle(platform, &native_handle)); - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, - urPlatformCreateWithNativeHandle( - native_handle, adapters[0], nullptr, nullptr)); - } +TEST_P(urPlatformCreateWithNativeHandleTest, InvalidNullPointerPlatform) { + ur_native_handle_t native_handle = 0; + UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( + urPlatformGetNativeHandle(platform, &native_handle)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urPlatformCreateWithNativeHandle(native_handle, adapter, + nullptr, nullptr)); } diff --git a/test/conformance/platform/urPlatformGet.cpp b/test/conformance/platform/urPlatformGet.cpp index 20f12c16df..b7305a066d 100644 --- a/test/conformance/platform/urPlatformGet.cpp +++ b/test/conformance/platform/urPlatformGet.cpp @@ -3,9 +3,12 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include "fixtures.h" +#include -using urPlatformGetTest = uur::platform::urTest; +struct urPlatformGetTest : ::testing::Test { + std::vector &adapters = + uur::PlatformEnvironment::instance->adapters; +}; TEST_F(urPlatformGetTest, Success) { uint32_t count; diff --git a/test/conformance/platform/urPlatformGetApiVersion.cpp b/test/conformance/platform/urPlatformGetApiVersion.cpp index 10279d560a..f3571f9a58 100644 --- a/test/conformance/platform/urPlatformGetApiVersion.cpp +++ b/test/conformance/platform/urPlatformGetApiVersion.cpp @@ -3,24 +3,25 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include "fixtures.h" +#include -using urPlatformGetApiVersionTest = uur::platform::urPlatformTest; +using urPlatformGetApiVersionTest = uur::urPlatformTest; +UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urPlatformGetApiVersionTest); -TEST_F(urPlatformGetApiVersionTest, Success) { +TEST_P(urPlatformGetApiVersionTest, Success) { ur_api_version_t version; ASSERT_EQ_RESULT(UR_RESULT_SUCCESS, urPlatformGetApiVersion(platform, &version)); ASSERT_GE(UR_API_VERSION_CURRENT, version); } -TEST_F(urPlatformGetApiVersionTest, InvalidPlatform) { +TEST_P(urPlatformGetApiVersionTest, InvalidPlatform) { ur_api_version_t version; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urPlatformGetApiVersion(nullptr, &version)); } -TEST_F(urPlatformGetApiVersionTest, InvalidVersionPtr) { +TEST_P(urPlatformGetApiVersionTest, InvalidVersionPtr) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, urPlatformGetApiVersion(platform, nullptr)); } diff --git a/test/conformance/platform/urPlatformGetBackendOption.cpp b/test/conformance/platform/urPlatformGetBackendOption.cpp index 06ac618580..30d59013df 100644 --- a/test/conformance/platform/urPlatformGetBackendOption.cpp +++ b/test/conformance/platform/urPlatformGetBackendOption.cpp @@ -4,45 +4,45 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "fixtures.h" -struct urPlatfromGetBackendOptionTestWithParam - : uur::platform::urPlatformTest, - ::testing::WithParamInterface {}; +using urPlatformGetBackendOptionTest = + uur::platform::urPlatformTestWithParam; -INSTANTIATE_TEST_SUITE_P(, urPlatfromGetBackendOptionTestWithParam, - ::testing::Values("-O0", "-O1", "-O2", "-O3"), - [](const ::testing::TestParamInfo &info) { - return uur::GTestSanitizeString(info.param); - }); +UUR_PLATFORM_TEST_SUITE_P(urPlatformGetBackendOptionTest, + ::testing::Values("-O0", "-O1", "-O2", "-O3"), + std::string); -TEST_P(urPlatfromGetBackendOptionTestWithParam, Success) { +TEST_P(urPlatformGetBackendOptionTest, Success) { const char *platformOption = nullptr; - ASSERT_SUCCESS(urPlatformGetBackendOption(platform, GetParam().c_str(), + ASSERT_SUCCESS(urPlatformGetBackendOption(platform, getParam().c_str(), &platformOption)); ASSERT_NE(platformOption, nullptr); } -using urPlatfromGetBackendOptionTest = uur::platform::urPlatformTest; +using urPlatformGetBackendOptionNegativeTest = uur::urPlatformTest; +UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urPlatformGetBackendOptionNegativeTest); -TEST_F(urPlatfromGetBackendOptionTest, InvalidNullHandle) { +TEST_P(urPlatformGetBackendOptionNegativeTest, InvalidNullHandle) { const char *platformOption = nullptr; ASSERT_EQ_RESULT( UR_RESULT_ERROR_INVALID_NULL_HANDLE, urPlatformGetBackendOption(nullptr, "-O0", &platformOption)); } -TEST_F(urPlatfromGetBackendOptionTest, InvalidNullPointerFrontendOption) { +TEST_P(urPlatformGetBackendOptionNegativeTest, + InvalidNullPointerFrontendOption) { const char *platformOption = nullptr; ASSERT_EQ_RESULT( UR_RESULT_ERROR_INVALID_NULL_POINTER, urPlatformGetBackendOption(platform, nullptr, &platformOption)); } -TEST_F(urPlatfromGetBackendOptionTest, InvalidNullPointerPlatformOption) { +TEST_P(urPlatformGetBackendOptionNegativeTest, + InvalidNullPointerPlatformOption) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, urPlatformGetBackendOption(platform, "-O0", nullptr)); } -TEST_F(urPlatfromGetBackendOptionTest, InvalidValueFrontendOption) { +TEST_P(urPlatformGetBackendOptionNegativeTest, InvalidValueFrontendOption) { const char *platformOption = nullptr; ASSERT_EQ_RESULT( UR_RESULT_ERROR_INVALID_VALUE, diff --git a/test/conformance/platform/urPlatformGetInfo.cpp b/test/conformance/platform/urPlatformGetInfo.cpp index 8535b42b5b..5f3e422740 100644 --- a/test/conformance/platform/urPlatformGetInfo.cpp +++ b/test/conformance/platform/urPlatformGetInfo.cpp @@ -4,32 +4,24 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "fixtures.h" +#include "uur/environment.h" +#include "uur/fixtures.h" #include -struct urPlatformGetInfoTest - : uur::platform::urPlatformTest, - ::testing::WithParamInterface { +using urPlatformGetInfoTest = + uur::platform::urPlatformTestWithParam; - void SetUp() { - UUR_RETURN_ON_FATAL_FAILURE(uur::platform::urPlatformTest::SetUp()); - } -}; - -INSTANTIATE_TEST_SUITE_P( - urPlatformGetInfo, urPlatformGetInfoTest, +UUR_PLATFORM_TEST_SUITE_P( + urPlatformGetInfoTest, ::testing::Values(UR_PLATFORM_INFO_NAME, UR_PLATFORM_INFO_VENDOR_NAME, UR_PLATFORM_INFO_VERSION, UR_PLATFORM_INFO_EXTENSIONS, UR_PLATFORM_INFO_PROFILE, UR_PLATFORM_INFO_BACKEND, UR_PLATFORM_INFO_ADAPTER), - [](const ::testing::TestParamInfo &info) { - std::stringstream ss; - ss << info.param; - return ss.str(); - }); + ur_platform_info_t); TEST_P(urPlatformGetInfoTest, Success) { size_t size = 0; - ur_platform_info_t info_type = GetParam(); + ur_platform_info_t info_type = getParam(); ASSERT_SUCCESS_OR_OPTIONAL_QUERY( urPlatformGetInfo(platform, info_type, 0, nullptr, &size), info_type); if (info_type == UR_PLATFORM_INFO_BACKEND) { @@ -57,8 +49,11 @@ TEST_P(urPlatformGetInfoTest, Success) { auto queried_adapter = *reinterpret_cast(name.data()); auto adapter_found = - std::find(adapters.begin(), adapters.end(), queried_adapter); - ASSERT_NE(adapter_found, adapters.end()); + std::find(uur::PlatformEnvironment::instance->adapters.begin(), + uur::PlatformEnvironment::instance->adapters.end(), + queried_adapter); + ASSERT_NE(adapter_found, + uur::AdapterEnvironment::instance->adapters.end()); break; } default: @@ -69,38 +64,41 @@ TEST_P(urPlatformGetInfoTest, Success) { TEST_P(urPlatformGetInfoTest, InvalidNullHandlePlatform) { size_t size = 0; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urPlatformGetInfo(nullptr, GetParam(), 0, nullptr, &size)); + urPlatformGetInfo(nullptr, getParam(), 0, nullptr, &size)); } -TEST_F(urPlatformGetInfoTest, InvalidEnumerationPlatformInfoType) { +using urPlatformGetInfoNegativeTest = uur::urPlatformTest; +UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urPlatformGetInfoNegativeTest); + +TEST_P(urPlatformGetInfoNegativeTest, InvalidEnumerationPlatformInfoType) { size_t size = 0; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, urPlatformGetInfo(platform, UR_PLATFORM_INFO_FORCE_UINT32, 0, nullptr, &size)); } -TEST_F(urPlatformGetInfoTest, InvalidSizeZero) { +TEST_P(urPlatformGetInfoNegativeTest, InvalidSizeZero) { ur_platform_backend_t backend; ASSERT_EQ_RESULT(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND, 0, &backend, nullptr), UR_RESULT_ERROR_INVALID_SIZE); } -TEST_F(urPlatformGetInfoTest, InvalidSizeSmall) { +TEST_P(urPlatformGetInfoNegativeTest, InvalidSizeSmall) { ur_platform_backend_t backend; ASSERT_EQ_RESULT(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND, sizeof(backend) - 1, &backend, nullptr), UR_RESULT_ERROR_INVALID_SIZE); } -TEST_F(urPlatformGetInfoTest, InvalidNullPointerPropValue) { +TEST_P(urPlatformGetInfoNegativeTest, InvalidNullPointerPropValue) { ur_platform_backend_t backend; ASSERT_EQ_RESULT(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND, sizeof(backend), nullptr, nullptr), UR_RESULT_ERROR_INVALID_NULL_POINTER); } -TEST_F(urPlatformGetInfoTest, InvalidNullPointerPropSizeRet) { +TEST_P(urPlatformGetInfoNegativeTest, InvalidNullPointerPropSizeRet) { ASSERT_EQ_RESULT(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND, 0, nullptr, nullptr), UR_RESULT_ERROR_INVALID_NULL_POINTER); diff --git a/test/conformance/platform/urPlatformGetNativeHandle.cpp b/test/conformance/platform/urPlatformGetNativeHandle.cpp index 305eed5eda..ba4e29986f 100644 --- a/test/conformance/platform/urPlatformGetNativeHandle.cpp +++ b/test/conformance/platform/urPlatformGetNativeHandle.cpp @@ -3,28 +3,25 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include "fixtures.h" +#include -using urPlatformGetNativeHandleTest = uur::platform::urPlatformsTest; +using urPlatformGetNativeHandleTest = uur::urPlatformTest; +UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urPlatformGetNativeHandleTest); -TEST_F(urPlatformGetNativeHandleTest, Success) { - for (auto platform : platforms) { - ur_native_handle_t native_handle = 0; - if (auto error = urPlatformGetNativeHandle(platform, &native_handle)) { - ASSERT_EQ(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); - } +TEST_P(urPlatformGetNativeHandleTest, Success) { + ur_native_handle_t native_handle = 0; + if (auto error = urPlatformGetNativeHandle(platform, &native_handle)) { + ASSERT_EQ(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); } } -TEST_F(urPlatformGetNativeHandleTest, InvalidNullHandlePlatform) { +TEST_P(urPlatformGetNativeHandleTest, InvalidNullHandlePlatform) { ur_native_handle_t native_handle = 0; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urPlatformGetNativeHandle(nullptr, &native_handle)); } -TEST_F(urPlatformGetNativeHandleTest, InvalidNullPointerNativePlatform) { - for (auto platform : platforms) { - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, - urPlatformGetNativeHandle(platform, nullptr)); - } +TEST_P(urPlatformGetNativeHandleTest, InvalidNullPointerNativePlatform) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urPlatformGetNativeHandle(platform, nullptr)); } diff --git a/test/conformance/source/environment.cpp b/test/conformance/source/environment.cpp index e1d1951616..037ab4c882 100644 --- a/test/conformance/source/environment.cpp +++ b/test/conformance/source/environment.cpp @@ -145,6 +145,7 @@ void uur::PlatformEnvironment::selectPlatformFromOptions() { urPlatformGet(&a, 1, count, platform_list.data(), nullptr)); for (auto p : platform_list) { + all_platforms.push_back(p); ur_platform_backend_t backend; ASSERT_SUCCESS(urPlatformGetInfo(p, UR_PLATFORM_INFO_BACKEND, sizeof(ur_platform_backend_t), diff --git a/test/conformance/testing/include/uur/environment.h b/test/conformance/testing/include/uur/environment.h index 397858333f..3d6c2cc0e4 100644 --- a/test/conformance/testing/include/uur/environment.h +++ b/test/conformance/testing/include/uur/environment.h @@ -42,6 +42,9 @@ struct PlatformEnvironment : AdapterEnvironment { PlatformOptions parsePlatformOptions(int argc, char **argv); PlatformOptions platform_options; + // List of all discovered platforms + std::vector all_platforms; + // Adapter and platform selected for testing via platform_options ur_adapter_handle_t adapter = nullptr; ur_platform_handle_t platform = nullptr; static PlatformEnvironment *instance; diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 5a409e465c..42896314cc 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -42,7 +42,10 @@ struct urAdapterTest : ::testing::Test, ur_adapter_handle_t adapter; }; -struct urPlatformTest : ::testing::Test { +// Inherit this to get the platform/adapter that was selected via the --backend +// and --platform arguments (or defaulted to if only one platform was +// discovered) +struct urSelectedPlatformTest : ::testing::Test { void SetUp() override { platform = uur::PlatformEnvironment::instance->platform; adapter = uur::PlatformEnvironment::instance->adapter; @@ -52,6 +55,17 @@ struct urPlatformTest : ::testing::Test { ur_adapter_handle_t adapter = nullptr; }; +// In the vein of urAdapterTest and urDeviceTest this is a parameterized +// platform fixture which can be instantiated via +// UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P to run tests on each discovered +// platform. +struct urPlatformTest : ::testing::Test, + ::testing::WithParamInterface { + void SetUp() override { platform = GetParam(); } + + ur_platform_handle_t platform = nullptr; +}; + inline std::pair> GetDevices(ur_platform_handle_t platform) { uint32_t count = 0; @@ -77,9 +91,9 @@ inline bool hasDevicePartitionSupport(ur_device_handle_t device, properties.end(); } -struct urAllDevicesTest : urPlatformTest { +struct urAllDevicesTest : urSelectedPlatformTest { void SetUp() override { - UUR_RETURN_ON_FATAL_FAILURE(urPlatformTest::SetUp()); + UUR_RETURN_ON_FATAL_FAILURE(urSelectedPlatformTest::SetUp()); auto devicesPair = GetDevices(platform); if (!devicesPair.first) { FAIL() << "Failed to get devices"; @@ -91,23 +105,23 @@ struct urAllDevicesTest : urPlatformTest { for (auto &device : devices) { EXPECT_SUCCESS(urDeviceRelease(device)); } - UUR_RETURN_ON_FATAL_FAILURE(urPlatformTest::TearDown()); + UUR_RETURN_ON_FATAL_FAILURE(urSelectedPlatformTest::TearDown()); } std::vector devices; }; -struct urDeviceTest : urPlatformTest, +struct urDeviceTest : urSelectedPlatformTest, ::testing::WithParamInterface { void SetUp() override { - UUR_RETURN_ON_FATAL_FAILURE(urPlatformTest::SetUp()); + UUR_RETURN_ON_FATAL_FAILURE(urSelectedPlatformTest::SetUp()); device = GetParam(); EXPECT_SUCCESS(urDeviceRetain(device)); } void TearDown() override { EXPECT_SUCCESS(urDeviceRelease(device)); - UUR_RETURN_ON_FATAL_FAILURE(urPlatformTest::TearDown()); + UUR_RETURN_ON_FATAL_FAILURE(urSelectedPlatformTest::SetUp()); } ur_device_handle_t device; @@ -122,6 +136,15 @@ struct urDeviceTest : urPlatformTest, return uur::GetAdapterBackendName(info.param); \ }) +#define UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(FIXTURE) \ + INSTANTIATE_TEST_SUITE_P( \ + , FIXTURE, \ + ::testing::ValuesIn( \ + uur::PlatformEnvironment::instance->all_platforms), \ + [](const ::testing::TestParamInfo &info) { \ + return uur::GetPlatformNameWithID(info.param); \ + }) + #define UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(FIXTURE) \ INSTANTIATE_TEST_SUITE_P( \ , FIXTURE, \ @@ -142,10 +165,10 @@ namespace uur { template struct urDeviceTestWithParam - : urPlatformTest, + : urSelectedPlatformTest, ::testing::WithParamInterface> { void SetUp() override { - UUR_RETURN_ON_FATAL_FAILURE(urPlatformTest::SetUp()); + UUR_RETURN_ON_FATAL_FAILURE(urSelectedPlatformTest::SetUp()); device = std::get<0>(this->GetParam()); } // TODO - I don't like the confusion with GetParam(); @@ -561,9 +584,9 @@ struct urMultiQueueTestWithParam : urContextTestWithParam { }; template -struct urMultiDeviceContextTestTemplate : urPlatformTest { +struct urMultiDeviceContextTestTemplate : urSelectedPlatformTest { void SetUp() override { - UUR_RETURN_ON_FATAL_FAILURE(urPlatformTest::SetUp()); + UUR_RETURN_ON_FATAL_FAILURE(urSelectedPlatformTest::SetUp()); auto &devices = DevicesEnvironment::instance->devices; if (devices.size() < MinDevices) { GTEST_SKIP(); @@ -576,7 +599,7 @@ struct urMultiDeviceContextTestTemplate : urPlatformTest { if (context) { ASSERT_SUCCESS(urContextRelease(context)); } - UUR_RETURN_ON_FATAL_FAILURE(urPlatformTest::TearDown()); + UUR_RETURN_ON_FATAL_FAILURE(urSelectedPlatformTest::TearDown()); } ur_context_handle_t context = nullptr; diff --git a/test/conformance/testing/include/uur/utils.h b/test/conformance/testing/include/uur/utils.h index 2415e580c5..76b0cfe31d 100644 --- a/test/conformance/testing/include/uur/utils.h +++ b/test/conformance/testing/include/uur/utils.h @@ -190,6 +190,15 @@ inline std::string GetPlatformName(ur_platform_handle_t hPlatform) { std::string(platform_name.data(), platform_name.size())); } +inline std::string GetPlatformNameWithID(ur_platform_handle_t hPlatform) { + auto platform_name = GetPlatformName(hPlatform); + auto &platforms = uur::PlatformEnvironment::instance->all_platforms; + size_t platform_id = + std::find(platforms.begin(), platforms.end(), hPlatform) - + platforms.begin(); + return platform_name + "_ID" + std::to_string(platform_id); +} + inline std::string GetDeviceName(ur_device_handle_t device) { std::string device_name, device_uuid; GetDeviceInfo(device, UR_DEVICE_INFO_NAME, device_name);