aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-runner
diff options
context:
space:
mode:
authoryouzhongyang <[email protected]>2021-10-20 19:07:19 -0400
committerGitHub <[email protected]>2021-10-20 16:07:19 -0700
commitec64fdb93d144ab1884097cfd36e18b62a2db848 (patch)
treeb0f072cb457e720ab25a074989440e55845f72a3 /tests/test-runner
parent1886cdfcfb970d57d4a2ae40b56d2dab2f029e2b (diff)
Skip snapshot in zfs_iter_mounted()
The intention of the zfs_iter_mounted() is to traverse the dataset and its descendants, not the snapshots. The current code can cause a mounted snapshot to be included and thus zfs_open() on the snapshot with ZFS_TYPE_FILESYSTEM would print confusing message such as "cannot open 'rpool/fs@snap': snapshot delimiter '@' is not expected here". Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Youzhong Yang <[email protected]> Closes #12447 Closes #12448
Diffstat (limited to 'tests/test-runner')
-rw-r--r--tests/test-runner/include/logapi.shlib50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/test-runner/include/logapi.shlib b/tests/test-runner/include/logapi.shlib
index 5a7e76c0d..c9c01ab75 100644
--- a/tests/test-runner/include/logapi.shlib
+++ b/tests/test-runner/include/logapi.shlib
@@ -68,6 +68,16 @@ function log_must
(( $? != 0 )) && log_fail
}
+# Execute a positive test (expecting no stderr) and exit $STF_FAIL
+# if test fails
+# $@ - command to execute
+
+function log_must_nostderr
+{
+ log_pos_nostderr "$@"
+ (( $? != 0 )) && log_fail
+}
+
# Execute a positive test but retry the command on failure if the output
# matches an expected pattern. Otherwise behave like log_must and exit
# $STF_FAIL is test fails.
@@ -292,6 +302,46 @@ function log_pos
return $status
}
+# Execute and print command with status where success equals zero result
+# and no stderr output
+#
+# $@ command to execute
+#
+# return 0 if command succeeds and no stderr output
+# return 1 othersie
+
+function log_pos_nostderr
+{
+ typeset out=""
+ typeset logfile="/tmp/log.$$"
+
+ while [[ -e $logfile ]]; do
+ logfile="$logfile.$$"
+ done
+
+ "$@" 2>$logfile
+ typeset status=$?
+ out="cat $logfile"
+ typeset out_msg=$($out)
+
+ if (( $status != 0 )) ; then
+ print -u2 $out_msg
+ _printerror "$@" "exited $status"
+ else
+ if [[ ! -z "$out_msg" ]]; then
+ print -u2 $out_msg
+ _printerror "$@" "message in stderr" \
+ " exited $status"
+ status=1
+ else
+ [[ -n $LOGAPI_DEBUG ]] && cat $logfile
+ _printsuccess "$@"
+ fi
+ fi
+ _recursive_output $logfile "false"
+ return $status
+}
+
# Set an exit handler
#
# $@ - function(s) to perform on exit