summaryrefslogtreecommitdiff
path: root/scripts/fuzz.sh
blob: 047e55cad743c32314e2df083e9e7bf05adbb379 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash

set -e
set -o pipefail

export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason"

AFL_PREFIX=$(mason prefix afl 2.19b)
AFL_FUZZ=${AFL_PREFIX}/bin/afl-fuzz


if [ -z "$2" ]; then
    echo "Usage: $0 <build path> <name>"
    exit 1
fi

if [ ! -d "test/fuzz-input/$2" ]; then
    echo "Fuzzing data for '$2' does not exist."
    exit 1
fi

FUZZ=$1/fuzz
${FUZZ} $2 < /dev/null

rm -rf test/fuzz-result/$2
mkdir -p test/fuzz-result/$2

${AFL_FUZZ} -i test/fuzz-input/$2 -o test/fuzz-result/$2 ${FUZZ} $2