Skip to content

Commit

Permalink
Merge pull request #47 from killercup/improve-run-fuzzer
Browse files Browse the repository at this point in the history
Improve run-fuzzer script
  • Loading branch information
frewsxcv authored Mar 15, 2017
2 parents 298bbbb + fb5d65a commit a00fcd8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
Cargo.lock
target/

*/*.log
*/crash-*
*/corpus
32 changes: 25 additions & 7 deletions run-fuzzer.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
#!/bin/sh
#!/bin/bash

set -ex
set -e

if [ "$#" -ne 2 ]; then
echo "Usage: run-fuzzer.sh <crate> <target>" 1>&2
if [ "$#" -lt 2 ]; then
echo "Usage: run-fuzzer.sh <crate> <target> [<options...>]" 1>&2
exit 1
fi

# Specify RUSTFLAGS so the target crate is compiled with sanitization
export RUSTFLAGS="-Cpasses=sancov -Cllvm-args=-sanitizer-coverage-level=3 -Zsanitizer=address -Cpanic=abort"
# Specify RUSTFLAGS:
export RUSTFLAGS=""
# - so the target crate is compiled with sanitization
export RUSTFLAGS="$RUSTFLAGS -C passes=sancov -C llvm-args=-sanitizer-coverage-level=3 -Z sanitizer=address -C panic=abort"
# - optimizations
export RUSTFLAGS="$RUSTFLAGS -C opt-level=3"
# - and all debug infos
export RUSTFLAGS="$RUSTFLAGS -C debug-assertions=on -C debuginfo=2"

# Specify asan options to disable things that don't work
export ASAN_OPTIONS="$ASAN_OPTIONS detect_odr_violation=0"

# Show all the rust errors
export RUST_BACKTRACE=full

# Change directory to the crate we want to fuzz
cd "$1"

# Create seed directory if it does not exist. Add example files here.
mkdir -p seeds

# Create corpus directory which the fuzzer will fill with interesting inputs.
mkdir -p corpus

# Run the fuzzer with that target
cargo run --bin "$2"
cargo run --bin "$2" -- ${@:3} `pwd`/corpus `pwd`/seeds

0 comments on commit a00fcd8

Please sign in to comment.