zip-rs-wasm/fuzz-until-converged.sh
2024-06-13 03:40:41 +00:00

20 lines
866 B
Bash
Executable file

#!/bin/bash
rm -r "fuzz/corpus/fuzz_$1_old"
ncpus=$(nproc || getconf NPROCESSORS_ONLN)
ncpus=$(( ncpus / ( 1 + $(cat /sys/devices/system/cpu/smt/active))))
MAX_ITERS_WITHOUT_IMPROVEMENT=3
iters_without_improvement=0
while [[ $iters_without_improvement -lt $MAX_ITERS_WITHOUT_IMPROVEMENT ]]; do
cp -r "fuzz/corpus/fuzz_$1" "fuzz/corpus/fuzz_$1_old"
cargo fuzz run --all-features "fuzz_$1" "fuzz/corpus/fuzz_$1" -- \
-dict=fuzz/fuzz.dict -max_len="$2" -fork="$ncpus" \
-max_total_time=1800 -runs=20000000 -rss_limit_mb=8192 -timeout=10
./recursive-fuzz-cmin.sh "$1" "$2"
if diff "fuzz/corpus/fuzz_$1" "fuzz/corpus/fuzz_$1_old"; then
iters_without_improvement=$(( iters_without_improvement + 1 ))
echo "$iters_without_improvement iterations without improvement"
else
iters_without_improvement=0
fi
rm -r "fuzz/corpus/fuzz_$1_old"
done