Skip to content

Commit

Permalink
review: simplify choosing modules
Browse files Browse the repository at this point in the history
  • Loading branch information
abrown committed Aug 24, 2022
1 parent 5958292 commit 13bda67
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions fuzz/fuzz_targets/differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,13 @@ fn run(data: &[u8]) -> Result<()> {
let module = SingleInstModule::new(u, &mut config.module_config)?;
Ok(module.to_bytes())
};
let wasm = match unsafe { &ALLOWED_MODULES.as_slice() } {
&[] => panic!("unable to generate a module to fuzz against; check `ALLOWED_MODULES`"),
&[n] if n == "wasm-smith" => build_wasm_smith_module(&mut u, &mut config)?,
&[n] if n == "single-inst" => build_single_inst_module(&mut u, &mut config)?,
_ => {
if u.arbitrary()? {
build_wasm_smith_module(&mut u, &mut config)?
} else {
build_single_inst_module(&mut u, &mut config)?
}
}
if unsafe { ALLOWED_MODULES }.is_empty() {
panic!("unable to generate a module to fuzz against; check `ALLOWED_MODULES`")
}
let wasm = match u.choose(unsafe { &ALLOWED_MODULES.as_slice() }).unwrap() {
"wasm-smith" => build_wasm_smith_module(&mut u, &mut config)?,
"single-inst" => build_single_inst_module(&mut u, &mut config)?,
_ => unreachable!(),
};
log_wasm(&wasm);

Expand Down

0 comments on commit 13bda67

Please sign in to comment.