diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-04-13 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-04-13 00:00:00 +0000 |
| commit | da40e69b607814371a54fd389bffec054e8dd7dd (patch) | |
| tree | abf81800cf3637adf3d201170d87c48cff7cfa8e /src/tools | |
| parent | 58f32da346642ff3f50186f6f4a0de46e61008be (diff) | |
| download | rust-da40e69b607814371a54fd389bffec054e8dd7dd.tar.gz rust-da40e69b607814371a54fd389bffec054e8dd7dd.zip | |
Check for asm support in UI tests that require it
Add `needs-asm-support` compiletest directive, and use it in asm tests that require asm support without relying on any architecture specific features.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/compiletest/src/header.rs | 5 | ||||
| -rw-r--r-- | src/tools/compiletest/src/header/tests.rs | 11 | ||||
| -rw-r--r-- | src/tools/compiletest/src/util.rs | 9 |
3 files changed, 25 insertions, 0 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 531a23d76a2..363105a9f09 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -44,6 +44,7 @@ impl EarlyProps { let mut props = EarlyProps::default(); let rustc_has_profiler_support = env::var_os("RUSTC_PROFILER_SUPPORT").is_some(); let rustc_has_sanitizer_support = env::var_os("RUSTC_SANITIZER_SUPPORT").is_some(); + let has_asm_support = util::has_asm_support(&config.target); let has_asan = util::ASAN_SUPPORTED_TARGETS.contains(&&*config.target); let has_lsan = util::LSAN_SUPPORTED_TARGETS.contains(&&*config.target); let has_msan = util::MSAN_SUPPORTED_TARGETS.contains(&&*config.target); @@ -76,6 +77,10 @@ impl EarlyProps { props.ignore = true; } + if !has_asm_support && config.parse_name_directive(ln, "needs-asm-support") { + props.ignore = true; + } + if !rustc_has_profiler_support && config.parse_needs_profiler_support(ln) { props.ignore = true; } diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index ec99fde0df9..c41b43cdd0b 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -224,6 +224,17 @@ fn sanitizers() { } #[test] +fn asm_support() { + let mut config = config(); + + config.target = "avr-unknown-gnu-atmega328".to_owned(); + assert!(parse_rs(&config, "// needs-asm-support").ignore); + + config.target = "i686-unknown-netbsd".to_owned(); + assert!(!parse_rs(&config, "// needs-asm-support").ignore); +} + +#[test] fn test_extract_version_range() { use super::{extract_llvm_version, extract_version_range}; diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index b302953708c..7dbd70948b8 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -128,6 +128,15 @@ const BIG_ENDIAN: &[&str] = &[ "sparcv9", ]; +static ASM_SUPPORTED_ARCHS: &[&str] = &[ + "x86", "x86_64", "arm", "aarch64", "riscv32", "riscv64", "nvptx64", "hexagon", "mips", + "mips64", "spirv", "wasm32", +]; + +pub fn has_asm_support(triple: &str) -> bool { + ASM_SUPPORTED_ARCHS.contains(&get_arch(triple)) +} + pub fn matches_os(triple: &str, name: &str) -> bool { // For the wasm32 bare target we ignore anything also ignored on emscripten // and then we also recognize `wasm32-bare` as the os for the target |
