aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-runner
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2020-03-12 13:50:51 -0400
committerGitHub <[email protected]>2020-03-12 10:50:51 -0700
commit94eb65b4c1ff02653c00c8f30b1a2a9617afa556 (patch)
treec68b4f93fbce4ec22a9ebfb9e1bf89e91122e12a /tests/test-runner
parentcdbc34fc2b954e504d42e25ad5c8e92504908813 (diff)
ZTS: Use correct signal numbers for status checks
Different operating systems encode exit status in different ways. The logapi shell library assumes the Solaris meaning of exit codes, which is not correct on other platforms. Define the needed constants according to the platform we are running on and use those to decode process exit status. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #10121
Diffstat (limited to 'tests/test-runner')
-rw-r--r--tests/test-runner/include/logapi.shlib35
1 files changed, 29 insertions, 6 deletions
diff --git a/tests/test-runner/include/logapi.shlib b/tests/test-runner/include/logapi.shlib
index 3c8324d57..86a345b7a 100644
--- a/tests/test-runner/include/logapi.shlib
+++ b/tests/test-runner/include/logapi.shlib
@@ -165,6 +165,29 @@ function log_mustnot_expect
(( $? != 0 )) && log_fail
}
+# Exit status encoding is platform-dependent
+case $(uname) in
+Darwin|FreeBSD)
+ EXIT_SIGNAL=128
+ SIGBUS=10
+ SIGSEGV=11
+ ;;
+illumos)
+ EXIT_SIGNAL=256
+ SIGBUS=7
+ SIGSEGV=11
+ ;;
+Linux|*)
+ EXIT_SIGNAL=128
+ SIGBUS=7
+ SIGSEGV=11
+ ;;
+esac
+EXIT_SUCCESS=0
+EXIT_NOTFOUND=127
+EXIT_SIGBUS=$((EXIT_SIGNAL + SIGBUS))
+EXIT_SIGSEGV=$((EXIT_SIGNAL + SIGSEGV))
+
# Execute and print command with status where success equals non-zero result
# or output includes expected keyword
#
@@ -191,19 +214,19 @@ function log_neg_expect
out="cat $logfile"
# unexpected status
- if (( $status == 0 )); then
+ if (( $status == EXIT_SUCCESS )); then
print -u2 $($out)
_printerror "$@" "unexpectedly exited $status"
# missing binary
- elif (( $status == 127 )); then
+ elif (( $status == EXIT_NOTFOUND )); then
print -u2 $($out)
_printerror "$@" "unexpectedly exited $status (File not found)"
- # bus error - core dump (256+signal, SIGBUS=7)
- elif (( $status == 263 )); then
+ # bus error - core dump
+ elif (( $status == EXIT_SIGBUS )); then
print -u2 $($out)
_printerror "$@" "unexpectedly exited $status (Bus Error)"
- # segmentation violation - core dump (256+signal, SIGSEGV=11)
- elif (( $status == 267 )); then
+ # segmentation violation - core dump
+ elif (( $status == EXIT_SIGSEGV )); then
print -u2 $($out)
_printerror "$@" "unexpectedly exited $status (SEGV)"
else