//! Replay every input the fuzzer has ever found, on stable, in CI. //! //! A crash found by `cargo fuzz` becomes a permanent test by copying one file //! into `fuzz/regressions/`. Nothing else is needed: this walks the directory //! and runs the same `docengine::oracle::check` the fuzz target runs, so the two //! cannot drift into checking different things. //! //! An empty directory is a passing run and says so. That is not the same as no //! coverage -- the soak tier is where the searching happens -- but a silently //! empty replay would look identical to a replay that ran, which is the failure //! this note exists to prevent. use std::fs; use std::path::Path; #[test] fn every_fuzz_regression_still_passes() { let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("fuzz/regressions"); let Ok(entries) = fs::read_dir(&dir) else { // Not a failure: a checkout without the directory is a checkout with no // regressions yet. println!("no regressions directory at {}", dir.display()); return; }; let mut checked = 0usize; for entry in entries { let path = entry.expect("reading a regression entry").path(); if !path.is_file() { continue; } // Lossy on purpose. The corpus is bytes the fuzzer produced, and one // that is not valid UTF-8 is still worth replaying through the same // conversion the target's `&str` input performs. let input = String::from_utf8_lossy(&fs::read(&path).expect("reading a regression")).into_owned(); docengine::oracle::check(&input); checked += 1; } println!( "replayed {checked} fuzz regression(s) from {}", dir.display() ); }