Skip to content

Commit 0ea7e17

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 1c59bea commit 0ea7e17

File tree

6 files changed

+99
-3
lines changed

6 files changed

+99
-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/unsupported.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/unsupported.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/unsupported.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/unsupported.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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright (C) 2022-2023 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_UNSUPPORTED_H_INCLUDED
7+
#define UR_CONFORMANCE_INCLUDE_UNSUPPORTED_H_INCLUDED
8+
9+
#include "uur/utils.h"
10+
#include <string>
11+
#include <vector>
12+
13+
namespace uur {
14+
struct DeviceMatcher {
15+
DeviceMatcher(ur_platform_backend_t backend,
16+
std::vector<std::string> deviceNames)
17+
: backend(backend), deviceNames(deviceNames) {}
18+
19+
ur_platform_backend_t backend;
20+
std::vector<std::string> deviceNames;
21+
};
22+
23+
struct OpenCL : DeviceMatcher {
24+
OpenCL(std::initializer_list<std::string> il)
25+
: DeviceMatcher(UR_PLATFORM_BACKEND_OPENCL, {il.begin(), il.end()}) {}
26+
};
27+
28+
struct LevelZero : DeviceMatcher {
29+
LevelZero(std::initializer_list<std::string> il)
30+
: DeviceMatcher(UR_PLATFORM_BACKEND_LEVEL_ZERO,
31+
{il.begin(), il.end()}) {}
32+
};
33+
34+
struct CUDA : DeviceMatcher {
35+
CUDA(std::initializer_list<std::string> il)
36+
: DeviceMatcher(UR_PLATFORM_BACKEND_CUDA, {il.begin(), il.end()}) {}
37+
};
38+
39+
struct HIP : DeviceMatcher {
40+
HIP(std::initializer_list<std::string> il)
41+
: DeviceMatcher(UR_PLATFORM_BACKEND_HIP, {il.begin(), il.end()}) {}
42+
};
43+
44+
struct NativeCPU : DeviceMatcher {
45+
NativeCPU(std::initializer_list<std::string> il)
46+
: DeviceMatcher(UR_PLATFORM_BACKEND_NATIVE_CPU,
47+
{il.begin(), il.end()}) {}
48+
};
49+
50+
inline bool isKnownFailureOn(ur_platform_handle_t platform,
51+
ur_device_handle_t device,
52+
std::vector<DeviceMatcher> deviceMatchers) {
53+
for (const auto &deviceMatcher : deviceMatchers) {
54+
ur_platform_backend_t backend = UR_PLATFORM_BACKEND_UNKNOWN;
55+
uur::GetPlatformInfo<ur_platform_backend_t>(
56+
platform, UR_PLATFORM_INFO_BACKEND, backend);
57+
if (deviceMatcher.backend != backend) {
58+
continue;
59+
}
60+
if (deviceMatcher.deviceNames.empty()) {
61+
return true;
62+
}
63+
std::string deviceName;
64+
uur::GetDeviceInfo<std::string>(device, UR_DEVICE_INFO_NAME,
65+
deviceName);
66+
for (const auto &unsupportedDeviceName : deviceMatcher.deviceNames) {
67+
if (deviceName.find(unsupportedDeviceName) != std::string::npos) {
68+
return true;
69+
}
70+
}
71+
}
72+
return false;
73+
}
74+
} // namespace uur
75+
76+
#define UUR_KNOWN_FAILURE_ON(...) \
77+
if (uur::isKnownFailureOn(platform, device, {__VA_ARGS__})) { \
78+
std::string platformName; \
79+
uur::GetPlatformInfo<std::string>(platform, UR_PLATFORM_INFO_NAME, \
80+
platformName); \
81+
std::string deviceName; \
82+
uur::GetDeviceInfo<std::string>(device, UR_DEVICE_INFO_NAME, \
83+
deviceName); \
84+
GTEST_SKIP() << "Known failure on: " << platformName << ", " \
85+
<< deviceName; \
86+
}
87+
88+
#endif // UR_CONFORMANCE_INCLUDE_UNSUPPORTED_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)