#!/bin/bash set -e print_help() { cat <&2 printf 'WARN: redirection to %s EMPTY when jobs > 1\n' "$FUZZER_STDOUT" jobs_opts+=( -jobs="$JOBS" -close_fd_mask=1 ) fi date # Help is at: -help=1 ( set -x >"$FUZZER_STDOUT" build-fuzz/zephyr/zephyr.exe -max_total_time="$TEST_DURATION" \ -verbosity=0 "${jobs_opts[@]}" ./fuzz_corpus ) || { ret=$? >&2 printf 'zephyr.exe returned: %d\n' $ret date die "FAIL. To debug, run: gdb -tui ./build-fuzz/zephyr/zephyr.exe -ex 'run > _ ./crash-...'" } date } setup() { SOF_TOP=$(cd "$(dirname "$0")/.." && pwd) export SOF_TOP export ZEPHYR_TOOLCHAIN_VARIANT=llvm # Define ZEPHYR_BASE so this can be invoked even outside the west workspace. local WS_TOP WS_TOP=$(cd "$SOF_TOP"; west topdir) # The manifest itself is not a west project ZEP_DIR=$(2>/dev/null west list -f '{path}' zephyr || echo 'zephyr') export ZEPHYR_BASE="$WS_TOP/$ZEP_DIR" } die() { >&2 printf '%s ERROR: ' "$0" # We want die() to be usable exactly like printf # shellcheck disable=SC2059 >&2 printf "$@" >&2 printf '\n' exit 1 } main "$@"