Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable platform CTS tests to run on all available platforms. #2409

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/adapters/cuda/urDeviceCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "fixtures.h"

using urCudaDeviceCreateWithNativeHandle = uur::urPlatformTest;
using urCudaDeviceCreateWithNativeHandle = uur::urSelectedPlatformTest;

TEST_F(urCudaDeviceCreateWithNativeHandle, Success) {
// get a device from cuda
Expand Down
75 changes: 38 additions & 37 deletions test/conformance/device/urDeviceGet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#include <uur/fixtures.h>

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));
Expand All @@ -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));
Expand All @@ -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<ur_device_handle_t> 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<ur_device_type_t> {
Expand Down Expand Up @@ -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<ur_device_handle_t> 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));
}
41 changes: 21 additions & 20 deletions test/conformance/device/urDeviceGetSelected.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
#include <uur/fixtures.h>

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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -99,23 +100,23 @@ 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(
urDeviceGetSelected(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
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(
urDeviceGetSelected(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
ASSERT_EQ(count, 0);
}

TEST_F(urDeviceGetSelectedTest,
TEST_P(urDeviceGetSelectedTest,
SuccessSelected_SelectSomethingAndDiscardSomethingElse) {
setenv("ONEAPI_DEVICE_SELECTOR", "*:0;!*:1", 1);
uint32_t count = 0;
Expand All @@ -130,23 +131,23 @@ TEST_F(urDeviceGetSelectedTest,
}
}

TEST_F(urDeviceGetSelectedTest, InvalidNullHandlePlatform) {
TEST_P(urDeviceGetSelectedTest, InvalidNullHandlePlatform) {
unsetenv("ONEAPI_DEVICE_SELECTOR");
uint32_t count = 0;
ASSERT_EQ_RESULT(
UR_RESULT_ERROR_INVALID_NULL_HANDLE,
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,
urDeviceGetSelected(platform, UR_DEVICE_TYPE_FORCE_UINT32,
0, nullptr, &count));
}

TEST_F(urDeviceGetSelectedTest, InvalidValueNumEntries) {
TEST_P(urDeviceGetSelectedTest, InvalidValueNumEntries) {
unsetenv("ONEAPI_DEVICE_SELECTOR");
uint32_t count = 0;
ASSERT_SUCCESS(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -224,23 +225,23 @@ 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(
urDeviceGetSelected(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
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(
urDeviceGetSelected(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ struct urMultiDeviceContextMemBufferTest : urMultiDeviceContextTest {
std::vector<ur_kernel_handle_t> kernels;
std::vector<ur_program_metadata_t> metadatas{};
};
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urMultiDeviceContextMemBufferTest);

TEST_F(urMultiDeviceContextMemBufferTest, WriteRead) {
TEST_P(urMultiDeviceContextMemBufferTest, WriteRead) {
if (num_devices == 1) {
GTEST_SKIP();
}
Expand All @@ -173,7 +174,7 @@ TEST_F(urMultiDeviceContextMemBufferTest, WriteRead) {
}
}

TEST_F(urMultiDeviceContextMemBufferTest, FillRead) {
TEST_P(urMultiDeviceContextMemBufferTest, FillRead) {
if (num_devices == 1) {
GTEST_SKIP();
}
Expand All @@ -197,7 +198,7 @@ TEST_F(urMultiDeviceContextMemBufferTest, FillRead) {
}
}

TEST_F(urMultiDeviceContextMemBufferTest, WriteKernelRead) {
TEST_P(urMultiDeviceContextMemBufferTest, WriteKernelRead) {
if (num_devices == 1) {
GTEST_SKIP();
}
Expand Down Expand Up @@ -233,7 +234,7 @@ TEST_F(urMultiDeviceContextMemBufferTest, WriteKernelRead) {
}
}

TEST_F(urMultiDeviceContextMemBufferTest, WriteKernelKernelRead) {
TEST_P(urMultiDeviceContextMemBufferTest, WriteKernelKernelRead) {
if (num_devices == 1) {
GTEST_SKIP();
}
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading