diff options
author | Giuseppe Di Natale <[email protected]> | 2017-02-24 10:59:24 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-02-24 10:59:24 -0800 |
commit | d8fa599fab81109c22253fbe0946cbe0f98ea1c4 (patch) | |
tree | 2abe04c6fb2bfe19a29bfba5da80b8c6471afd2e /scripts/zfs-tests.sh | |
parent | 6d82f98c3d9f83045a801df60f904421b101faa9 (diff) |
Allow zfs-tests to run a single test
Add a -t flag to zfs-tests to allow a user
to run a single test by providing the path
to the test relative to STF_SUITE.
Reviewed-by: George Melikov <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Giuseppe Di Natale <[email protected]>
Closes #5775
Diffstat (limited to 'scripts/zfs-tests.sh')
-rwxr-xr-x | scripts/zfs-tests.sh | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/scripts/zfs-tests.sh b/scripts/zfs-tests.sh index 00a7ceabc..b1be68bd1 100755 --- a/scripts/zfs-tests.sh +++ b/scripts/zfs-tests.sh @@ -43,6 +43,8 @@ FILESIZE="4G" RUNFILE=${RUNFILE:-"linux.run"} FILEDIR=${FILEDIR:-/var/tmp} DISKS=${DISKS:-""} +SINGLETEST=() +SINGLETESTUSER="root" # # Attempt to remove loopback devices and files which where created earlier @@ -167,6 +169,8 @@ OPTIONS: -d DIR Use DIR for files and loopback devices -s SIZE Use vdevs of SIZE (default: 4G) -r RUNFILE Run tests in RUNFILE (default: linux.run) + -t PATH Run single test at PATH + -u USER Run single test as USER (default: root) EXAMPLES: # Run the default (linux) suite of tests and output the configuration used. @@ -182,7 +186,7 @@ $0 -x EOF } -while getopts 'hvqxkfd:s:r:?' OPTION; do +while getopts 'hvqxkfd:s:r:?t:u:' OPTION; do case $OPTION in h) usage @@ -212,6 +216,15 @@ while getopts 'hvqxkfd:s:r:?' OPTION; do r) RUNFILE="$OPTARG" ;; + t) + if [ ${#SINGLETEST[@]} -ne 0 ]; then + fail "-t can only be provided once." + fi + SINGLETEST+=("$OPTARG") + ;; + u) + SINGLETESTUSER="$OPTARG" + ;; ?) usage exit @@ -224,6 +237,51 @@ shift $((OPTIND-1)) FILES=${FILES:-"$FILEDIR/file-vdev0 $FILEDIR/file-vdev1 $FILEDIR/file-vdev2"} LOOPBACKS=${LOOPBACKS:-""} +if [ ${#SINGLETEST[@]} -ne 0 ]; then + RUNFILEDIR="/var/tmp" + RUNFILE="zfs-tests.$$.run" + SINGLEQUIET="False" + + if [ -n "$QUIET" ]; then + SINGLEQUIET="True" + fi + + cat >$RUNFILEDIR/$RUNFILE << EOF +[DEFAULT] +pre = +quiet = $SINGLEQUIET +pre_user = root +user = $SINGLETESTUSER +timeout = 600 +post_user = root +post = +outputdir = /var/tmp/test_results +EOF + for t in "${SINGLETEST[@]}" + do + SINGLETESTDIR=$(dirname "$t") + SINGLETESTFILE=$(basename "$t") + SETUPSCRIPT= + CLEANUPSCRIPT= + + if [ -f "$SINGLETESTDIR/setup.ksh" ]; then + SETUPSCRIPT="setup" + fi + + if [ -f "$SINGLETESTDIR/cleanup.ksh" ]; then + CLEANUPSCRIPT="cleanup" + fi + + cat >>$RUNFILEDIR/$RUNFILE << EOF + +[$SINGLETESTDIR] +tests = ['$SINGLETESTFILE'] +pre = $SETUPSCRIPT +post = $CLEANUPSCRIPT +EOF + done +fi + # # Attempt to locate the runfile describing the test workload. # @@ -350,4 +408,8 @@ ${TEST_RUNNER} ${QUIET} -c ${RUNFILE} -i ${STF_SUITE} RESULT=$? echo +if [ ${#SINGLETEST[@]} -ne 0 ]; then + rm -f "$RUNFILEDIR/$RUNFILE" &>/dev/null +fi + exit ${RESULT} |