From e5e36586120e18b977e7a80427585659a18c4294 Mon Sep 17 00:00:00 2001 From: Pawel Wodkowski Date: Wed, 15 Nov 2017 19:43:15 +0100 Subject: [PATCH] autotest_common.sh: small fixes and adjustments Introduce SPDK_AUTOTEST_X to allow controlling '-x' flag. Fix ldconfig detection - it is not always in /usr/sbin but should be in PATH. Fix (once again) regexp in print_backtrace. Also obey current '-x' option. Change-Id: I782b6445e7d44ceb168fd4d9874300f1c71f4f80 Signed-off-by: Pawel Wodkowski Reviewed-on: https://review.gerrithub.io/387610 Tested-by: SPDK Automated Test System Reviewed-by: Seth Howell Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris Reviewed-by: Karol Latecki --- scripts/autotest_common.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/autotest_common.sh b/scripts/autotest_common.sh index 9a31a70bf..2ea3451b0 100755 --- a/scripts/autotest_common.sh +++ b/scripts/autotest_common.sh @@ -1,4 +1,11 @@ -set -xe +: ${SPDK_AUTOTEST_X=true}; export SPDK_AUTOTEST_X + +if $SPDK_AUTOTEST_X; then + set -x +fi + +set -e + PS4=' \t \$ ' ulimit -c unlimited @@ -70,7 +77,7 @@ case `uname` in config_params+=' --enable-ubsan' fi if [ $SPDK_RUN_ASAN -eq 1 ]; then - if /usr/sbin/ldconfig -p | grep -q asan; then + if ldconfig -p | grep -q asan; then config_params+=' --enable-asan' else SPDK_RUN_ASAN=0 @@ -339,6 +346,7 @@ function run_test() { } function print_backtrace() { + local shell_options="$-" set +x echo "========== Backtrace start: ==========" echo "" @@ -348,13 +356,13 @@ function print_backtrace() { local src="${BASH_SOURCE[$i]}" echo "in $src:$line_nr -> $func()" echo " ..." - nl -w 4 -ba -nln $src | grep -B 5 -A 5 "^$line_nr" | \ + nl -w 4 -ba -nln $src | grep -B 5 -A 5 "^$line_nr[^0-9]" | \ sed "s/^/ /g" | sed "s/^ $line_nr /=> $line_nr /g" echo " ..." done echo "" echo "========== Backtrace end ==========" - set -x + [[ "$shell_options" =~ x ]] && set -x return 0 }