Skip to content

Commit

Permalink
Log ZTS test name to dmesg
Browse files Browse the repository at this point in the history
Log each test name to dmesg to help post-mortem test failures.
Specifically, to help debug #10940.

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
  • Loading branch information
tonyhutter committed Sep 17, 2020
1 parent a57f954 commit 115cd16
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
8 changes: 4 additions & 4 deletions TEST
Expand Up @@ -5,21 +5,21 @@
#TEST_PREPARE_SHARES="yes"

### ztest
#TEST_ZTEST_SKIP="yes"
TEST_ZTEST_SKIP="yes"
#TEST_ZTEST_TIMEOUT=1800
#TEST_ZTEST_DIR="/var/tmp/"
#TEST_ZTEST_OPTIONS="-V"
#TEST_ZTEST_CORE_DIR="/mnt/zloop"

### zimport
#TEST_ZIMPORT_SKIP="yes"
TEST_ZIMPORT_SKIP="yes"
#TEST_ZIMPORT_DIR="/var/tmp/zimport"
#TEST_ZIMPORT_VERSIONS="master installed"
#TEST_ZIMPORT_POOLS="zol-0.6.1 zol-0.6.2 master installed"
#TEST_ZIMPORT_OPTIONS="-c"

### xfstests
#TEST_XFSTESTS_SKIP="yes"
TEST_XFSTESTS_SKIP="yes"
#TEST_XFSTESTS_URL="https://github.com/behlendorf/xfstests/archive/"
#TEST_XFSTESTS_VER="zfs.tar.gz"
#TEST_XFSTESTS_POOL="tank"
Expand All @@ -38,7 +38,7 @@
#TEST_ZFSTESTS_TAGS="functional"

### zfsstress
#TEST_ZFSSTRESS_SKIP="yes"
TEST_ZFSSTRESS_SKIP="yes"
#TEST_ZFSSTRESS_URL="https://github.com/nedbass/zfsstress/archive/"
#TEST_ZFSSTRESS_VER="master.tar.gz"
#TEST_ZFSSTRESS_RUNTIME=300
Expand Down
29 changes: 29 additions & 0 deletions tests/zfs-tests/include/libtest.shlib
Expand Up @@ -268,6 +268,30 @@ function default_setup_no_mountpoint
log_pass
}


function backtrace {
typeset -a stack
# Use "set -u" and an undefined variable access in a subshell
# to figure out how we got here. Each token of the result is
# stored as an element in an indexed array named "stack".
set -A stack $(exec 2>&1; set -u; unset __unset__; echo $__unset__)

# Trim the last entries in stack array until we find the one that
# matches the name of this function.
typeset i=0
for (( i = ${#stack[@]} - 1; i >= 0; i-- )); do
[[ "${stack[i]}" == "${.sh.fun}:" ]] && break
done

# Print the name of the function that called this one, stripping off
# the [lineno] and appending any arguments provided to this function.
print -u2 "${stack[i-1]/\[[0-9]*\]} $*"
# Print the backtrace.
for (( i--; i >= 0; i-- )); do
print -u2 "\t${stack[i]%:}"
done
}

#
# Given a list of disks, setup storage pools and datasets.
#
Expand All @@ -279,6 +303,11 @@ function default_setup_noexit
typeset no_mountpoint=$4
log_note begin default_setup_noexit

# Crudely log to dmesg which test we're running for post-mortem
me="$(ps aux | grep zfs-tests) | head -n 1)"
echo "ZTS: running $me ($0)" > /dev/kmsg
backtrace > /dev/kmsg

if is_global_zone; then
if poolexists $TESTPOOL ; then
destroy_pool $TESTPOOL
Expand Down

0 comments on commit 115cd16

Please sign in to comment.