autotest/common: define xtrace_restore as an alias

This doesn't make difference right now, but would be
useful if we printed $BASH_SOURCE or $LINENO in xtrace
(via PS4). Those two will now point to the original
line where xtrace_restore was called rather than
always the single line inside autotest_common.sh.

Change-Id: Idf3ac8d00ad9610960678351014334013149b88d
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456964
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Darek Stojaczyk 2019-05-13 16:09:51 +02:00
parent 416c5e29ab
commit fadcb08db3

View File

@ -3,6 +3,10 @@ function xtrace_disable() {
set +x
}
xtrace_disable
set -e
shopt -s expand_aliases
# Dummy function to be called after restoring xtrace just so that it appears in the
# xtrace log. This way we can consistently track when xtrace is enabled/disabled.
function xtrace_enable() {
@ -11,17 +15,10 @@ function xtrace_enable() {
function xtrace_dummy() { :; }
}
function xtrace_restore() {
if [[ "$PREV_BASH_OPTS" != *"x"* ]]; then
return
fi
set -x
xtrace_enable
}
xtrace_disable
set -e
# 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_enable; fi'
: ${RUN_NIGHTLY:=0}
export RUN_NIGHTLY