Commit fadcb08d authored by Darek Stojaczyk's avatar Darek Stojaczyk
Browse files

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: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456964


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 416c5e29
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -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