Skip to content

Commit 54b26f4

Browse files
committed
Test XRay only for supported targets
Now that the compiler accepts "-Z instrument-xray" option only when targeting one of the supported targets, make sure to not run the codegen tests where the compiler will fail. Like with other compiletests, we don't have access to internals, so simply hardcode a list of supported architectures here.
1 parent 3561dc9 commit 54b26f4

File tree

10 files changed

+23
-0
lines changed

10 files changed

+23
-0
lines changed

src/tools/compiletest/src/header.rs

+2
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ pub fn make_test_description<R: Read>(
941941
let has_hwasan = util::HWASAN_SUPPORTED_TARGETS.contains(&&*config.target);
942942
let has_memtag = util::MEMTAG_SUPPORTED_TARGETS.contains(&&*config.target);
943943
let has_shadow_call_stack = util::SHADOWCALLSTACK_SUPPORTED_TARGETS.contains(&&*config.target);
944+
let has_xray = util::XRAY_SUPPORTED_TARGETS.contains(&&*config.target);
944945

945946
// For tests using the `needs-rust-lld` directive (e.g. for `-Zgcc-ld=lld`), we need to find
946947
// whether `rust-lld` is present in the compiler under test.
@@ -1019,6 +1020,7 @@ pub fn make_test_description<R: Read>(
10191020
&& config.parse_name_directive(ln, "needs-sanitizer-shadow-call-stack")
10201021
);
10211022
reason!(!config.can_unwind() && config.parse_name_directive(ln, "needs-unwind"));
1023+
reason!(!has_xray && config.parse_name_directive(ln, "needs-xray"));
10221024
reason!(
10231025
config.target == "wasm32-unknown-unknown"
10241026
&& config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS)

src/tools/compiletest/src/util.rs

+13
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ pub const MEMTAG_SUPPORTED_TARGETS: &[&str] =
7878

7979
pub const SHADOWCALLSTACK_SUPPORTED_TARGETS: &[&str] = &["aarch64-linux-android"];
8080

81+
pub const XRAY_SUPPORTED_TARGETS: &[&str] = &[
82+
"aarch64-linux-android",
83+
"aarch64-unknown-linux-gnu",
84+
"aarch64-unknown-linux-musl",
85+
"x86_64-linux-android",
86+
"x86_64-unknown-freebsd",
87+
"x86_64-unknown-linux-gnu",
88+
"x86_64-unknown-linux-musl",
89+
"x86_64-unknown-netbsd",
90+
"x86_64-unknown-none-linuxkernel",
91+
"x86_64-unknown-openbsd",
92+
];
93+
8194
pub fn make_new_path(path: &str) -> String {
8295
assert!(cfg!(windows));
8396
// Windows just uses PATH as the library search path, so we have to

tests/codegen/instrument-xray/basic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Checks that `-Z instrument-xray` produces expected instrumentation.
22
//
3+
// needs-xray
34
// compile-flags: -Z instrument-xray=always
45

56
#![crate_type = "lib"]

tests/codegen/instrument-xray/options-combine.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Checks that `-Z instrument-xray` options can be specified multiple times.
22
//
3+
// needs-xray
34
// compile-flags: -Z instrument-xray=skip-exit
45
// compile-flags: -Z instrument-xray=instruction-threshold=123
56
// compile-flags: -Z instrument-xray=instruction-threshold=456

tests/codegen/instrument-xray/options-override.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Checks that the last `-Z instrument-xray` option wins.
22
//
3+
// needs-xray
34
// compile-flags: -Z instrument-xray=always
45
// compile-flags: -Z instrument-xray=never
56

tests/ui/instrument-xray/flags-always-never-1.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Checks that `-Z instrument-xray` does not allow `always` and `never` simultaneously.
22
//
3+
// needs-xray
34
// compile-flags: -Z instrument-xray=always,never
45
// error-pattern: incorrect value `always,never` for unstable option `instrument-xray`
56

tests/ui/instrument-xray/flags-always-never-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Checks that `-Z instrument-xray` allows `always` and `never` sequentially.
22
// (The last specified setting wins, like `-Z instrument-xray=no` as well.)
33
//
4+
// needs-xray
45
// compile-flags: -Z instrument-xray=always
56
// compile-flags: -Z instrument-xray=never
67
// check-pass

tests/ui/instrument-xray/flags-basic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Verifies basic `-Z instrument-xray` flags.
22
//
3+
// needs-xray
34
// compile-flags: -Z instrument-xray
45
// compile-flags: -Z instrument-xray=skip-exit
56
// compile-flags: -Z instrument-xray=ignore-loops,instruction-threshold=300

tests/ui/instrument-xray/flags-dupe-always.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Checks that `-Z instrument-xray` does not allow duplicates.
22
//
3+
// needs-xray
34
// compile-flags: -Z instrument-xray=always,always
45
// error-pattern: incorrect value `always,always` for unstable option `instrument-xray`
56

tests/ui/instrument-xray/flags-dupe-ignore-loops.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Checks that `-Z instrument-xray` does not allow duplicates.
22
//
3+
// needs-xray
34
// compile-flags: -Z instrument-xray=ignore-loops,ignore-loops
45
// error-pattern: incorrect value `ignore-loops,ignore-loops` for unstable option `instrument-xray`
56

0 commit comments

Comments
 (0)