From 1849d52bb8184fd0ec975586a4677b2e689fc76d Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 2 Feb 2024 21:56:54 +0000 Subject: [PATCH] scripts/fuzz.sh: add a -p "pristine" flag that deletes build-fuzz/ It's slower but safer when changing some parameters. Signed-off-by: Marc Herbert --- scripts/fuzz.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/fuzz.sh b/scripts/fuzz.sh index ee3aadc96872..18bcbbe6a01f 100755 --- a/scripts/fuzz.sh +++ b/scripts/fuzz.sh @@ -7,10 +7,10 @@ print_help() Usage: - $0 -b -- -DOVERLAY_CONFIG=stub_build_all_ipc4.conf -DEXTRA_CFLAGS=... + $0 -b -- -DOVERLAY_CONFIG=stub_build_all_ipc4.conf -DEXTRA_CFLAGS="-O0 -g3" ... $0 -t 500 -- -DOVERLAY_CONFIG=stub_build_all_ipc3.conf ... - + -p Delete build-fuzz/ first ("pristine") -b Do not run/fuzz: stop after the build. -t n Fuzz for n seconds. -o ofile Redirect the fuzzer's extremely verbose stdout. The @@ -71,11 +71,13 @@ main() { setup - BUILD_ONLY=false + local BUILD_ONLY=false + local PRISTINE=false # Parse "$@". getopts stops after '--' - while getopts "ho:t:b" opt; do + while getopts "hpo:t:b" opt; do case "$opt" in h) print_help; exit 0;; + p) PRISTINE=true;; o) FUZZER_STDOUT="$OPTARG";; t) TEST_DURATION="$OPTARG";; b) BUILD_ONLY=true;; @@ -102,6 +104,11 @@ main() -DCONFIG_ASAN=y ) + # Note there's never any reason to delete fuzz_corpus/. + # Don't trust `west build -p` because it is not 100% unreliable, + # especially not when doing unusual toolchain things. + if $PRISTINE; then rm -rf build-fuzz/; fi + (set -x # When passing conflicting -DVAR='VAL UE1' -DVAR='VAL UE2' to CMake, # the last 'VAL UE2' wins. Previous ones are silently ignored.