Skip to content

Commit

Permalink
Less fragile miri tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Nov 6, 2024
1 parent 29282e2 commit 7b77a90
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,6 @@ jobs:
tool: cargo-nextest
- name: Test public C api with miri
run: |
cargo +nightly miri nextest run -j4 -p test-libbzip2-rs-sys -- \
--skip buff_to_buff_ --skip bzip2_testfiles::commons_compress_zip64support \
--skip bzip2_testfiles::dotnetzip_ --skip bzip2_testfiles::go \
--skip bzip2_testfiles::lbzip2_ch255 --skip bzip2_testfiles::lbzip2_fib \
--skip bzip2_testfiles::lbzip2_idx899999 --skip bzip2_testfiles::lbzip2_repet \
--skip bzip2_testfiles::pyflate_45MB_ --skip chunked:: --skip compress_sample1 \
--skip compress_sample2 --skip decompress_sample1 --skip decompress_sample2
cargo +nightly miri nextest run -j4 -p test-libbzip2-rs-sys miri_
- name: Run unit tests with miri
run: "cargo +nightly miri nextest run -j4 -p libbzip2-rs-sys"
58 changes: 29 additions & 29 deletions test-libbzip2-rs-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ macro_rules! assert_eq_compress {
}

#[test]
fn version() {
fn miri_version() {
let ptr = libbzip2_rs_sys::BZ2_bzlibVersion();
let cstr = unsafe { core::ffi::CStr::from_ptr(ptr) };
let string = cstr.to_str().unwrap();
Expand Down Expand Up @@ -229,7 +229,7 @@ fn decompress_sample2() {
}

#[test]
fn decompress_sample3() {
fn miri_decompress_sample3() {
assert_eq_decompress!("../../tests/input/quick/sample3.bz2");
}

Expand All @@ -244,7 +244,7 @@ fn compress_sample2() {
}

#[test]
fn compress_sample3() {
fn miri_compress_sample3() {
assert_eq_compress!("../../tests/input/quick/sample3.bz2");
}

Expand Down Expand Up @@ -595,18 +595,18 @@ mod bzip2_testfiles {

use super::*;

#[test] fn pyflate_765B() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/pyflate/765B.bz2"); }
#[test] fn miri_pyflate_765B() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/pyflate/765B.bz2"); }
#[test] fn pyflate_45MB_00() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/pyflate/45MB-00.bz2"); }
#[test] fn pyflate_hello_world() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/pyflate/hello-world.bz2"); }
#[test] fn pyflate_510B() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/pyflate/510B.bz2"); }
#[test] fn pyflate_aaa() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/pyflate/aaa.bz2"); }
#[test] fn pyflate_empty() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/pyflate/empty.bz2"); }
#[test] fn miri_pyflate_hello_world() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/pyflate/hello-world.bz2"); }
#[test] fn miri_pyflate_510B() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/pyflate/510B.bz2"); }
#[test] fn miri_pyflate_aaa() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/pyflate/aaa.bz2"); }
#[test] fn miri_pyflate_empty() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/pyflate/empty.bz2"); }
#[test] fn pyflate_45MB_fb() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/pyflate/45MB-fb.bz2"); }
#[test] fn commons_compress_bla_xml() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/commons-compress/bla.xml.bz2"); }
#[test] fn commons_compress_bla_tar() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/commons-compress/bla.tar.bz2"); }
#[test] fn commons_compress_bla_txt() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/commons-compress/bla.txt.bz2"); }
#[test] fn commons_compress_COMPRESS_131() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/commons-compress/COMPRESS-131.bz2"); }
#[test] fn commons_compress_multiple() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/commons-compress/multiple.bz2"); }
#[test] fn miri_commons_compress_bla_xml() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/commons-compress/bla.xml.bz2"); }
#[test] fn miri_commons_compress_bla_tar() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/commons-compress/bla.tar.bz2"); }
#[test] fn miri_commons_compress_bla_txt() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/commons-compress/bla.txt.bz2"); }
#[test] fn miri_commons_compress_COMPRESS_131() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/commons-compress/COMPRESS-131.bz2"); }
#[test] fn miri_commons_compress_multiple() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/commons-compress/multiple.bz2"); }
#[test] fn commons_compress_zip64support() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/commons-compress/zip64support.tar.bz2"); }
#[test] fn go_compress_e() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/go/compress/e.txt.bz2"); }
#[test] fn go_compress_Isaac() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/go/compress/Isaac.Newton-Opticks.txt.bz2"); }
Expand All @@ -617,26 +617,26 @@ mod bzip2_testfiles {
#[test] fn go_regexp_re2_exhaustive() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/go/regexp/re2-exhaustive.txt.bz2"); }
#[test] fn go_crypto_pss_vect() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/go/crypto/pss-vect.txt.bz2"); }
#[test] fn go_crypto_SigVer() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/go/crypto/SigVer.rsp.bz2"); }
#[test] fn lbzip2_incomp_1() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/incomp-1.bz2"); }
#[test] fn lbzip2_trash() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/trash.bz2"); }
#[test] fn lbzip2_incomp_2() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/incomp-2.bz2"); }
#[test] fn miri_lbzip2_incomp_1() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/incomp-1.bz2"); }
#[test] fn miri_lbzip2_trash() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/trash.bz2"); }
#[test] fn miri_lbzip2_incomp_2() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/incomp-2.bz2"); }
#[test] fn lbzip2_fib() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/fib.bz2"); }
#[test] fn lbzip2_ch255() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/ch255.bz2"); }
#[test] fn lbzip2_32767() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/32767.bz2"); }
#[test] fn lbzip2_empty() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/empty.bz2"); }
#[test] fn lbzip2_concat() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/concat.bz2"); }
#[test] fn miri_lbzip2_empty() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/empty.bz2"); }
#[test] fn miri_lbzip2_concat() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/concat.bz2"); }
#[test] fn lbzip2_idx899999() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/idx899999.bz2"); }
#[test] fn lbzip2_repet() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/repet.bz2"); }
#[test] fn lbzip2_codelen20() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/codelen20.bz2"); }
#[test] fn lbzip2_gap() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/gap.bz2"); }
#[test] fn lbzip2_rand() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/rand.bz2"); }
#[test] fn miri_lbzip2_codelen20() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/codelen20.bz2"); }
#[test] fn miri_lbzip2_gap() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/gap.bz2"); }
#[test] fn miri_lbzip2_rand() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/lbzip2/rand.bz2"); }
#[test] fn dotnetzip_sample1() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/dotnetzip/sample1.bz2"); }
#[test] fn dotnetzip_sample2() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/dotnetzip/sample2.bz2"); }
#[test] fn dotnetzip_dancing_color() { assert_eq_decompress!("../../tests/input/bzip2-testfiles/dotnetzip/dancing-color.ps.bz2"); }
}

#[test]
fn decompress_init_edge_cases() {
fn miri_decompress_init_edge_cases() {
// valid input
crate::assert_eq_rs_c!({
let mut strm = MaybeUninit::zeroed();
Expand Down Expand Up @@ -693,7 +693,7 @@ fn decompress_init_edge_cases() {
}

#[test]
fn decompress_edge_cases() {
fn miri_decompress_edge_cases() {
// strm is NULL
crate::assert_eq_rs_c!({
assert_eq!(BZ_PARAM_ERROR, BZ2_bzDecompress(core::ptr::null_mut()));
Expand Down Expand Up @@ -776,7 +776,7 @@ fn decompress_edge_cases() {
}

#[test]
fn decompress_end_edge_cases() {
fn miri_decompress_end_edge_cases() {
// strm is NULL
crate::assert_eq_rs_c!({
assert_eq!(BZ_PARAM_ERROR, BZ2_bzDecompressEnd(core::ptr::null_mut()));
Expand Down Expand Up @@ -815,7 +815,7 @@ fn decompress_end_edge_cases() {
}

#[test]
fn compress_init_edge_cases() {
fn miri_compress_init_edge_cases() {
let blockSize100k = 9;
let verbosity = 0;
let workFactor = 30;
Expand Down Expand Up @@ -929,7 +929,7 @@ fn compress_init_edge_cases() {
}

#[test]
fn compress_edge_cases() {
fn miri_compress_edge_cases() {
let blockSize100k = 9;
let verbosity = 0;
let workFactor = 30;
Expand Down Expand Up @@ -1082,7 +1082,7 @@ fn compress_edge_cases() {
}

#[test]
fn compress_64_bit_arithmetic_edge_cases() {
fn miri_compress_64_bit_arithmetic_edge_cases() {
let mut output = [0u8; 64];

let blockSize100k = 9;
Expand Down Expand Up @@ -1171,7 +1171,7 @@ fn compress_64_bit_arithmetic_edge_cases() {
}

#[test]
fn compress_action_edge_cases() {
fn miri_compress_action_edge_cases() {
let mut output = [0u8; 64];

let blockSize100k = 9;
Expand Down Expand Up @@ -1229,7 +1229,7 @@ fn compress_action_edge_cases() {
}

#[test]
fn compress_end_edge_cases() {
fn miri_compress_end_edge_cases() {
let blockSize100k = 9;
let verbosity = 0;
let workFactor = 30;
Expand Down

0 comments on commit 7b77a90

Please sign in to comment.