rust/tests/ui/sse2.rs
Josh Stone 706f06c39a Use an explicit x86-64 cpu in tests that are sensitive to it
There are a few tests that depend on some target features **not** being
enabled by default, and usually they are correct with the default x86-64
target CPU. However, in downstream builds we have modified the default
to fit our distros -- `x86-64-v2` in RHEL 9 and `x86-64-v3` in RHEL 10
-- and the latter especially trips tests that expect not to have AVX.

These cases are few enough that we can just set them back explicitly.
2024-05-01 15:25:26 -07:00

26 lines
754 B
Rust

//@ run-pass
#![allow(stable_features)]
#![feature(cfg_target_feature)]
use std::env;
fn main() {
match env::var("TARGET") {
Ok(s) => {
// Skip this tests on i586-unknown-linux-gnu where sse2 is disabled
if s.contains("i586") {
return
}
}
Err(_) => return,
}
if cfg!(any(target_arch = "x86", target_arch = "x86_64")) {
assert!(cfg!(target_feature = "sse2"),
"SSE2 was not detected as available on an x86 platform");
}
// check a negative case too -- allowed on x86, but not enabled by default
assert!(cfg!(not(target_feature = "avx512f")),
"AVX512 shouldn't be detected as available by default on any platform");
}