aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack O'Connor <[email protected]>2021-11-05 00:17:05 -0400
committerJack O'Connor <[email protected]>2021-11-05 00:17:05 -0400
commite99922f16574973c505a0113ca4c306acf34c327 (patch)
treed16565ea8524be51b3d5cf96dcdf1264ca9ba954
parent04571021fb5490d0f0008c5b5a968f221de159a0 (diff)
add a test that triggers a failure in the SSE2 asm impl on Windowstrigger_sse2
A regular `cargo test` will pass this, but if you force SSE2 with the following command, it will fail: cargo test --features=no_avx512,no_avx2,no_sse41 --release
-rw-r--r--src/test.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test.rs b/src/test.rs
index cbe0188..be5f66f 100644
--- a/src/test.rs
+++ b/src/test.rs
@@ -564,3 +564,23 @@ fn test_hex_encoding_decoding() {
#[cfg(feature = "std")]
assert_eq!(_result.to_string(), "invalid hex character: 0x80");
}
+
+#[test]
+fn test_trigger_sse2() {
+ // This stupid loop has to be here. I don't know why.
+ for _ in &[0] {
+ // The length 65 (two blocks) is significant. It doesn't repro with 64 (one block).
+ // It also doesn't repro with an all-zero input.
+ let input = &[0xff; 65];
+ let expected_hash = [
+ 183, 235, 50, 217, 156, 24, 190, 219, 2, 216, 176, 255, 224, 53, 28, 95, 57, 148, 179,
+ 245, 162, 90, 37, 121, 0, 142, 219, 62, 234, 204, 225, 161,
+ ];
+
+ // This throwaway call has to be here to trigger the bug.
+ crate::Hasher::new().update(input);
+
+ // This assert fails.
+ assert_eq!(crate::Hasher::new().update(input).finalize(), expected_hash);
+ }
+}