Throw out fewer fuzz inputs with differential fuzzer (#4859)
* Throw out fewer fuzz inputs with differential fuzzer Prior to this commit the differential fuzzer would generate a module and then select an engine to execute the module against Wasmtime. This meant, however, that the candidate list of engines were filtered against the configuration used to generate the module to ensure that the selected engine could run the generated module. This commit inverts this logic and instead selects an engine first, allowing the engine to then tweak the module configuration to ensure that the generated module is compatible with the engine selected. This means that fewer fuzz inputs are discarded because every fuzz input will result in an engine being executed. Internally the engine constructors have all been updated to update the configuration to work instead of filtering the configuration. Some other fixes were applied for the spec interpreter as well to work around #4852 * Fix tests
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
//! Evaluate an exported Wasm function using Wasmtime.
|
||||
|
||||
use crate::generators::{self, DiffValue, DiffValueType};
|
||||
use crate::generators::{self, DiffValue, DiffValueType, WasmtimeConfig};
|
||||
use crate::oracles::dummy;
|
||||
use crate::oracles::engine::DiffInstance;
|
||||
use crate::oracles::{compile_module, engine::DiffEngine, StoreLimits};
|
||||
use anyhow::{Context, Error, Result};
|
||||
use arbitrary::Unstructured;
|
||||
use wasmtime::{Extern, FuncType, Instance, Module, Store, Trap, TrapCode, Val};
|
||||
|
||||
/// A wrapper for using Wasmtime as a [`DiffEngine`].
|
||||
pub struct WasmtimeEngine {
|
||||
pub(crate) config: generators::Config,
|
||||
config: generators::Config,
|
||||
}
|
||||
|
||||
impl WasmtimeEngine {
|
||||
@@ -17,7 +18,13 @@ impl WasmtimeEngine {
|
||||
/// later. Ideally the store and engine could be built here but
|
||||
/// `compile_module` takes a [`generators::Config`]; TODO re-factor this if
|
||||
/// that ever changes.
|
||||
pub fn new(config: generators::Config) -> Result<Self> {
|
||||
pub fn new(u: &mut Unstructured<'_>, config: &generators::Config) -> arbitrary::Result<Self> {
|
||||
let mut new_config = u.arbitrary::<WasmtimeConfig>()?;
|
||||
new_config.make_compatible_with(&config.wasmtime);
|
||||
let config = generators::Config {
|
||||
wasmtime: new_config,
|
||||
module_config: config.module_config.clone(),
|
||||
};
|
||||
Ok(Self { config })
|
||||
}
|
||||
}
|
||||
@@ -220,5 +227,5 @@ impl Into<DiffValue> for Val {
|
||||
|
||||
#[test]
|
||||
fn smoke() {
|
||||
crate::oracles::engine::smoke_test_engine(|config| WasmtimeEngine::new(config))
|
||||
crate::oracles::engine::smoke_test_engine(|u, config| WasmtimeEngine::new(u, config))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user