Skip to content

Instantly share code, notes, and snippets.

@practicalswift
Created January 25, 2021 12:23
Show Gist options
  • Save practicalswift/e3de0d96af31f42d3a2f5bcb6f631432 to your computer and use it in GitHub Desktop.
Save practicalswift/e3de0d96af31f42d3a2f5bcb6f631432 to your computer and use it in GitHub Desktop.
#!/bin/bash
RUNNING_TIME=${1:-2}
FUZZ_LOG=$(mktemp)
for FUZZER in $(PRINT_ALL_FUZZ_TARGETS_AND_ABORT=1 src/test/fuzz/fuzz 2> /dev/null | sort -u); do
echo -n "Running fuzzer \"${FUZZER}\" for ${RUNNING_TIME} second(s): "
if ! FUZZ="${FUZZER}" UBSAN_OPTIONS="print_stacktrace=1:halt_on_error=1:report_error_type=1:suppressions=$(pwd)/test/sanitizer_suppressions/ubsan" src/test/fuzz/fuzz -max_total_time="${RUNNING_TIME}" 2> "${FUZZ_LOG}"; then
echo "FAILED"
echo
echo "Fuzzer \"${FUZZER}\" exited with status code $?:"
echo
cat "${FUZZ_LOG}"
exit 1
fi
if ! grep -qE "^Done .* runs in .* second" "${FUZZ_LOG}"; then
echo "FAILED"
echo
echo "Fuzzer \"${FUZZER}\" did not generate expected libFuzzer output:"
echo
cat "${FUZZ_LOG}"
exit 1
fi
echo "✅"
done
rm -f "${FUZZ_LOG}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment