Skip to content

Commit

Permalink
fix(lazy-pages-fuzzer, ci): add error output on lazy pages fuzzer's s…
Browse files Browse the repository at this point in the history
…moke test fail
  • Loading branch information
ByteNacked committed Aug 28, 2024
1 parent 3bf4156 commit 9f9061e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions scripts/check-lazy-pages-fuzzer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ SCRIPTS="$(cd "$(dirname "$SELF")"/ && pwd)"
RUN_DURATION_SECS=10
PROCESS_NAME="lazy-pages-fuzzer-fuzz"
OUTPUT_FILE="lazy_pages_fuzz_run"
# Don't need big input for smoke test
INITIAL_INPUT_SIZE=1000
FUZZER_INPUT_FILE=utils/lazy-pages-fuzzer/fuzz/corpus/main/check-fuzzer-bytes

main() {
echo " >> Checking lazy pages fuzzer"
echo " >> Getting random bytes from /dev/urandom"
# Fuzzer expects a minimal input size of 350 KiB. Without providing a corpus of the same or larger
# size fuzzer will stuck for a long time with trying to test the target using 0..100 bytes.
mkdir -p utils/lazy-pages-fuzzer/fuzz/corpus/main
dd if=/dev/urandom of=utils/lazy-pages-fuzzer/fuzz/corpus/main/check-fuzzer-bytes bs=1 count="$INITIAL_INPUT_SIZE"
dd if=/dev/urandom of=$FUZZER_INPUT_FILE bs=1 count="$INITIAL_INPUT_SIZE"

# Remove lazy pages fuzzer run file
rm -f $OUTPUT_FILE
Expand All @@ -29,7 +30,7 @@ main() {
( RUST_LOG="error,lazy_pages_fuzzer::lazy_pages=trace" RUST_BACKTRACE=1 ./scripts/gear.sh test lazy-pages-fuzz "" > $OUTPUT_FILE 2>&1 ) & \
sleep ${RUN_DURATION_SECS} ; \
kill -s KILL $(pidof $PROCESS_NAME) 2> /dev/null ; \
echo " >> Lazy pages fuzzer run completed" ;
echo " >> Lazy pages fuzzer run finished" ;

# Trim output after SIGKILL backtrace
OUTPUT=$(sed '/SIGKILL/,$d' $OUTPUT_FILE)
Expand All @@ -40,9 +41,17 @@ main() {
echo "Success"
exit 0
else
cat $OUTPUT_FILE
echo "Failed"
print_seed
exit 1
fi
}

print_seed() {
echo "Seed start: \""
xxd -p $FUZZER_INPUT_FILE | tr --delete '\n'
echo -e "\n\" Seed end."
}

main

0 comments on commit 9f9061e

Please sign in to comment.