Make spectest fuzzing more deterministic

Currently spectest fuzzing indexes into a compile-time-created array of
strings which is the list of input files, but the order of this array is
dependent on the filesystem that we're reading from. This means that
inputs from oss-fuzz may not be easily reproducible locally because
files could be read in different orders, so indexes could be distinct.

This commit instead reads the directory paths, then sorts them, then
includes them for testing. That way fuzz inputs at a specific commit
should be consistent.
This commit is contained in:
Alex Crichton
2020-08-06 08:08:20 -07:00
parent 4cb36afd7b
commit d6f64ec88e

View File

@@ -13,9 +13,12 @@ fn main() {
.unwrap() .unwrap()
.join("../../tests/spec_testsuite"); .join("../../tests/spec_testsuite");
let mut code = format!("static FILES: &[(&str, &str)] = &[\n"); let mut code = format!("static FILES: &[(&str, &str)] = &[\n");
for entry in dir.read_dir().unwrap() { let entries = dir
let entry = entry.unwrap(); .read_dir()
let path = entry.path().display().to_string(); .unwrap()
.map(|p| p.unwrap().path().display().to_string())
.collect::<Vec<_>>();
for path in entries {
if !path.ends_with(".wast") { if !path.ends_with(".wast") {
continue; continue;
} }