selftests: Remove forced unbuffering for test running [Linux 5.2]

selftests: Remove forced unbuffering for test running [Linux 5.2]

This Linux kernel change "selftests: Remove forced unbuffering for test running" is included in the Linux 5.2 release. This change is authored by Kees Cook <keescook [at]> on Mon May 20 15:37:48 2019 -0700. The commit for this change in Linux stable tree is e810886 (patch).

selftests: Remove forced unbuffering for test running

As it turns out, the "stdbuf" command will actually force all
subprocesses into unbuffered output, and some implementations of "echo"
turn into single-character writes, which utterly wrecks writes to /sys
and /proc files.

Instead, drop the "stdbuf" usage, and for any tests that want explicit
flushing between newlines, they'll have to add "fflush(stdout);" as

Reported-by: Takashi Iwai <[email protected]>
Fixes: 5c069b6dedef ("selftests: Move test output to diagnostic lines")
Signed-off-by: Kees Cook <[email protected]>
Tested-by: Takashi Iwai <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>

There are 12 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 tools/testing/selftests/kselftest/ | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/tools/testing/selftests/kselftest/ b/tools/testing/selftests/kselftest/
index eff3ee3..00c9020 100644
--- a/tools/testing/selftests/kselftest/
+++ b/tools/testing/selftests/kselftest/
@@ -24,16 +24,6 @@ tap_prefix()

-# If stdbuf is unavailable, we must fall back to line-at-a-time piping.
-   if ! which stdbuf >/dev/null ; then
-       "[email protected]"
-   else
-       stdbuf -i0 -o0 -e0 "[email protected]"
-   fi
@@ -54,7 +44,7 @@ run_one()
        echo "not ok $test_num $TEST_HDR_MSG"
        cd `dirname $TEST` > /dev/null
-       (((((tap_unbuffer ./$BASENAME_TEST 2>&1; echo $? >&3) |
+       (((((./$BASENAME_TEST 2>&1; echo $? >&3) |
            tap_prefix >&4) 3>&1) |
            (read xs; exit $xs)) 4>>"$logfile" &&
        echo "ok $test_num $TEST_HDR_MSG") ||

Leave a Reply

Your email address will not be published. Required fields are marked *