]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: fix --unbuffered mode with ASAN
authorKarel Zak <kzak@redhat.com>
Tue, 27 Aug 2019 11:02:38 +0000 (13:02 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 27 Aug 2019 11:02:38 +0000 (13:02 +0200)
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 <kzak@redhat.com>
tests/functions.sh
tests/ts/libfdisk/mkpart-full
tests/ts/misc/swaplabel
tests/ts/rename/exit_codes

index 3d7bb89bc9e5570bd277723e7402021e03bde746..67fab1d83fc72a846b404b19a134e99ba9f348d4 100644 (file)
@@ -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 {
index 9fb46ef67074d0da653cbf0ce0c9d358e7f4da84..4724074ef345b39e92b0ef5ac9626b376146d22e 100755 (executable)
@@ -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)
 
index 106cb7d213a48c4f05678171963b9e7ba2358f9e..4388464260b2a072aebb314a7932bfa4cf2420d5 100755 (executable)
@@ -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()
index d3012ae59d1ec5c27f9c80f6e3f4e0615155d2ce..5ebd37a295fcccdba5becac0bcead79ed1054433 100755 (executable)
@@ -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}