test(fuzz): Refactor: move and re-create directory rather than contents, when possible

This commit is contained in:
Chris Hennick 2024-07-06 16:07:33 -07:00
parent 319fafdefe
commit 0453cf0ebf
No known key found for this signature in database
GPG key ID: DA47AABA4961C509
2 changed files with 10 additions and 11 deletions

View file

@ -8,35 +8,35 @@ mkdir "fuzz/corpus/fuzz_$1_pre_fresh_blood"
find "fuzz/corpus/fuzz_$1" -type f -exec mv '{}' "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 for i in $(seq 1 $NORMAL_RESTARTS); do
find "fuzz/corpus/fuzz_$1_restart_${i}" -type f -exec mv '{}' "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
rm -rf "fuzz/corpus/fuzz_$1_restart_${i}" || true
echo "$(date): RESTART ${i}" echo "$(date): RESTART ${i}"
mkdir "fuzz/corpus/fuzz_$1" || true mkdir "fuzz/corpus/fuzz_$1" || true
cargo fuzz run --all-features "fuzz_$1" "fuzz/corpus/fuzz_$1" -- \ cargo fuzz run --all-features "fuzz_$1" "fuzz/corpus/fuzz_$1" -- \
-dict=fuzz/fuzz.dict -max_len="$2" -fork="$ncpus" \ -dict=fuzz/fuzz.dict -max_len="$2" -fork="$ncpus" \
-max_total_time=5100 -runs=100000000 -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}" ';' mkdir "fuzz/corpus/fuzz_$1"
done done
find "fuzz/corpus/fuzz_$1_restart_dictionaryless" -type f -exec mv '{}' "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 rm -rf "fuzz/corpus/fuzz_$1_restart_dictionaryless" || true
mkdir "fuzz/corpus/fuzz_$1_restart_dictionaryless" || true
echo "$(date): DICTIONARY-LESS RESTART" echo "$(date): DICTIONARY-LESS RESTART"
cargo fuzz run --all-features "fuzz_$1" "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 -max_len="$2" -fork="$ncpus" -max_total_time=5100 -runs=100000000
find "fuzz/corpus/fuzz_$1" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_restart_dictionaryless" ';' mv "fuzz/corpus/fuzz_$1" "fuzz/corpus/fuzz_$1_restart_dictionaryless"
mkdir "fuzz/corpus/fuzz_$1"
find "fuzz/corpus/fuzz_$1_restart_dictionaryless_012byte" -type f -exec mv '{}' "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 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" echo "$(date): DICTIONARY-LESS RESTART WITH 0-2 BYTE CORPUS"
tar -xvzf "fuzz/012byte.tar.gz" -C "fuzz/corpus/fuzz_$1" tar -xvzf "fuzz/012byte.tar.gz" -C "fuzz/corpus/fuzz_$1"
cargo fuzz run --all-features "fuzz_$1" "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 -max_len="$2" -fork="$ncpus" -max_total_time=5100 -runs=100000000
find "fuzz/corpus/fuzz_$1" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_restart_dictionaryless_012byte" ';' mv "fuzz/corpus/fuzz_$1" "fuzz/corpus/fuzz_$1_restart_dictionaryless_012byte"
mkdir "fuzz/corpus/fuzz_$1"
find "fuzz/corpus/fuzz_$1_restart_012byte" -type f -exec mv '{}' "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 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" echo "$(date): RESTART WITH DICTIONARY AND 0-2 BYTE CORPUS"
tar -xvzf "fuzz/012byte.tar.gz" -C "fuzz/corpus/fuzz_$1" tar -xvzf "fuzz/012byte.tar.gz" -C "fuzz/corpus/fuzz_$1"
cargo fuzz run --all-features "fuzz_$1" "fuzz/corpus/fuzz_$1" -- \ cargo fuzz run --all-features "fuzz_$1" "fuzz/corpus/fuzz_$1" -- \

View file

@ -2,8 +2,8 @@
set -euxo pipefail set -euxo pipefail
i=0 i=0
rm -rf "fuzz/corpus/fuzz_$1_iter_0" || true rm -rf "fuzz/corpus/fuzz_$1_iter_0" || true
mkdir "fuzz/corpus/fuzz_$1_iter_0" mv "fuzz/corpus/fuzz_$1" "fuzz/corpus/fuzz_$1_iter_0"
find "fuzz/corpus/fuzz_$1" -type f -exec mv '{}' "fuzz/corpus/fuzz_$1_iter_0" ';' mkdir "fuzz/corpus/fuzz_$1"
while true; do while true; do
j=$((i + 1)) j=$((i + 1))
rm -rf "fuzz/corpus/fuzz_$1_iter_${i}.bak" || true rm -rf "fuzz/corpus/fuzz_$1_iter_${i}.bak" || true
@ -15,8 +15,7 @@ while true; do
if diff "fuzz/corpus/fuzz_$1_iter_${i}.bak" "fuzz/corpus/fuzz_$1_iter_${j}"; then 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 # Last iteration made no difference, so we're done
rm -rf "fuzz/corpus/fuzz_$1" rm -rf "fuzz/corpus/fuzz_$1"
mkdir "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" ';'
rm -rf "fuzz/corpus/fuzz_$1_iter_${i}.bak" rm -rf "fuzz/corpus/fuzz_$1_iter_${i}.bak"
exit 0 exit 0
fi fi