Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements to differential fuzzing #4845

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions crates/fuzzing/src/oracles/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn choose(
u: &mut Unstructured<'_>,
existing_config: &Config,
allowed: &[&str],
) -> arbitrary::Result<Box<dyn DiffEngine>> {
) -> arbitrary::Result<Option<Box<dyn DiffEngine>>> {
// Filter out any engines that cannot match the `existing_config` or are not
// `allowed`.
let mut engines: Vec<Box<dyn DiffEngine>> = vec![];
Expand Down Expand Up @@ -54,13 +54,16 @@ pub fn choose(
}
}

if engines.is_empty() {
return Ok(None);
}
Comment on lines +57 to +59
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly surprised we would ever have a case where we can't run the test case in Wasmtime. What is even the point at that time?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue this is addressing is if testing Wasmtime against Wasmtime has been disabled using the ALLOWED_ENGINES environment variable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah this is only applicable when you're doing something like ALLOWED_ENGINES=wasmi locally where I was trying to only differentially-execute against wasmi


// Use the input of the fuzzer to pick an engine that we'll be fuzzing
// Wasmtime against.
assert!(!engines.is_empty());
let index: usize = u.int_in_range(0..=engines.len() - 1)?;
let engine = engines.swap_remove(index);
log::debug!("selected engine: {}", engine.name());
Ok(engine)
Ok(Some(engine))
}

/// Provide a way to instantiate Wasm modules.
Expand Down
9 changes: 7 additions & 2 deletions fuzz/fuzz_targets/differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,13 @@ fn run(data: &[u8]) -> Result<()> {
};
log_wasm(&wasm);

// Choose a left-hand side Wasm engine.
let mut lhs = engine::choose(&mut u, &config, unsafe { &ALLOWED_ENGINES })?;
// Choose a left-hand side Wasm engine. If no engine could be chosen then
// that means the configuration selected above doesn't match any allowed
// engine (configured via an env var) so the test case is thrown out.
let mut lhs = match engine::choose(&mut u, &config, unsafe { &ALLOWED_ENGINES })? {
Some(engine) => engine,
None => return Ok(()),
};
let lhs_instance = lhs.instantiate(&wasm);
STATS.bump_engine(lhs.name());

Expand Down