diff --git a/tests/functions.sh b/tests/functions.sh index 3d7bb89bc..67fab1d83 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 9fb46ef67..4724074ef 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 106cb7d21..438846426 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 d3012ae59..5ebd37a29 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}