Add a spec test fuzzer for Config (#1509)
* Add a spec test fuzzer for Config This commit adds a new fuzzer which is intended to run on oss-fuzz. This fuzzer creates and arbitrary `Config` which *should* pass spec tests and then asserts that it does so. The goal here is to weed out any accidental bugs in global configuration which could cause non-spec-compliant behavior. * Move implementation to `fuzzing` crate
This commit is contained in:
@@ -15,6 +15,7 @@ pub mod dummy;
|
||||
use dummy::dummy_imports;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
|
||||
use wasmtime::*;
|
||||
use wasmtime_wast::WastContext;
|
||||
|
||||
fn log_wasm(wasm: &[u8]) {
|
||||
static CNT: AtomicUsize = AtomicUsize::new(0);
|
||||
@@ -400,3 +401,15 @@ pub fn make_api_calls(api: crate::generators::api::ApiCalls) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Executes the wast `test` spectest with the `config` specified.
|
||||
///
|
||||
/// Ensures that spec tests pass regardless of the `Config`.
|
||||
pub fn spectest(config: crate::generators::Config, test: crate::generators::SpecTest) {
|
||||
let store = Store::new(&Engine::new(&config.to_wasmtime()));
|
||||
let mut wast_context = WastContext::new(store);
|
||||
wast_context.register_spectest().unwrap();
|
||||
wast_context
|
||||
.run_buffer(test.file, test.contents.as_bytes())
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user