From 16a645e69b3c4da3db4d581d2a619877bc8bc82b Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Sat, 13 Nov 2021 14:31:11 -0800 Subject: [PATCH] Add fuzz target to fuzz wasm-to-IR conversion. --- fuzz/.gitignore | 4 ++++ fuzz/Cargo.toml | 27 +++++++++++++++++++++++++++ fuzz/fuzz_targets/parse_ir.rs | 9 +++++++++ 3 files changed, 40 insertions(+) create mode 100644 fuzz/.gitignore create mode 100644 fuzz/Cargo.toml create mode 100644 fuzz/fuzz_targets/parse_ir.rs diff --git a/fuzz/.gitignore b/fuzz/.gitignore new file mode 100644 index 0000000..572e03b --- /dev/null +++ b/fuzz/.gitignore @@ -0,0 +1,4 @@ + +target +corpus +artifacts diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 0000000..55d8543 --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,27 @@ + +[package] +name = "waffle-fuzz" +version = "0.0.0" +authors = ["Automatically generated"] +publish = false +edition = "2018" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.3" +wasm-smith = "0.8" + +[dependencies.waffle] +path = ".." + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +name = "parse_ir" +path = "fuzz_targets/parse_ir.rs" +test = false +doc = false diff --git a/fuzz/fuzz_targets/parse_ir.rs b/fuzz/fuzz_targets/parse_ir.rs new file mode 100644 index 0000000..d662856 --- /dev/null +++ b/fuzz/fuzz_targets/parse_ir.rs @@ -0,0 +1,9 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; + +use waffle::frontend::wasm_to_ir; +use wasm_smith::Module; + +fuzz_target!(|module: Module| { + let _parsed_module = wasm_to_ir(module.to_bytes()).unwrap(); +});