Commit 8d2247e2 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Jim Harris
Browse files

autotest/common: produce xtrace output on xtrace_restore



This way we can consistently track when xtrace in our
scripts is enabled or disabled.

> [...]
> xtrace_disable
> PREV_BASH_OPTS=ehxBE
> set +x
> xtrace_enable
> [...]

Change-Id: I2e813dc2a237a4620ea72d26a22a3c8cbeb269f9
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453248


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 3b660ea8
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -9,10 +9,21 @@ function xtrace_disable() {
	set +x
}

# 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() {
	# We have to do something inside a function in bash, and calling any command
	# (even `:`) will produce an xtrace entry, so we just define another function.
	function xtrace_dummy() { :; }
}

function xtrace_restore() {
	if [[ "$PREV_BASH_OPTS" == *"x"* ]]; then
		set -x
	if [[ "$PREV_BASH_OPTS" != *"x"* ]]; then
		return
	fi

	set -x
	xtrace_enable
}

set -e