Skip to content

Commit 03e9793

Browse files
authored
Merge pull request rust-lang#48 from alexcrichton/assert-detection-correct
Add a test for x86 runtime support
2 parents d93e1d2 + 3f72e3a commit 03e9793

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ opt-level = 3
2020

2121
[dev-dependencies]
2222
stdsimd-test = { path = "stdsimd-test" }
23+
cupid = "0.3"

tests/cpu-detection.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#![feature(cfg_target_feature)]
2+
3+
#[macro_use]
4+
extern crate stdsimd;
5+
extern crate cupid;
6+
7+
#[test]
8+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
9+
fn works() {
10+
let information = cupid::master().unwrap();
11+
assert_eq!(cfg_feature_enabled!("sse"), information.sse());
12+
assert_eq!(cfg_feature_enabled!("sse2"), information.sse2());
13+
assert_eq!(cfg_feature_enabled!("sse3"), information.sse3());
14+
assert_eq!(cfg_feature_enabled!("ssse3"), information.ssse3());
15+
assert_eq!(cfg_feature_enabled!("sse4.1"), information.sse4_1());
16+
assert_eq!(cfg_feature_enabled!("sse4.2"), information.sse4_2());
17+
assert_eq!(cfg_feature_enabled!("avx"), information.avx());
18+
assert_eq!(cfg_feature_enabled!("avx2"), information.avx2());
19+
assert_eq!(cfg_feature_enabled!("fma"), information.fma());
20+
assert_eq!(cfg_feature_enabled!("bmi"), information.bmi1());
21+
assert_eq!(cfg_feature_enabled!("bmi2"), information.bmi2());
22+
assert_eq!(cfg_feature_enabled!("popcnt"), information.popcnt());
23+
24+
// TODO: tbm, abm, lzcnt
25+
}

0 commit comments

Comments
 (0)