Skip to content

Commit ba57ce9

Browse files
committed
Add CTS macro for marking tests as known failures in code
The new `UUR_KNOWN_FAILURE_ON` macro can be used to skip tests on devices where the test is known to fail. This can be done for a devices in an adapter or by substring match of the device name. For example: ```cpp UUR_KNOWN_FAILURE_ON(uur::OpenCL{"Intel(R) UHD Graphics 770"}); ``` This invocation is also used in a few places in order to have clean CTS runs on machines with this iGPU.
1 parent c6206db commit ba57ce9

File tree

6 files changed

+113
-3
lines changed

6 files changed

+113
-3
lines changed

test/conformance/kernel/urKernelSetArgValue.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See LICENSE.TXT
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6+
#include "uur/known_failure.h"
67
#include <uur/fixtures.h>
78

89
struct urKernelSetArgValueTest : uur::urKernelTest {
@@ -45,6 +46,7 @@ TEST_P(urKernelSetArgValueTest, InvalidKernelArgumentIndex) {
4546
}
4647

4748
TEST_P(urKernelSetArgValueTest, InvalidKernelArgumentSize) {
49+
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"Intel(R) UHD Graphics 770"});
4850
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE,
4951
urKernelSetArgValue(kernel, 2, 0, nullptr, &arg_value));
5052
}

test/conformance/memory/urMemImageCreate.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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 "uur/known_failure.h"
56
#include <uur/fixtures.h>
67
#include <uur/raii.h>
78

@@ -188,6 +189,7 @@ TEST_P(urMemImageCreateTest, InvalidNullPointerImageFormat) {
188189
}
189190

190191
TEST_P(urMemImageCreateTest, InvalidSize) {
192+
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"Intel(R) UHD Graphics 770"});
191193

192194
uur::raii::Mem image_handle = nullptr;
193195

test/conformance/memory/urMemImageCreateWithImageFormatParam.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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 "uur/known_failure.h"
56
#include <uur/fixtures.h>
67
#include <vector>
78

@@ -90,6 +91,7 @@ UUR_TEST_SUITE_P(
9091
uur::deviceTestWithParamPrinter<ur_image_format_t>);
9192

9293
TEST_P(urMemImageCreateTestWithImageFormatParam, Success) {
94+
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"Intel(R) UHD Graphics 770"});
9395
ur_image_channel_order_t channel_order =
9496
std::get<1>(GetParam()).channelOrder;
9597
ur_image_channel_type_t channel_type = std::get<1>(GetParam()).channelType;

test/conformance/program/urProgramGetFunctionPointer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See LICENSE.TXT
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6+
#include "uur/known_failure.h"
67
#include <uur/fixtures.h>
78

