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: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453248
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Darek Stojaczyk 2019-05-06 12:03:53 +02:00 committed by Jim Harris
parent 3b660ea857
commit 8d2247e2c4

View File

@ -9,10 +9,21 @@ function xtrace_disable() {
set +x 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() { function xtrace_restore() {
if [[ "$PREV_BASH_OPTS" == *"x"* ]]; then if [[ "$PREV_BASH_OPTS" != *"x"* ]]; then
set -x return
fi fi
set -x
xtrace_enable
} }
set -e set -e