Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SKIP SOF-TEST] fuzz: add argument to support other sanitizers #9444

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/boards/native_sim_libfuzzer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ CONFIG_SYS_HEAP_BIG_ONLY=y
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
CONFIG_ARCH_POSIX_LIBFUZZER=y
CONFIG_ZEPHYR_POSIX_FUZZ_TICKS=100
CONFIG_ASAN=y

# Override incompatible options found in sof/app/prj.conf
# to silence build time warnings
Expand Down
1 change: 1 addition & 0 deletions app/configs/fuzz_asan.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_ASAN=y
10 changes: 9 additions & 1 deletion scripts/fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Usage:

-i4 Appends: -- -DCONFIG_IPC_MAJOR_4=y + fuzz_IPC4_features.conf
-i3 See above
-s Which sanitizer to use, defaults to address
-p Delete build-fuzz/ first ("pristine")
-b Do not run/fuzz: stop after the build.
-t n Fuzz for n seconds.
Expand Down Expand Up @@ -87,15 +88,17 @@ main()
local BUILD_ONLY=false
local FUZZER_STDOUT=/dev/stdout # bashism
local TEST_DURATION=3
local SANITIZER=address
local IPC

# 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
i) IPC="$OPTARG";;
h) print_help; exit 0;;
j) if [ "$OPTARG" -eq 0 ]; then JOBS=$(nproc); else JOBS="$OPTARG"; fi;;
p) PRISTINE=true;;
s) SANITIZER="$OPTARG";;
o) FUZZER_STDOUT="$OPTARG";;
t) TEST_DURATION="$OPTARG";;
b) BUILD_ONLY=true;;
Expand All @@ -115,6 +118,11 @@ main()
conf_files_list+=";configs/fuzz_IPC${IPC}_features.conf"
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/.
# Don't trust `west build -p` because it is not 100% unreliable,
# especially not when doing unusual toolchain things.
Expand Down