peepmatic: Introduce the peepmatic-fuzzing crate

This crate contains oracles, generators, and fuzz targets for use with fuzzing
engines (e.g. libFuzzer). This doesn't contain the actual
`libfuzzer_sys::fuzz_target!` definitions (those are in the `peepmatic-fuzz`
crate) but does those definitions are one liners calling out to functions
defined in this crate.
This commit is contained in:
Nick Fitzgerald
2020-05-01 15:47:47 -07:00
parent 2828da1f56
commit 1a7670f964
6 changed files with 802 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
//! Utilities for fuzzing our DSL's parser.
use peepmatic::Optimizations;
use std::str;
/// Attempt to parse the given string as if it were a snippet of our DSL.
pub fn parse(data: &[u8]) {
let source = match str::from_utf8(data) {
Ok(s) => s,
Err(_) => return,
};
let buf = match wast::parser::ParseBuffer::new(&source) {
Ok(buf) => buf,
Err(_) => return,
};
let _ = wast::parser::parse::<Optimizations>(&buf);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn check_parse() {
crate::check(|s: String| parse(s.as_bytes()));
}
}