Skip to content

Commit 9b7fc3f

Browse files
committed
test: added simd_alignment_test
Test whether the size of `SimdBlock` agrees with the expected one for a given target.
1 parent 28d5fc4 commit 9b7fc3f

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

.cargo/config.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build]
2-
rustflags = "-C target-feature=+avx2"
2+
rustflags = "-C target-feature=+sse"
33

44
[alias]
55
testall = "hack test --feature-powerset --skip default"

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ cfg-if = "1.0.0"
1818
lazy_static = "1.4.0"
1919
page_size = "0.4.2"
2020

21+
[dev-dependencies]
22+
anyhow = "1.0.57"
23+
2124
[features]
2225
default = ["simd"]
2326
simd = []

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ aligners v0.0.1
6565
#### Dev
6666

6767
- `cargo-hack` – used for more robust testing by compiling and running the code for the feature powerset.
68+
- `anyhow` – used in the `simd_alignment_test` to make error handling easy.
6869

6970
## `crev`
7071

tests/simd_alignment_test.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#[cfg(feature = "simd")]
2+
mod tests {
3+
use anyhow::{bail, Result};
4+
5+
const EXPECTED_SWITCH_ENV_NAME: &str = "ALIGNERS_TEST_SIMD_EXPECTED_SIZE";
6+
7+
#[test]
8+
#[ignore]
9+
pub fn simd_alignment_test() {
10+
let verify = verify_simd_block_size();
11+
verify.unwrap();
12+
}
13+
14+
pub fn verify_simd_block_size() -> Result<()> {
15+
use aligners::alignment::{Alignment, SimdBlock};
16+
let expected_size: usize = std::env::var(EXPECTED_SWITCH_ENV_NAME)?.parse()?;
17+
let actual_size = SimdBlock::size();
18+
19+
if expected_size != actual_size {
20+
bail!(
21+
"Expected SIMD block size was '{}', but actual is '{}'",
22+
expected_size,
23+
actual_size
24+
);
25+
}
26+
27+
Ok(())
28+
}
29+
}

0 commit comments

Comments
 (0)