Skip to content

Commit

Permalink
Fix fuzz (bytecodealliance#35)
Browse files Browse the repository at this point in the history
* Add checking for fuzz.

* Use wabt's validation instead of wasm2wat.

Fixes bytecodealliance#16
Fixes bytecodealliance#34

* Check fuzz with nightly.

* Install nightly toolchain

* Travis Driven Development bytecodealliance#1

* Travis Driven Development bytecodealliance#2
  • Loading branch information
pepyakin authored and NikVolf committed Feb 5, 2018
1 parent 106ac7a commit eda4882
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ addons:
- gcc-6
- g++-6
- cmake
env:
- NIGHTLY_TOOLCHAIN=nightly-2018-02-05

install:
# Install `cargo-deadlinks` unless it is currently installed.
- command -v cargo-deadlinks &> /dev/null || cargo install cargo-deadlinks
# Install nightly toolchain.
- rustup toolchain install $NIGHTLY_TOOLCHAIN
script:
- export CC=/usr/bin/gcc-6
- export CXX=/usr/bin/g++-6
# Make sure fuzz targets are not broken.
- rustup run $NIGHTLY_TOOLCHAIN cargo check --tests --manifest-path=fuzz/Cargo.toml
- ./test.sh
- ./doc.sh
after_success: |
Expand Down
2 changes: 1 addition & 1 deletion doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eux

cd $(dirname $0)

cargo doc
rustup run $NIGHTLY_TOOLCHAIN cargo doc

# cargo-deadlinks will check any links in docs generated by `cargo doc`.
# This is useful as rustdoc uses raw links which are error prone.
Expand Down
2 changes: 1 addition & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cargo-fuzz = true

[dependencies]
wasmi = { path = ".." }
wabt = "0.1.6"
wabt = "0.1.7"

[dependencies.libfuzzer-sys]
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
Expand Down
12 changes: 6 additions & 6 deletions fuzz/fuzz_targets/load.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate wasmi;
#[macro_use]
extern crate libfuzzer_sys;
extern crate wabt;
extern crate wasmi;

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);
let wasmi_result = wasmi::Module::from_buffer(data);
let wabt_result =
wabt::Module::read_binary(data, &Default::default()).and_then(|m| m.validate());

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

0 comments on commit eda4882

Please sign in to comment.