25 lines
857 B
Bash
Executable File
25 lines
857 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Coverage-guided fuzzing of the standalone parsers with Clang/libFuzzer.
|
|
# Usage: VOID_INCLUDE_DIR=/path/to/VoidLibrary/include fuzz/run.sh [seconds] [extra libFuzzer args...]
|
|
set -euo pipefail
|
|
|
|
root="$(cd "$(dirname "$0")/.." && pwd)"
|
|
seconds="${1:-60}"
|
|
shift || true
|
|
|
|
: "${VOID_INCLUDE_DIR:?set VOID_INCLUDE_DIR to the VoidLibrary include directory}"
|
|
|
|
out="${FUZZ_OUT:-$root/build/fuzz}"
|
|
corpus="$out/corpus"
|
|
mkdir -p "$out" "$corpus"
|
|
if [ -d "$root/fuzz/seeds" ]; then
|
|
cp -n "$root/fuzz/seeds/"* "$corpus/" 2>/dev/null || true
|
|
fi
|
|
|
|
clang++ -std=c++26 -O1 -g -fsanitize=fuzzer,address,undefined \
|
|
-fno-omit-frame-pointer \
|
|
-I"$root/include" -I"$root/recipes" -I"$VOID_INCLUDE_DIR" \
|
|
"$root/fuzz/fuzz_parsers.cpp" -o "$out/fuzz_parsers"
|
|
|
|
exec "$out/fuzz_parsers" -max_total_time="$seconds" -max_len=65536 "$corpus" "$@"
|