Fuzz loading/validation against wabt.

This commit is contained in:
Sergey Pepyakin 2018-01-24 21:32:46 +03:00
parent 51caaff556
commit d78677ef00
3 changed files with 41 additions and 0 deletions

4
fuzz/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
target
corpus
artifacts

24
fuzz/Cargo.toml Normal file
View File

@ -0,0 +1,24 @@
[package]
name = "wasmi-fuzz"
version = "0.0.1"
authors = ["Automatically generated"]
publish = false
[package.metadata]
cargo-fuzz = true
[dependencies]
wasmi = { path = ".." }
wabt = "0.1.6"
[dependencies.libfuzzer-sys]
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "load"
path = "fuzz_targets/load.rs"

13
fuzz/fuzz_targets/load.rs Normal file
View File

@ -0,0 +1,13 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate wasmi;
extern crate wabt;
fuzz_target!(|data: &[u8]| {
let wasmi_result = wasmi::load_from_buffer(data);
// TODO: Do validation only!
let wabt_result = wabt::wasm2wat(data);
assert_eq!(wasmi_result.is_ok(), wabt_result.is_ok());
});