mirror of
https://github.com/BLAKE3-team/BLAKE3
synced 2024-04-30 12:05:08 +02:00
test_miri_smoketest
This commit is contained in:
parent
d57818afdc
commit
5b9af1c347
|
@ -336,3 +336,16 @@ jobs:
|
|||
run: cmake -S c -B c/build -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/target
|
||||
- name: CMake build / install
|
||||
run: cmake --build c/build --target install
|
||||
|
||||
miri_smoketest:
|
||||
name: Miri smoketest
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@nightly
|
||||
with:
|
||||
components: miri
|
||||
# Currently the test search "miri" only matches "test_miri_smoketest", but
|
||||
# we might add more. If this accidentally picks up anything incompatible or
|
||||
# slow, we can narrow it.
|
||||
- run: cargo miri test miri
|
||||
|
|
18
src/test.rs
18
src/test.rs
|
@ -818,3 +818,21 @@ fn test_serde() {
|
|||
let hash2: crate::Hash = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(hash, hash2);
|
||||
}
|
||||
|
||||
// `cargo +nightly miri test` currently works, but it takes forever, because some of our test
|
||||
// inputs are quite large. Most of our unsafe code is platform specific and incompatible with Miri
|
||||
// anyway, but we'd like it to be possible for callers to run their own tests under Miri, assuming
|
||||
// they don't use incompatible features like Rayon or mmap. This test should get reasonable
|
||||
// coverage of our public API without using any large inputs, so we can run it in CI and catch
|
||||
// obvious breaks. (For example, constant_time_eq is not compatible with Miri.)
|
||||
#[test]
|
||||
fn test_miri_smoketest() {
|
||||
let mut hasher = crate::Hasher::new_derive_key("Miri smoketest");
|
||||
hasher.update(b"foo");
|
||||
#[cfg(feature = "std")]
|
||||
hasher.update_reader(&b"bar"[..]).unwrap();
|
||||
assert_eq!(hasher.finalize(), hasher.finalize());
|
||||
let mut reader = hasher.finalize_xof();
|
||||
reader.set_position(999999);
|
||||
reader.fill(&mut [0]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue