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:
26
crates/fuzzing/build.rs
Normal file
26
crates/fuzzing/build.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
// A small build script to include the contents of the spec test suite into the
|
||||
// final fuzzing binary so the fuzzing binary can be run elsewhere and doesn't
|
||||
// rely on the original source tree.
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
||||
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
let dir = env::current_dir()
|
||||
.unwrap()
|
||||
.join("../../tests/spec_testsuite");
|
||||
let mut code = format!("static FILES: &[(&str, &str)] = &[\n");
|
||||
for entry in dir.read_dir().unwrap() {
|
||||
let entry = entry.unwrap();
|
||||
let path = entry.path().display().to_string();
|
||||
if !path.ends_with(".wast") {
|
||||
continue;
|
||||
}
|
||||
code.push_str(&format!("({:?}, include_str!({0:?})),\n", path));
|
||||
}
|
||||
code.push_str("];\n");
|
||||
std::fs::write(out_dir.join("spectests.rs"), code).unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user