From 39fe5c849b91274e98052862e89ee1a785200b38 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Mon, 30 Dec 2019 12:19:46 -0700 Subject: [PATCH] autotest_common: fix xtrace_restore_enable My previous patch enabling this to be called recursively didn't take into account that a single call to xtrace_restore would override multiple levels of xtrace_disable nesting. This change fixes that. fixes: 190b2245c5ed9ec3483a4b0e87629419e88d4e62 Signed-off-by: Seth Howell Change-Id: I2167ba460e68223c9426b3d71e9c17019f947924 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478959 Community-CI: SPDK CI Jenkins Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Paul Luse Reviewed-by: Shuhei Matsumoto --- test/common/autotest_common.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index cbf3fbfec..6a992158b 100644 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -5,6 +5,10 @@ function xtrace_disable() { XTRACE_DISABLED="yes" fi set +x + elif [ -z $XTRACE_NESTING_LEVEL ]; then + XTRACE_NESTING_LEVEL=1 + else + XTRACE_NESTING_LEVEL=$((++XTRACE_NESTING_LEVEL)) fi } @@ -23,7 +27,17 @@ function xtrace_enable() { # Keep it as alias to avoid xtrace_enable backtrace always pointing to xtrace_restore. # xtrace_enable will appear as called directly from the user script, from the same line # that "called" xtrace_restore. -alias xtrace_restore='if [[ "$PREV_BASH_OPTS" == *"x"* ]]; then set -x; XTRACE_DISABLED="no"; PREV_BASH_OPTS=""; xtrace_enable; fi' +alias xtrace_restore=\ +'if [ -z $XTRACE_NESTING_LEVEL ]; then + if [[ "$PREV_BASH_OPTS" == *"x"* ]]; then + XTRACE_DISABLED="no"; PREV_BASH_OPTS=""; set -x; xtrace_enable; + fi +else + XTRACE_NESTING_LEVEL=$((--XTRACE_NESTING_LEVEL)); + if [ $XTRACE_NESTING_LEVEL -eq "0" ]; then + unset XTRACE_NESTING_LEVEL + fi +fi' : ${RUN_NIGHTLY:=0} export RUN_NIGHTLY @@ -950,7 +964,9 @@ trap "trap - ERR; print_backtrace >&2" ERR PS4=' \t \$ ' if $SPDK_AUTOTEST_X; then - # explicitly enable xtraces + # explicitly enable xtraces, overriding any tracking information. + unset XTRACE_DISABLED + unset XTRACE_NESTING_LEVEL set -x xtrace_enable else