aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/tests/test-runner/include/logapi.shlib
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/openzfs/tests/test-runner/include/logapi.shlib')
-rw-r--r--sys/contrib/openzfs/tests/test-runner/include/logapi.shlib126
1 files changed, 28 insertions, 98 deletions
diff --git a/sys/contrib/openzfs/tests/test-runner/include/logapi.shlib b/sys/contrib/openzfs/tests/test-runner/include/logapi.shlib
index 33423a7e3c65..094e8cb21a33 100644
--- a/sys/contrib/openzfs/tests/test-runner/include/logapi.shlib
+++ b/sys/contrib/openzfs/tests/test-runner/include/logapi.shlib
@@ -26,7 +26,11 @@
# Copyright (c) 2012, 2020 by Delphix. All rights reserved.
#
-. ${STF_TOOLS}/include/stf.shlib
+STF_PASS=0
+STF_FAIL=1
+STF_UNRESOLVED=2
+STF_UNSUPPORTED=4
+STF_UNTESTED=5
# Output an assertion
#
@@ -54,7 +58,7 @@ function log_note
function log_neg
{
- log_neg_expect "" "$@"
+ log_neg_expect "" "$@"
}
# Execute a positive test and exit $STF_FAIL is test fails
@@ -85,7 +89,6 @@ function log_must_nostderr
#
function log_must_retry
{
- typeset out=""
typeset logfile="/tmp/log.$$"
typeset status=1
typeset expect=$1
@@ -100,14 +103,10 @@ function log_must_retry
while (( $retry > 0 )); do
"$@" 2>$logfile
status=$?
- out="cat $logfile"
if (( $status == 0 )); then
- $out | egrep -i "internal error|assertion failed" \
- > /dev/null 2>&1
- # internal error or assertion failed
- if [[ $? -eq 0 ]]; then
- print -u2 $($out)
+ if grep -qEi "internal error|assertion failed" $logfile; then
+ cat $logfile >&2
_printerror "$@" "internal error or" \
" assertion failure exited $status"
status=1
@@ -117,9 +116,8 @@ function log_must_retry
fi
break
else
- $out | grep -i "$expect" > /dev/null 2>&1
- if (( $? == 0 )); then
- print -u2 $($out)
+ if grep -qi "$expect" $logfile; then
+ cat $logfile >&2
_printerror "$@" "Retry in $delay seconds"
sleep $delay
@@ -132,7 +130,7 @@ function log_must_retry
done
if (( $status != 0 )) ; then
- print -u2 $($out)
+ cat $logfile >&2
_printerror "$@" "exited $status"
fi
@@ -197,7 +195,6 @@ EXIT_SIGSEGV=$((EXIT_SIGNAL + SIGSEGV))
function log_neg_expect
{
- typeset out=""
typeset logfile="/tmp/log.$$"
typeset ret=1
typeset expect=$1
@@ -209,38 +206,33 @@ function log_neg_expect
"$@" 2>$logfile
typeset status=$?
- out="cat $logfile"
# unexpected status
if (( $status == EXIT_SUCCESS )); then
- print -u2 $($out)
+ cat $logfile >&2
_printerror "$@" "unexpectedly exited $status"
# missing binary
elif (( $status == EXIT_NOTFOUND )); then
- print -u2 $($out)
+ cat $logfile >&2
_printerror "$@" "unexpectedly exited $status (File not found)"
# bus error - core dump
elif (( $status == EXIT_SIGBUS )); then
- print -u2 $($out)
+ cat $logfile >&2
_printerror "$@" "unexpectedly exited $status (Bus Error)"
# segmentation violation - core dump
elif (( $status == EXIT_SIGSEGV )); then
- print -u2 $($out)
+ cat $logfile >&2
_printerror "$@" "unexpectedly exited $status (SEGV)"
else
- $out | egrep -i "internal error|assertion failed" \
- > /dev/null 2>&1
- # internal error or assertion failed
- if (( $? == 0 )); then
- print -u2 $($out)
+ if grep -qEi "internal error|assertion failed" $logfile; then
+ cat $logfile >&2
_printerror "$@" "internal error or assertion failure" \
" exited $status"
elif [[ -n $expect ]] ; then
- $out | grep -i "$expect" > /dev/null 2>&1
- if (( $? == 0 )); then
+ if grep -qi "$expect" $logfile; then
ret=0
else
- print -u2 $($out)
+ cat $logfile >&2
_printerror "$@" "unexpectedly exited $status"
fi
else
@@ -264,7 +256,6 @@ function log_neg_expect
function log_pos
{
- typeset out=""
typeset logfile="/tmp/log.$$"
while [[ -e $logfile ]]; do
@@ -273,17 +264,13 @@ function log_pos
"$@" 2>$logfile
typeset status=$?
- out="cat $logfile"
if (( $status != 0 )) ; then
- print -u2 $($out)
+ cat $logfile >&2
_printerror "$@" "exited $status"
else
- $out | egrep -i "internal error|assertion failed" \
- > /dev/null 2>&1
- # internal error or assertion failed
- if [[ $? -eq 0 ]]; then
- print -u2 $($out)
+ if grep -qEi "internal error|assertion failed" $logfile; then
+ cat $logfile >&2
_printerror "$@" "internal error or assertion failure" \
" exited $status"
status=1
@@ -306,7 +293,6 @@ function log_pos
function log_pos_nostderr
{
- typeset out=""
typeset logfile="/tmp/log.$$"
while [[ -e $logfile ]]; do
@@ -315,15 +301,13 @@ function log_pos_nostderr
"$@" 2>$logfile
typeset status=$?
- out="cat $logfile"
- typeset out_msg=$($out)
if (( $status != 0 )) ; then
- print -u2 $out_msg
+ cat $logfile >&2
_printerror "$@" "exited $status"
else
- if [[ ! -z "$out_msg" ]]; then
- print -u2 $out_msg
+ if [ -s "$logfile" ]; then
+ cat $logfile >&2
_printerror "$@" "message in stderr" \
" exited $status"
status=1
@@ -392,15 +376,6 @@ function log_unresolved
_endlog $STF_UNRESOLVED "$@"
}
-# Perform cleanup and exit $STF_NOTINUSE
-#
-# $@ - message text
-
-function log_notinuse
-{
- _endlog $STF_NOTINUSE "$@"
-}
-
# Perform cleanup and exit $STF_UNSUPPORTED
#
# $@ - message text
@@ -419,51 +394,6 @@ function log_untested
_endlog $STF_UNTESTED "$@"
}
-# Perform cleanup and exit $STF_UNINITIATED
-#
-# $@ - message text
-
-function log_uninitiated
-{
- _endlog $STF_UNINITIATED "$@"
-}
-
-# Perform cleanup and exit $STF_NORESULT
-#
-# $@ - message text
-
-function log_noresult
-{
- _endlog $STF_NORESULT "$@"
-}
-
-# Perform cleanup and exit $STF_WARNING
-#
-# $@ - message text
-
-function log_warning
-{
- _endlog $STF_WARNING "$@"
-}
-
-# Perform cleanup and exit $STF_TIMED_OUT
-#
-# $@ - message text
-
-function log_timed_out
-{
- _endlog $STF_TIMED_OUT "$@"
-}
-
-# Perform cleanup and exit $STF_OTHER
-#
-# $@ - message text
-
-function log_other
-{
- _endlog $STF_OTHER "$@"
-}
-
function set_main_pid
{
_MAINPID=$1
@@ -481,12 +411,12 @@ function _execute_testfail_callbacks
{
typeset callback
- print "$TESTFAIL_CALLBACKS:" | while read -d ":" callback; do
+ while read -d ":" callback; do
if [[ -n "$callback" ]] ; then
log_note "Performing test-fail callback ($callback)"
$callback
fi
- done
+ done <<<"$TESTFAIL_CALLBACKS:"
}
# Perform cleanup and exit
@@ -534,7 +464,7 @@ function _endlog
function _printline
{
- print "$@"
+ echo "$@"
}
# Output an error message