From d6d7145cd02e99dfe65dcdb1394027cb7c113e32 Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Thu, 6 Jun 2024 15:18:29 -0700 Subject: [PATCH] ci(fuzz): Bug fixes and tweaks for fuzz scripts --- fuzz-until-converged.sh | 13 +++++++++++++ recursive-fuzz-cmin.sh | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100755 fuzz-until-converged.sh diff --git a/fuzz-until-converged.sh b/fuzz-until-converged.sh new file mode 100755 index 00000000..c16e0861 --- /dev/null +++ b/fuzz-until-converged.sh @@ -0,0 +1,13 @@ +#!/bin/bash +rm -r "fuzz/corpus/fuzz_$1_old" +updated=1 +while [[ $updated ]]; do + updated=0 + 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" -rss_limit_mb=8192 \ + -fork="$(nproc || getconf NPROCESSORS_ONLN)" -runs=1000000 + ./recursive-fuzz-cmin.sh "$1" "$2" + updated=$(diff "fuzz/corpus/fuzz_$1" "fuzz/corpus/fuzz_$1_old") + rm -r "fuzz/corpus/fuzz_$1_old" +done diff --git a/recursive-fuzz-cmin.sh b/recursive-fuzz-cmin.sh index c9e08c69..da9e9210 100755 --- a/recursive-fuzz-cmin.sh +++ b/recursive-fuzz-cmin.sh @@ -1,6 +1,7 @@ #!/bin/bash -cp -r "fuzz/corpus/fuzz_$1" "fuzz/corpus/fuzz_$1_iter_0" i=0 +find fuzz/corpus -iname "fuzz_$1_iter_*" -exec rm -r {} + +cp -r "fuzz/corpus/fuzz_$1" "fuzz/corpus/fuzz_$1_iter_0" while true; do j=$((i + 1)) cp -r "fuzz/corpus/fuzz_$1_iter_${i}" "fuzz/corpus/fuzz_$1_iter_${i}.bak" @@ -11,7 +12,8 @@ while true; do # Last iteration made no difference, so we're done rm -r "fuzz/corpus/fuzz_$1" mv "fuzz/corpus/fuzz_$1_iter_${j}" "fuzz/corpus/fuzz_$1" + find fuzz/corpus -iname "fuzz_$1_iter_*" -exec rm -r {} + exit 0 fi i=$j -done +done \ No newline at end of file