diff options
| author | Luca Barbato <lu_zero@gentoo.org> | 2019-09-17 17:55:45 +0200 |
|---|---|---|
| committer | Luca Barbato <lu_zero@gentoo.org> | 2019-09-17 19:22:18 +0200 |
| commit | efd19f4a133528d902fe7b565e2fa421f77973ec (patch) | |
| tree | 640bd0ce7989b405904f92e9e194e333ab24ef7c /library/stdarch/crates | |
| parent | b70d574394e360c87528fc65a44bd31082801cd3 (diff) | |
| download | rust-efd19f4a133528d902fe7b565e2fa421f77973ec.tar.gz rust-efd19f4a133528d902fe7b565e2fa421f77973ec.zip | |
Add a test for the env_override
Diffstat (limited to 'library/stdarch/crates')
| -rw-r--r-- | library/stdarch/crates/std_detect/src/detect/mod.rs | 7 | ||||
| -rw-r--r-- | library/stdarch/crates/std_detect/src/detect/os/x86.rs | 19 |
2 files changed, 26 insertions, 0 deletions
diff --git a/library/stdarch/crates/std_detect/src/detect/mod.rs b/library/stdarch/crates/std_detect/src/detect/mod.rs index 6389a3fd75b..748299f7f84 100644 --- a/library/stdarch/crates/std_detect/src/detect/mod.rs +++ b/library/stdarch/crates/std_detect/src/detect/mod.rs @@ -135,3 +135,10 @@ pub fn features() -> impl Iterator<Item = (&'static str, bool)> { } impl_() } + +#[test] +fn features_roundtrip() { + for (f, _) in features() { + let _ = Feature::from_str(f).unwrap(); + } +} diff --git a/library/stdarch/crates/std_detect/src/detect/os/x86.rs b/library/stdarch/crates/std_detect/src/detect/os/x86.rs index c653771c435..9da3d77c50a 100644 --- a/library/stdarch/crates/std_detect/src/detect/os/x86.rs +++ b/library/stdarch/crates/std_detect/src/detect/os/x86.rs @@ -295,6 +295,25 @@ mod tests { println!("rtm: {:?}", is_x86_feature_detected!("rtm")); } + #[cfg(feature = "std_detect_env_override")] + #[test] + fn env_override_no_avx() { + if let Ok(disable) = crate::env::var("RUST_STD_DETECT_UNSTABLE") { + let information = cupid::master().unwrap(); + for d in disable.split(" ") { + match d { + "avx" => if information.avx() { + assert_ne!(is_x86_feature_detected!("avx"), information.avx()) + } + "avx2" => if information.avx2() { + assert_ne!(is_x86_feature_detected!("avx2"), information.avx2()) + } + _ => {} + } + } + } + } + #[test] fn compare_with_cupid() { let information = cupid::master().unwrap(); |
