Create binary for processing fuzz crashes

This commit is contained in:
Wilson Lin 2020-07-07 21:09:22 +10:00
parent 2ffb626573
commit 03879c223a
3 changed files with 31 additions and 0 deletions

2
fuzz/process/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target/
/Cargo.lock

8
fuzz/process/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "hyperbuild-fuzz-process"
version = "0.0.1"
authors = ["Wilson Lin <code@wilsonl.in>"]
edition = "2018"
[dependencies]
hyperbuild = { path = "../.." }

21
fuzz/process/src/main.rs Normal file
View File

@ -0,0 +1,21 @@
use std::fs;
use std::io::{self, Write};
use std::panic;
use hyperbuild;
fn main() {
for dirent in fs::read_dir("../out/crashes").unwrap() {
let path = dirent.unwrap().path().to_path_buf();
let path_in_catch = path.clone();
let res = panic::catch_unwind(|| {
let mut contents = fs::read(path_in_catch).unwrap();
let _ = hyperbuild::hyperbuild(&mut contents);
});
if res.is_err() {
let contents = fs::read(path).unwrap();
io::stdout().write_all(&contents).unwrap();
break;
};
fs::remove_file(path).unwrap();
};
}