test(fuzz): Bug fix: work around mv argument limit by using find -exec

This commit is contained in:
Chris Hennick 2024-06-23 12:45:12 -07:00
parent 602c92fed9
commit 125283db60
No known key found for this signature in database
GPG key ID: DA47AABA4961C509
3 changed files with 13 additions and 13 deletions

View file

@ -5,52 +5,52 @@ ncpus=$(( ncpus / ( 1 + $(cat /sys/devices/system/cpu/smt/active))))
NORMAL_RESTARTS=10
rm -rf "fuzz/corpus/fuzz_$1_pre_fresh_blood" || true
mkdir "fuzz/corpus/fuzz_$1_pre_fresh_blood"
mv "fuzz/corpus/fuzz_$1"/* "fuzz/corpus/fuzz_$1_pre_fresh_blood" || true
find "fuzz/corpus/fuzz_$1" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_pre_fresh_blood" ';' || true
for i in $(seq 1 $NORMAL_RESTARTS); do
mv "fuzz/corpus/fuzz_$1_restart_${i}"/* "fuzz/corpus/fuzz_$1_pre_fresh_blood" || true
find "fuzz/corpus/fuzz_$1_restart_${i}" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_pre_fresh_blood" ';' || true
echo "$(date): RESTART ${i}"
mkdir "fuzz/corpus/fuzz_$1" || true
cargo fuzz run --all-features "fuzz_$1" "fuzz/corpus/fuzz_$1" -- \
-dict=fuzz/fuzz.dict -max_len="$2" -fork="$ncpus" \
-max_total_time=5100 -runs=100000000
mkdir "fuzz/corpus/fuzz_$1_restart_${i}" || true
mv "fuzz/corpus/fuzz_$1"/* "fuzz/corpus/fuzz_$1_restart_${i}"
find "fuzz/corpus/fuzz_$1" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_restart_${i}" ';'
done
mv "fuzz/corpus/fuzz_$1_restart_dictionaryless"/* "fuzz/corpus/fuzz_$1_pre_fresh_blood" || true
find "fuzz/corpus/fuzz_$1_restart_dictionaryless" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_pre_fresh_blood" ';' || true
rm -rf "fuzz/corpus/fuzz_$1_restart_dictionaryless" || true
mkdir "fuzz/corpus/fuzz_$1_restart_dictionaryless" || true
echo "$(date): DICTIONARY-LESS RESTART"
cargo fuzz run --all-features "fuzz_$1" "fuzz/corpus/fuzz_$1" -- \
-max_len="$2" -fork="$ncpus" -max_total_time=5100 -runs=100000000
mv "fuzz/corpus/fuzz_$1"/* "fuzz/corpus/fuzz_$1_restart_dictionaryless"
find "fuzz/corpus/fuzz_$1" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_restart_dictionaryless" ';'
mv "fuzz/corpus/fuzz_$1_restart_dictionaryless_012byte"/* "fuzz/corpus/fuzz_$1_pre_fresh_blood" || true
find "fuzz/corpus/fuzz_$1_restart_dictionaryless_012byte" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_pre_fresh_blood" ';' || true
rm -rf "fuzz/corpus/fuzz_$1_restart_dictionaryless_012byte" || true
mkdir "fuzz/corpus/fuzz_$1_restart_dictionaryless_012byte" || true
echo "$(date): DICTIONARY-LESS RESTART WITH 0-2 BYTE CORPUS"
tar -xvzf "fuzz/012byte.tar.gz" -C "fuzz/corpus/fuzz_$1"
cargo fuzz run --all-features "fuzz_$1" "fuzz/corpus/fuzz_$1" -- \
-max_len="$2" -fork="$ncpus" -max_total_time=5100 -runs=100000000
mv "fuzz/corpus/fuzz_$1"/* "fuzz/corpus/fuzz_$1_restart_dictionaryless_012byte"
find "fuzz/corpus/fuzz_$1" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_restart_dictionaryless_012byte" ';'
mv "fuzz/corpus/fuzz_$1_restart_012byte"/* "fuzz/corpus/fuzz_$1_pre_fresh_blood" || true
find "fuzz/corpus/fuzz_$1_restart_012byte"/* -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_pre_fresh_blood" ';' || true
rm -rf "fuzz/corpus/fuzz_$1_restart_012byte" || true
mkdir "fuzz/corpus/fuzz_$1_restart_012byte" || true
echo "$(date): RESTART WITH DICTIONARY AND 0-2 BYTE CORPUS"
tar -xvzf "fuzz/012byte.tar.gz" -C "fuzz/corpus/fuzz_$1"
cargo fuzz run --all-features "fuzz_$1" "fuzz/corpus/fuzz_$1" -- \
-dict=fuzz/fuzz.dict -max_len="$2" -fork="$ncpus" -max_total_time=5100 -runs=100000000
mv "fuzz/corpus/fuzz_$1"/* "fuzz/corpus/fuzz_$1_restart_012byte"
find "fuzz/corpus/fuzz_$1" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_restart_012byte" ';'
echo "$(date): MERGING CORPORA"
for i in $(seq 1 $NORMAL_RESTARTS); do
mv "fuzz/corpus/fuzz_$1_restart_${i}"/* "fuzz/corpus/fuzz_$1"
find "fuzz/corpus/fuzz_$1_restart_${i}" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1" ';'
rm -rf "fuzz/corpus/fuzz_$1_restart_${i}"
done
SPECIAL_RESTARTS=("012byte" "dictionaryless_012byte" "dictionaryless")
for i in "${SPECIAL_RESTARTS[@]}"; do
mv "fuzz/corpus/fuzz_$1_restart_${i}"/* "fuzz/corpus/fuzz_$1"
find "fuzz/corpus/fuzz_$1_restart_${i}" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1" ';'
rm -rf "fuzz/corpus/fuzz_$1_restart_${i}"
done
echo "$(date): RUNNING WITH MERGED CORPUS"

View file

@ -8,7 +8,7 @@ find "fuzz/corpus/fuzz_$1_recombination_sources" -type f -size -2c -delete
for size in "${@:2}"; do
echo "$(date): STARTING ON SIZE $size"
rm -rf "fuzz/corpus/fuzz_$1_pre_fresh_blood" || true
mv "fuzz/corpus/fuzz_$1/*" "fuzz/corpus/fuzz_$1_recombination_sources" || true
find "fuzz/corpus/fuzz_$1" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_recombination_sources" ';' || true
./build-fuzz-corpus-multiple-restarts.sh "$1" "$size"
find "fuzz/corpus/fuzz_$1_recombination_sources" -type f -size "-${size}c" -exec mv '{}' "fuzz/corpus/fuzz_$1" ';'
./fuzz-until-converged.sh "$1" "$size"

View file

@ -11,7 +11,7 @@ while true; do
if diff "fuzz/corpus/fuzz_$1_iter_${i}.bak" "fuzz/corpus/fuzz_$1_iter_${j}"; then
# 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/fuzz_$1_iter_${j}" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1" ';'
find fuzz/corpus -iname "fuzz_$1_iter_*" -exec rm -r {} +
exit 0
fi