89
struct urProgramGetFunctionPointerTest : uur::urProgramTest {
@@ -20,6 +21,7 @@ struct urProgramGetFunctionPointerTest : uur::urProgramTest {
2021
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramGetFunctionPointerTest);
2122

2223
TEST_P(urProgramGetFunctionPointerTest, Success) {
24+
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"Intel(R) UHD Graphics 770"});
2325
void *function_pointer = nullptr;
2426
ASSERT_SUCCESS(urProgramGetFunctionPointer(
2527
device, program, function_name.data(), &function_pointer));
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Copyright (C) 2024 Intel Corporation
2+
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
3+
// See LICENSE.TXT
4+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
#ifndef UR_CONFORMANCE_INCLUDE_KNOWN_FAILURE_H_INCLUDED
7+
#define UR_CONFORMANCE_INCLUDE_KNOWN_FAILURE_H_INCLUDED
8+
9+
#include "uur/utils.h"
10+
#include <string>
11+
#include <vector>
12+
13+
namespace uur {
14+
struct DeviceMatcher {
15+
DeviceMatcher(uint32_t adapterVersion, ur_platform_backend_t backend,
16+
std::vector<std::string> deviceNames)
17+
: adapterVersion(adapterVersion), backend(backend),
18+
deviceNames(deviceNames) {}
19+
20+
uint32_t adapterVersion;
21+
ur_platform_backend_t backend;
22+
std::vector<std::string> deviceNames;
23+
};
24+
25+
struct OpenCL : DeviceMatcher {
26+
OpenCL(std::initializer_list<std::string> il)
27+
: DeviceMatcher(1, UR_PLATFORM_BACKEND_OPENCL, {il.begin(), il.end()}) {
28+
}
29+
};
30+
31+
struct LevelZero : DeviceMatcher {
32+
LevelZero(std::initializer_list<std::string> il)
33+
: DeviceMatcher(1, UR_PLATFORM_BACKEND_LEVEL_ZERO,
34+
{il.begin(), il.end()}) {}
35+
};
36+
37+
struct LevelZeroV2 : DeviceMatcher {
38+
LevelZeroV2(std::initializer_list<std::string> il)
39+
: DeviceMatcher(2, UR_PLATFORM_BACKEND_LEVEL_ZERO,
40+
{il.begin(), il.end()}) {}
41+
};
42+
43+
struct CUDA : DeviceMatcher {
44+
CUDA(std::initializer_list<std::string> il)
45+
: DeviceMatcher(1, UR_PLATFORM_BACKEND_CUDA, {il.begin(), il.end()}) {}
46+
};
47+
48+
struct HIP : DeviceMatcher {
49+
HIP(std::initializer_list<std::string> il)
50+
: DeviceMatcher(1, UR_PLATFORM_BACKEND_HIP, {il.begin(), il.end()}) {}
51+
};
52+
53+
struct NativeCPU : DeviceMatcher {
54+
NativeCPU(std::initializer_list<std::string> il)
55+
: DeviceMatcher(1, UR_PLATFORM_BACKEND_NATIVE_CPU,
56+
{il.begin(), il.end()}) {}
57+
};
58+
59+
inline bool isKnownFailureOn(ur_adapter_handle_t adapter,
60+
ur_platform_handle_t platform,
61+
ur_device_handle_t device,
62+
std::vector<DeviceMatcher> deviceMatchers) {
63+
for (const auto &deviceMatcher : deviceMatchers) {
64+
uint32_t adapterVersion = 0;
65+
urAdapterGetInfo(adapter, UR_ADAPTER_INFO_VERSION,
66+
sizeof(adapterVersion), &adapterVersion, nullptr);
67+
ur_platform_backend_t backend = UR_PLATFORM_BACKEND_UNKNOWN;
68+
uur::GetPlatformInfo<ur_platform_backend_t>(
69+
platform, UR_PLATFORM_INFO_BACKEND, backend);
70+
if (deviceMatcher.adapterVersion != adapterVersion &&
71+
deviceMatcher.backend != backend) {
72+
continue;
73+
}
74+
if (deviceMatcher.deviceNames.empty()) {
75+
return true;
76+
}
77+
std::string deviceName;
78+
uur::GetDeviceInfo<std::string>(device, UR_DEVICE_INFO_NAME,
79+
deviceName);
80+
for (const auto &unsupportedDeviceName : deviceMatcher.deviceNames) {
81+
if (deviceName.find(unsupportedDeviceName) != std::string::npos) {
82+
return true;
83+
}
84+
}
85+
}
86+
return false;
87+
}
88+
} // namespace uur
89+
90+
#define UUR_KNOWN_FAILURE_ON(...) \
91+
if (uur::isKnownFailureOn(adapter, platform, device, {__VA_ARGS__})) { \
92+
std::string platformName; \
93+
uur::GetPlatformInfo<std::string>(platform, UR_PLATFORM_INFO_NAME, \
94+
platformName); \
95+
std::string deviceName; \
96+
uur::GetDeviceInfo<std::string>(device, UR_DEVICE_INFO_NAME, \
97+
deviceName); \
98+
GTEST_SKIP() << "Known failure on: " << platformName << ", " \
99+
<< deviceName; \
100+
}
101+
102+
#endif // UR_CONFORMANCE_INCLUDE_KNOWN_FAILURE_H_INCLUDED

test/conformance/testing/include/uur/utils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ ur_result_t GetInfo(ObjectTy object, InfoTy info, Callable cb, T &out_value) {
4343

4444
// special case for strings
4545
if constexpr (std::is_same_v<std::string, T>) {
46-
std::vector<char> data(size);
47-
result = cb(object, info, size, data.data(), nullptr);
46+
std::string value(size, '\0');
47+
result = cb(object, info, size, value.data(), nullptr);
4848
if (result != UR_RESULT_SUCCESS) {
4949
return result;
5050
}
51-
out_value = std::string(data.data(), data.size());
51+
out_value = value.substr(0, value.find_last_of('\0'));
5252
return UR_RESULT_SUCCESS;
5353
} else {
5454
if (size != sizeof(T)) {

0 commit comments

Comments
 (0)