-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathrun-fuzz.sh
More file actions
executable file
·33 lines (27 loc) · 867 Bytes
/
run-fuzz.sh
File metadata and controls
executable file
·33 lines (27 loc) · 867 Bytes
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
29
30
31
32
33
#!/usr/bin/env bash
#
# run-fuzz.sh -- run every FuzzXxx target in this package sequentially.
#
# Usage:
# ./run-fuzz.sh # default 30s per fuzzer
# FUZZTIME=5m ./run-fuzz.sh # override per-fuzzer duration
# FUZZTIME=1h ./run-fuzz.sh # long soak
#
# Go's -fuzz flag accepts only one target per invocation, so we enumerate
# them and loop. Any discovered crash is written under testdata/fuzz/<name>/
# and the script aborts on first failure.
set -euo pipefail
FUZZTIME="${FUZZTIME:-30s}"
cd "$(dirname "$0")"
fuzzers=$(go test -list='^Fuzz' . | grep ^Fuzz || true)
if [ -z "$fuzzers" ]; then
echo "no fuzz targets found" >&2
exit 1
fi
echo "running fuzzers ($FUZZTIME each):"
echo "$fuzzers" | sed 's/^/ - /'
echo
for f in $fuzzers; do
echo "=== $f ==="
go test -run=xxx -fuzz="^${f}\$" -fuzztime="$FUZZTIME" .
done