fuzz: add argument to support other sanitizers

Allows for switching out zephyr configs for other sanitizers

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
This commit is contained in:
Curtis Malainey 2024-09-05 15:35:18 -07:00 committed by Kai Vehmanen
parent 7ec73c72f6
commit f383b0ffab
3 changed files with 10 additions and 2 deletions

View File

@ -8,7 +8,6 @@ CONFIG_SYS_HEAP_BIG_ONLY=y
CONFIG_ZEPHYR_NATIVE_DRIVERS=y CONFIG_ZEPHYR_NATIVE_DRIVERS=y
CONFIG_ARCH_POSIX_LIBFUZZER=y CONFIG_ARCH_POSIX_LIBFUZZER=y
CONFIG_ZEPHYR_POSIX_FUZZ_TICKS=100 CONFIG_ZEPHYR_POSIX_FUZZ_TICKS=100
CONFIG_ASAN=y
# Override incompatible options found in sof/app/prj.conf # Override incompatible options found in sof/app/prj.conf
# to silence build time warnings # to silence build time warnings

View File

@ -0,0 +1 @@
CONFIG_ASAN=y

View File

@ -12,6 +12,7 @@ Usage:
-i4 Appends: -- -DCONFIG_IPC_MAJOR_4=y + fuzz_IPC4_features.conf -i4 Appends: -- -DCONFIG_IPC_MAJOR_4=y + fuzz_IPC4_features.conf
-i3 See above -i3 See above
-s Which sanitizer to use, defaults to address
-p Delete build-fuzz/ first ("pristine") -p Delete build-fuzz/ first ("pristine")
-b Do not run/fuzz: stop after the build. -b Do not run/fuzz: stop after the build.
-t n Fuzz for n seconds. -t n Fuzz for n seconds.
@ -87,15 +88,17 @@ main()
local BUILD_ONLY=false local BUILD_ONLY=false
local FUZZER_STDOUT=/dev/stdout # bashism local FUZZER_STDOUT=/dev/stdout # bashism
local TEST_DURATION=3 local TEST_DURATION=3
local SANITIZER=address
local IPC local IPC
# Parse "$@". getopts stops after '--' # Parse "$@". getopts stops after '--'
while getopts "i:hj:po:t:b" opt; do while getopts "i:hj:ps:o:t:b" opt; do
case "$opt" in case "$opt" in
i) IPC="$OPTARG";; i) IPC="$OPTARG";;
h) print_help; exit 0;; h) print_help; exit 0;;
j) if [ "$OPTARG" -eq 0 ]; then JOBS=$(nproc); else JOBS="$OPTARG"; fi;; j) if [ "$OPTARG" -eq 0 ]; then JOBS=$(nproc); else JOBS="$OPTARG"; fi;;
p) PRISTINE=true;; p) PRISTINE=true;;
s) SANITIZER="$OPTARG";;
o) FUZZER_STDOUT="$OPTARG";; o) FUZZER_STDOUT="$OPTARG";;
t) TEST_DURATION="$OPTARG";; t) TEST_DURATION="$OPTARG";;
b) BUILD_ONLY=true;; b) BUILD_ONLY=true;;
@ -115,6 +118,11 @@ main()
conf_files_list+=";configs/fuzz_IPC${IPC}_features.conf" conf_files_list+=";configs/fuzz_IPC${IPC}_features.conf"
fi fi
case $SANITIZER in
address) conf_files_list+=";configs/fuzz_asan.conf";;
*) echo "Unknown fuzzer type"; print_help; exit 1;;
esac
# Note there's never any reason to delete fuzz_corpus/. # Note there's never any reason to delete fuzz_corpus/.
# Don't trust `west build -p` because it is not 100% unreliable, # Don't trust `west build -p` because it is not 100% unreliable,
# especially not when doing unusual toolchain things. # especially not when doing unusual toolchain things.