#!/usr/bin/env bash export LC_ALL=C set -eu -o pipefail for d in src/fuzzing/*/ ; do fuzz_cases+="$(basename "$d"), " done FUZZ_OPTIONS_STRING="Where FUZZ_CASE is one of the following: ${fuzz_cases::-2}" required_options_count=0 function help { cat <&2 help exit 1 ;; esac done if ((required_options_count == 0)); then help exit 1 fi mkdir -p "$AFL_INSTALL_DIR" cd "$AFL_INSTALL_DIR" if [ ! -z "$(ls -A .)" ]; then echo "$1 is not empty. This script will only attempt to build AFL in an empty directory." exit 1 fi # Get the AFL source rm -f afl-latest.tgz wget https://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz sha256sum afl-latest.tgz | grep '43614b4b91c014d39ef086c5cc84ff5f068010c264c2c05bf199df60898ce045' if [ "$?" != "0" ] then echo "Wrong SHA256 hash for afl" exit fi tar xvf afl-latest.tgz mv afl-*/* . # Build AFL make echo "You can now build zcashd with AFL instrumentation as follows:" echo "$ make clean # if you've already built zcashd without AFL instrumentation" echo "$ ./zcutil/afl/afl-build.sh -i $(pwd) -f FUZZ_CASE" echo $FUZZ_OPTIONS_STRING