Skip to content

Commit

Permalink
Merge pull request bytecodealliance#15 from pepyakin/fuzz-load
Browse files Browse the repository at this point in the history
Fuzz loading/validation against wabt.
  • Loading branch information
NikVolf authored Jan 26, 2018
2 parents 5005380 + e1216f6 commit aa42ac9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

target
corpus
artifacts
24 changes: 24 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions fuzz/fuzz_targets/load.rs
Original file line number Diff line number Diff line change
@@ -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! https://github.com/pepyakin/wasmi/issues/16
let wabt_result = wabt::wasm2wat(data);

assert_eq!(wasmi_result.is_ok(), wabt_result.is_ok());
});

0 comments on commit aa42ac9

Please sign in to comment.