#!/usr/bin/env bash # Build and run the differential and safety fuzzers. set -euo pipefail here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" build="${1:-$here/build}" seconds="${2:-300}" # Configure once, then rebuild every run: the build is incremental, so this # cannot fuzz stale binaries after a source edit. if [[ ! -f "$build/CMakeCache.txt" ]]; then cmake -S "$here" -B "$build" -G Ninja -DCMAKE_CXX_COMPILER="${CXX:-clang++-21}" fi cmake --build "$build" --target fuzz_readable fuzz_raw corpus="${TMPDIR:-/tmp}/cr-fuzz-corpus" mkdir -p "$corpus/readable" "$corpus/raw" echo "== differential fuzzing (readable instances) ==" "$build/fuzz_readable" -max_total_time="$seconds" -max_len=1024 "$corpus/readable" echo "== safety fuzzing (arbitrary instances) ==" "$build/fuzz_raw" -max_total_time="$seconds" -max_len=1024 "$corpus/raw"