From: Karel Zak Date: Tue, 27 Aug 2019 11:02:38 +0000 (+0200) Subject: tests: fix --unbuffered mode with ASAN X-Git-Tag: v2.35-rc1~261 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f612c4c67;p=thirdparty%2Futil-linux.git tests: fix --unbuffered mode with ASAN Unfortunately, ASAN is pretty sensitive to LD_PRELOAD, but stdbuf from coreutils is based on LD_PRELOAD. So, I have replaced stdbuf with unbuffer (from expect pkg). The another problem is "${args[@]}" "$@" which does not work as expected. Well, this patch sucks. It would be nice to have things in the way how it has been original expected by Patrick's patch, but ... Signed-off-by: Karel Zak --- diff --git a/tests/functions.sh b/tests/functions.sh index 3d7bb89bc9..67fab1d83f 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -425,7 +425,9 @@ function ts_run { while true; do case "$1" in --unbuffered) - UNBUFFERED=1 + if type stdbuf >/dev/null 2>&1; then + UNBUFFERED=1 + fi shift;; --) shift @@ -435,33 +437,34 @@ function ts_run { esac done - declare -a args - # # ASAN mode # if [ "$TS_ENABLE_ASAN" == "yes" ]; then - args+=(ASAN_OPTIONS='detect_leaks=1') - fi - - # - # Disable buffering of stdout - # - if [ -n "$UNBUFFERED" ]; then - if type stdbuf >/dev/null 2>&1; then - args+=(stdbuf --output=0) + if [ -n "$UNBUFFERED" ]; then + ASAN_OPTIONS='detect_leaks=1' unbuffer "$@" + else + ASAN_OPTIONS='detect_leaks=1' "$@" fi - fi # # valgrind mode # - if [ -n "$TS_VALGRIND_CMD" ]; then - args+=(libtool --mode=execute "$TS_VALGRIND_CMD" --tool=memcheck --leak-check=full) - args+=(--leak-resolution=high --num-callers=20 --log-file="$TS_VGDUMP") + elif [ -n "$TS_VALGRIND_CMD" ]; then + libtool --mode=execute \ + $TS_VALGRIND_CMD --tool=memcheck --leak-check=full \ + --leak-resolution=high --num-callers=20 \ + --log-file="$TS_VGDUMP" "$@" + # + # default mode + # + else + if [ -n "$UNBUFFERED" ]; then + unbuffer "$@" + else + "$@" + fi fi - - "${args[@]}" "$@" } function ts_gen_diff { diff --git a/tests/ts/libfdisk/mkpart-full b/tests/ts/libfdisk/mkpart-full index 9fb46ef670..4724074ef3 100755 --- a/tests/ts/libfdisk/mkpart-full +++ b/tests/ts/libfdisk/mkpart-full @@ -27,6 +27,7 @@ TESTPROG="$TS_HELPER_LIBFDISK_MKPART_FULLSPEC" ts_check_test_command "$TESTPROG" ts_check_test_command "$TS_CMD_SFDISK" ts_check_test_command "$TS_CMD_WIPEFS" +ts_check_prog unbuffer TEST_IMAGE_NAME=$(ts_image_init 15) diff --git a/tests/ts/misc/swaplabel b/tests/ts/misc/swaplabel index 106cb7d213..4388464260 100755 --- a/tests/ts/misc/swaplabel +++ b/tests/ts/misc/swaplabel @@ -21,6 +21,7 @@ ts_init "$*" ts_check_test_command "$TS_CMD_MKSWAP" ts_check_test_command "$TS_CMD_SWAPLABEL" ts_check_test_command "$TS_HELPER_SYSINFO" +ts_check_prog unbuffer # fallocate does not work on most file systems function fallocate_or_skip() diff --git a/tests/ts/rename/exit_codes b/tests/ts/rename/exit_codes index d3012ae59d..5ebd37a295 100755 --- a/tests/ts/rename/exit_codes +++ b/tests/ts/rename/exit_codes @@ -22,6 +22,8 @@ TS_DESC="exit codes" ts_init "$*" ts_check_test_command "$TS_CMD_RENAME" +ts_check_prog unbuffer + ts_cd "$TS_OUTDIR" touch rename_exit_codes.{1..2}