From 39217dfa9210a01078ac02aab959940dc581c314 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 22 Jan 2025 09:48:12 -0800 Subject: [PATCH] Relax test assertions so they are more flexible Two main things: 1. Symbolication may or may not happen depending on whether things like `llvm-addr2line` is on `$PATH` or not, and 2. corpus minimization isn't guaranteed to result in a single seed file, just assert that it gets smaller. --- tests/tests/main.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/tests/main.rs b/tests/tests/main.rs index 668461d..842af9a 100644 --- a/tests/tests/main.rs +++ b/tests/tests/main.rs @@ -281,10 +281,14 @@ fn run_with_crash() { .env("RUST_BACKTRACE", "1") .assert() .stderr( - predicate::str::contains("thread '' panicked at") + predicate::str::contains("panicked at") .and(predicate::str::contains("I'm afraid of number 7")) - .and(predicate::str::contains("ERROR: libFuzzer: deadly signal")) - .and(predicate::str::contains("run_with_crash::fail_fuzzing")) + .and(predicate::str::contains("libFuzzer: deadly signal")) + // XXX: Symbolication may or may not happen depending on what + // LLVM tools are on `$PATH`, so don't assert that we got the + // expected symbol name, even though ideally we should. + // + // .and(predicate::str::contains("run_with_crash::fail_fuzzing")) .and(predicate::str::contains( "────────────────────────────────────────────────────────────────────────────────\n\ \n\ @@ -375,10 +379,12 @@ fn run_without_sanitizer_with_crash() { .env("RUST_BACKTRACE", "1") .assert() .stderr( - predicate::str::contains("thread '' panicked at") + predicate::str::contains("panicked at") .and(predicate::str::contains("I'm afraid of number 7")) - .and(predicate::str::contains("ERROR: libFuzzer: deadly signal")) - .and(predicate::str::contains("run_without_sanitizer_with_crash::fail_fuzzing")) + .and(predicate::str::contains("libFuzzer: deadly signal")) + // XXX: See comment in `run_with_crash`. + // + // .and(predicate::str::contains("run_without_sanitizer_with_crash::fail_fuzzing")) .and(predicate::str::contains( "────────────────────────────────────────────────────────────────────────────────\n\ \n\ @@ -691,7 +697,11 @@ fn cmin() { .arg("foo") .assert() .success(); - assert_eq!(corpus_count(), 1); + + // XXX: Ideally this would be `assert_eq!(corpus_count(), 1)` but that has + // started failing in newer `rustc` / libFuzzer combinations. Just assert + // that the corpus got smaller, at least. + assert!(corpus_count() < 5); } #[test]