deps: Update Arbitrary to 1.0; libfuzzer-sys to 0.4.0; wasm-smith to 0.4.0
This commit is contained in:
committed by
Andrew Brown
parent
ebbe626e79
commit
824ce7bf89
@@ -8,7 +8,7 @@ publish = false
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
arbitrary = { version = "0.4.1", features = ["derive"] }
|
||||
arbitrary = { version = "1.0.0", features = ["derive"] }
|
||||
bincode = "1.2.1"
|
||||
env_logger = "0.8.1"
|
||||
fst = "0.4.1"
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
use arbitrary::{Arbitrary, Unstructured};
|
||||
use rand::prelude::*;
|
||||
use std::fmt::Debug;
|
||||
use std::panic;
|
||||
use std::time;
|
||||
|
||||
pub mod automata;
|
||||
@@ -24,7 +23,7 @@ pub mod parser;
|
||||
/// for use with `cargo test` and CI.
|
||||
pub fn check<A>(mut f: impl FnMut(A))
|
||||
where
|
||||
A: Clone + Debug + Arbitrary,
|
||||
A: Clone + Debug + for<'a> Arbitrary<'a>,
|
||||
{
|
||||
let seed = rand::thread_rng().gen();
|
||||
let mut rng = rand::rngs::SmallRng::seed_from_u64(seed);
|
||||
@@ -38,7 +37,7 @@ where
|
||||
let time_budget = time::Duration::from_secs(2);
|
||||
let then = time::Instant::now();
|
||||
|
||||
let (failing_input, panic_info) = loop {
|
||||
loop {
|
||||
if num_checked > 0 && time::Instant::now().duration_since(then) > time_budget {
|
||||
eprintln!("Checked {} random inputs.", num_checked);
|
||||
return;
|
||||
@@ -48,9 +47,7 @@ where
|
||||
Ok(input) => {
|
||||
num_checked += 1;
|
||||
eprintln!("Checking input: {:#?}", input);
|
||||
if let Err(p) = panic::catch_unwind(panic::AssertUnwindSafe(|| f(input.clone()))) {
|
||||
break (input, p);
|
||||
}
|
||||
f(input.clone());
|
||||
}
|
||||
Err(e @ arbitrary::Error::NotEnoughData) => {
|
||||
eprintln!("warning: {}", e);
|
||||
@@ -97,23 +94,5 @@ where
|
||||
for i in 0..buf.len() {
|
||||
buf[i] = rng.gen();
|
||||
}
|
||||
};
|
||||
|
||||
// Shrink the failing input.
|
||||
let mut smallest_failing_input = failing_input;
|
||||
let mut panic_info = panic_info;
|
||||
'shrinking: loop {
|
||||
eprintln!("Smallest failing input: {:#?}", smallest_failing_input);
|
||||
for input in smallest_failing_input.shrink() {
|
||||
if let Err(p) = panic::catch_unwind(panic::AssertUnwindSafe(|| f(input.clone()))) {
|
||||
smallest_failing_input = input;
|
||||
panic_info = p;
|
||||
continue 'shrinking;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Resume the panic for the smallest input.
|
||||
panic::resume_unwind(panic_info);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user