Commit 190b2245 authored by Seth Howell's avatar Seth Howell Committed by Tomasz Zawadzki
Browse files

test: make xtrace_disable multi-call safe.



Previously, if you made two sequential calls to xtrace_disable without
calling xtrace_enable, you would lose the original value of x. Now this
is not the case. It allows us to call xtrace_disable freely without
worrying about whether xtrace_disable is invoked later in a function we
call.

Change-Id: I9818ae97532e7a31db576bb9bd2e2e30d67ab410
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477965


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
parent c4d4abcf
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
function xtrace_disable() {
	if [ "$XTRACE_DISABLED" != "yes" ]; then
		PREV_BASH_OPTS="$-"
		if [[ "$PREV_BASH_OPTS" == *"x"* ]]; then
			XTRACE_DISABLED="yes"
		fi
		set +x
	fi
}

xtrace_disable
@@ -18,7 +23,7 @@ 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_enable; fi'
alias xtrace_restore='if [[ "$PREV_BASH_OPTS" == *"x"* ]]; then set -x; XTRACE_DISABLED="no"; PREV_BASH_OPTS=""; xtrace_enable; fi'

: ${RUN_NIGHTLY:=0}
export RUN_NIGHTLY