Skip to content

Commit

Permalink
Test XRay only for supported targets
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ilammy committed Feb 9, 2023
1 parent 3561dc9 commit 54b26f4
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ pub fn make_test_description<R: Read>(
let has_hwasan = util::HWASAN_SUPPORTED_TARGETS.contains(&&*config.target);
let has_memtag = util::MEMTAG_SUPPORTED_TARGETS.contains(&&*config.target);
let has_shadow_call_stack = util::SHADOWCALLSTACK_SUPPORTED_TARGETS.contains(&&*config.target);
let has_xray = util::XRAY_SUPPORTED_TARGETS.contains(&&*config.target);

// For tests using the `needs-rust-lld` directive (e.g. for `-Zgcc-ld=lld`), we need to find
// whether `rust-lld` is present in the compiler under test.
Expand Down Expand Up @@ -1019,6 +1020,7 @@ pub fn make_test_description<R: Read>(
&& config.parse_name_directive(ln, "needs-sanitizer-shadow-call-stack")
);
reason!(!config.can_unwind() && config.parse_name_directive(ln, "needs-unwind"));
reason!(!has_xray && config.parse_name_directive(ln, "needs-xray"));
reason!(
config.target == "wasm32-unknown-unknown"
&& config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS)
Expand Down
13 changes: 13 additions & 0 deletions src/tools/compiletest/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ pub const MEMTAG_SUPPORTED_TARGETS: &[&str] =

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

pub const XRAY_SUPPORTED_TARGETS: &[&str] = &[
"aarch64-linux-android",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"x86_64-linux-android",
"x86_64-unknown-freebsd",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl",
"x86_64-unknown-netbsd",
"x86_64-unknown-none-linuxkernel",
"x86_64-unknown-openbsd",
];

pub fn make_new_path(path: &str) -> String {
assert!(cfg!(windows));
// Windows just uses PATH as the library search path, so we have to
Expand Down
1 change: 1 addition & 0 deletions tests/codegen/instrument-xray/basic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Checks that `-Z instrument-xray` produces expected instrumentation.
//
// needs-xray
// compile-flags: -Z instrument-xray=always

#![crate_type = "lib"]
Expand Down
1 change: 1 addition & 0 deletions tests/codegen/instrument-xray/options-combine.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Checks that `-Z instrument-xray` options can be specified multiple times.
//
// needs-xray
// compile-flags: -Z instrument-xray=skip-exit
// compile-flags: -Z instrument-xray=instruction-threshold=123
// compile-flags: -Z instrument-xray=instruction-threshold=456
Expand Down
1 change: 1 addition & 0 deletions tests/codegen/instrument-xray/options-override.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Checks that the last `-Z instrument-xray` option wins.
//
// needs-xray
// compile-flags: -Z instrument-xray=always
// compile-flags: -Z instrument-xray=never

Expand Down
1 change: 1 addition & 0 deletions tests/ui/instrument-xray/flags-always-never-1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Checks that `-Z instrument-xray` does not allow `always` and `never` simultaneously.
//
// needs-xray
// compile-flags: -Z instrument-xray=always,never
// error-pattern: incorrect value `always,never` for unstable option `instrument-xray`

Expand Down
1 change: 1 addition & 0 deletions tests/ui/instrument-xray/flags-always-never-2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Checks that `-Z instrument-xray` allows `always` and `never` sequentially.
// (The last specified setting wins, like `-Z instrument-xray=no` as well.)
//
// needs-xray
// compile-flags: -Z instrument-xray=always
// compile-flags: -Z instrument-xray=never
// check-pass
Expand Down
1 change: 1 addition & 0 deletions tests/ui/instrument-xray/flags-basic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Verifies basic `-Z instrument-xray` flags.
//
// needs-xray
// compile-flags: -Z instrument-xray
// compile-flags: -Z instrument-xray=skip-exit
// compile-flags: -Z instrument-xray=ignore-loops,instruction-threshold=300
Expand Down
1 change: 1 addition & 0 deletions tests/ui/instrument-xray/flags-dupe-always.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Checks that `-Z instrument-xray` does not allow duplicates.
//
// needs-xray
// compile-flags: -Z instrument-xray=always,always
// error-pattern: incorrect value `always,always` for unstable option `instrument-xray`

Expand Down
1 change: 1 addition & 0 deletions tests/ui/instrument-xray/flags-dupe-ignore-loops.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Checks that `-Z instrument-xray` does not allow duplicates.
//
// needs-xray
// compile-flags: -Z instrument-xray=ignore-loops,ignore-loops
// error-pattern: incorrect value `ignore-loops,ignore-loops` for unstable option `instrument-xray`

Expand Down

0 comments on commit 54b26f4

Please sign in to comment.