From ad6ec9b8b2f516ba2d3cd02fc5c4132cc23828b9 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Mon, 4 Dec 2023 09:26:49 -0500 Subject: [PATCH] allow user of build_fuzz.sh to specify a directory to fuzz in --- scripts/build_fuzz.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/build_fuzz.sh b/scripts/build_fuzz.sh index 0f7ad7de8ede..54ed02c27e21 100755 --- a/scripts/build_fuzz.sh +++ b/scripts/build_fuzz.sh @@ -1,5 +1,11 @@ #!/usr/bin/env bash +# First argument is the time, in seconds, to run each fuzz test for. +# If not provided, defaults to 1 second. +# +# Second argument is the directory to run fuzz tests in. +# If not provided, defaults to the current directory. + set -euo pipefail # Mostly taken from https://github.com/golang/go/issues/46312#issuecomment-1153345129 @@ -10,7 +16,9 @@ AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) source "$AVALANCHE_PATH"/scripts/constants.sh fuzzTime=${1:-1} -files=$(grep -r --include='**_test.go' --files-with-matches 'func Fuzz' .) +fuzzDir=${2:-.} + +files=$(grep -r --include='**_test.go' --files-with-matches 'func Fuzz' $fuzzDir) failed=false for file in ${files} do