PX4-Autopilot/Tools/ci/run_fuzz_tests.sh
Onur Özkan 0d18be5049
fix(scripts): replace hardcoded /bin/bash shebangs
Several helper scripts assumes bash is available at /bin/bash. That breaks on systems
such as NixOS, where bash is resolved from PATH instead of a fixed /bin location and
causes failures like `bad interpreter` during `make format`, e.g., on my host machine:

```sh
$ make format

/PX4-Autopilot/Tools/astyle/check_code_style.sh: /PX4-Autopilot/Tools/astyle/fix_code_style.sh: /bin/bash: bad interpreter: No such file or directory
```

This change switches these entrypoints to `#!/usr/bin/env bash` so they locate bash properly.

No functional changes intended.

Signed-off-by: Onur Özkan <work@onurozkan.dev>
2026-04-01 12:25:28 -08:00

20 lines
556 B
Bash
Executable File

#!/usr/bin/env bash
# This script runs the fuzz tests from a given binary for a certain amount of time
set -e
if [[ "$1" == "--help" || "$1" == "-h" || -z "$1" ]]; then
echo "Usage: $0 <binary> [<duration>]"
echo "duration can be for example 5m or 5h"
exit 0
fi
binary="$1"
duration="$2"
[[ -z "$duration" ]] && duration="1m"
# Iterate over all available fuzz tests in the binary
for t in $("$binary" --fuzz=__non_existent__ 2>&1 | sed '1,/^Valid tests:$/d' | tr -d ' '); do
echo "Running $t"
"$binary" --fuzz="$t" --fuzz_for="$duration"
done