aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob N <rob.norris@klarasystems.com>2024-04-15 20:44:12 +0000
committerGitHub <noreply@github.com>2024-04-15 20:44:12 +0000
commitf22b110f60d83f62b75d20fabb0968ab74324778 (patch)
tree0e19782f2a1cb812e1fafde1c10e0eb5d84b6b6f
parentb181b2e604de3f36feab1092c702cdec5e78c693 (diff)
downloadsrc-f22b110f60d83f62b75d20fabb0968ab74324778.tar.gz
src-f22b110f60d83f62b75d20fabb0968ab74324778.zip
zts: allow running a single test by name only
Specifying a single test is kind of a hassle, because the full relative path under the test suite dir has to be included, but it's not always clear what that path even is. This change allows `-t` to take the name of a single test instead of a full path. If the value has no `/` characters, we search for a file of that name under the test root, and if found, use that as the full test path instead. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Akash B <akash-b@hpe.com> Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de> Signed-off-by: Rob Norris <rob.norris@klarasystems.com> Closes #16088
-rwxr-xr-xscripts/zfs-tests.sh15
1 files changed, 13 insertions, 2 deletions
diff --git a/scripts/zfs-tests.sh b/scripts/zfs-tests.sh
index 179e24d7a0ef..b5b3e4ab351f 100755
--- a/scripts/zfs-tests.sh
+++ b/scripts/zfs-tests.sh
@@ -326,7 +326,8 @@ OPTIONS:
-d DIR Use world-writable DIR for files and loopback devices
-s SIZE Use vdevs of SIZE (default: 4G)
-r RUNFILES Run tests in RUNFILES (default: ${DEFAULT_RUNFILES})
- -t PATH Run single test at PATH relative to test suite
+ -t PATH|NAME Run single test at PATH relative to test suite,
+ or search for test by NAME
-T TAGS Comma separated list of tags (default: 'functional')
-u USER Run single test as USER (default: root)
@@ -340,6 +341,9 @@ $0 -r linux-fast
# Run a single test
$0 -t tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh
+# Run a single test by name
+$0 -t zfs_bookmark_cliargs
+
# Cleanup a previous run of the test suite prior to testing, run the
# default ($(echo "${DEFAULT_RUNFILES}" | sed 's/\.run//')) suite of tests and perform no cleanup on exit.
$0 -x
@@ -450,8 +454,15 @@ post_user = root
post =
outputdir = /var/tmp/test_results
EOF
- SINGLETESTDIR="${SINGLETEST%/*}"
+ if [ "$SINGLETEST" = "${SINGLETEST%/*}" ] ; then
+ NEWSINGLETEST=$(find "$STF_SUITE" -name "$SINGLETEST*" -print -quit)
+ if [ -z "$NEWSINGLETEST" ] ; then
+ fail "couldn't find test matching '$SINGLETEST'"
+ fi
+ SINGLETEST=$NEWSINGLETEST
+ fi
+ SINGLETESTDIR="${SINGLETEST%/*}"
SETUPDIR="$SINGLETESTDIR"
[ "${SETUPDIR#/}" = "$SETUPDIR" ] && SETUPDIR="$STF_SUITE/$SINGLETESTDIR"
[ -x "$SETUPDIR/setup.ksh" ] && SETUPSCRIPT="setup" || SETUPSCRIPT=