From a8d016910a33f0611402fdf0c42d73c2971724ff Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Wed, 5 Feb 2020 10:33:53 -0500 Subject: [PATCH] test/common: Make sure that extdebug is enabled as soon as possible if given script, which executes under the debug tracer, fails before xtrace_restore() is called, the BASH_ARGC[] will miss all the arguments which were passed down till that very point. Similar case can be experienced after tracer is disabled as then all the arguments hold by BASH_ARG{C,V}[] become unavailable (i.e. until tracer is enabled again). Since there's no actual benefit from toggling the extdebug (in fact, it could break DEBUG|RETURN traps if ever used), enable it once when autotest_common.sh is sourced and keep it enabled throughout entire execution of given script. Change-Id: I01001ead1570967a2e550d993f85f12b9f62553e Signed-off-by: Michal Berger Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/477 Tested-by: SPDK CI Jenkins Reviewed-by: Darek Stojaczyk Reviewed-by: Ben Walker --- test/common/autotest_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 8e9ceb00646..a534a1f0370 100644 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -5,7 +5,6 @@ function xtrace_disable() { XTRACE_DISABLED="yes" fi set +x - shopt -u extdebug elif [ -z $XTRACE_NESTING_LEVEL ]; then XTRACE_NESTING_LEVEL=1 else @@ -31,7 +30,7 @@ function xtrace_enable() { alias xtrace_restore=\ 'if [ -z $XTRACE_NESTING_LEVEL ]; then if [[ "$PREV_BASH_OPTS" == *"x"* ]]; then - XTRACE_DISABLED="no"; PREV_BASH_OPTS=""; shopt -s extdebug; set -x; xtrace_enable; + XTRACE_DISABLED="no"; PREV_BASH_OPTS=""; set -x; xtrace_enable; fi else XTRACE_NESTING_LEVEL=$((--XTRACE_NESTING_LEVEL)); @@ -1065,6 +1064,7 @@ function opal_revert_cleanup { } set -o errtrace +shopt -s extdebug trap "trap - ERR; print_backtrace >&2" ERR PS4=' \t \$ '