Files
alkstore/fuzz/run-detached.sh
T

29 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Detached fuzzing runner for agent sessions: the fuzz campaign never
# runs as a foreground child of the session (OOM in a target must not
# take down the agent host), and survives the session ending.
#
# Usage: fuzz/run-detached.sh <target> [extra libfuzzer args...]
# (works from the repo root or from fuzz/; CWD-independent)
# FUZZ_RUNTIME_SECS overrides the per-campaign budget (default 600 s).
#
# Poll instead of waiting:
# tail -n 50 fuzz/artifacts/<target>-*.log
# ls fuzz/artifacts/<target>/ (crash-* / oom-* / timeout-* files)
# pgrep -f "cargo fuzz run <target>"
set -euo pipefail
target="${1:?usage: run-detached.sh <target> [extra libfuzzer args...]}"
shift
root="$(git rev-parse --show-toplevel)"
fuzz_dir="$root/fuzz"
mkdir -p "$fuzz_dir/artifacts"
runtime="${FUZZ_RUNTIME_SECS:-600}"
log="$fuzz_dir/artifacts/${target}-$(date -u +%Y%m%d-%H%M%S).log"
cd "$fuzz_dir"
setsid nohup cargo fuzz run "$target" -- \
-fork=1 -rss_limit_mb=2048 -malloc_limit_mb=2048 -timeout=25 \
-max_total_time="$runtime" "$@" \
>"$log" 2>&1 < /dev/null &
echo "pid=$! log=$log"