townforge/contrib/fuzz_testing/fuzz.sh
2021-11-27 17:18:58 +00:00

40 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
AFLFUZZ=$(which afl-fuzz)
if ! test -x "$AFLFUZZ"
then
echo "afl-fuzz not found - install american-fuzzy-lop"
exit 1
fi
type="$1"
if test -z "$type"
then
echo "usage: $0 block|transaction|signature|cold-outputs|cold-transaction|load-from-binary|load-from-json|base58|parse-url|http-client|levin|bulletproof|utf8|decode_blocks"
exit 1
fi
case "$type" in
block|transaction|signature|cold-outputs|cold-transaction|load-from-binary|load-from-json|base58|parse-url|http-client|levin|bulletproof|utf8|decode_blocks) ;;
*) echo "usage: $0 block|transaction|signature|cold-outputs|cold-transaction|load-from-binary|load-from-json|base58|parse-url|http-client|levin|bulletproof|utf8|decode_blocks"; exit 1 ;;
esac
if test -d "fuzz-out/$type"
then
dir="-"
else
dir="tests/data/fuzz/$type"
fi
mkdir -p fuzz-out
if test -x build/fuzz/tests/fuzz/${type}_fuzz_tests
then
binary="build/fuzz/tests/fuzz/${type}_fuzz_tests"
elif test -x build/Linux/cc/fuzz/tests/fuzz/${type}_fuzz_tests
then
binary="build/Linux/cc/fuzz/tests/fuzz/${type}_fuzz_tests"
else
echo "${type}_fuzz_tests binary not found"
exit 1
fi
afl-fuzz -i "$dir" -m none -t 250 -o fuzz-out/$type "$binary" @@