From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15334C04AAF for ; Tue, 21 May 2019 05:21:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D77A02173E for ; Tue, 21 May 2019 05:21:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727711AbfEUFVo (ORCPT ); Tue, 21 May 2019 01:21:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:45718 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725794AbfEUFVo (ORCPT ); Tue, 21 May 2019 01:21:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3844FAD36; Tue, 21 May 2019 05:21:43 +0000 (UTC) Date: Tue, 21 May 2019 07:21:42 +0200 Message-ID: From: Takashi Iwai To: Kees Cook Cc: Shuah Khan , John Stultz , Thomas Gleixner , Stephen Boyd , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] selftests: Remove forced unbuffering for test running In-Reply-To: <20190520223749.13476-2-keescook@chromium.org> References: <20190520223749.13476-1-keescook@chromium.org> <20190520223749.13476-2-keescook@chromium.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 May 2019 00:37:48 +0200, Kees Cook wrote: > > 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 > needed. > > Reported-by: Takashi Iwai > Fixes: 5c069b6dedef ("selftests: Move test output to diagnostic lines") > Signed-off-by: Kees Cook Tested-by: Takashi Iwai BTW, this might be specific to shell invocation. As in the original discussion thread, it starts working when I replace "echo" with "/usr/bin/echo". Still it's not easy to control in a script itself, so dropping the unbuffered mode is certainly safer, yes. Thanks! Takashi > --- > tools/testing/selftests/kselftest/runner.sh | 12 +----------- > 1 file changed, 1 insertion(+), 11 deletions(-) > > diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh > index eff3ee303d0d..00c9020bdda8 100644 > --- a/tools/testing/selftests/kselftest/runner.sh > +++ b/tools/testing/selftests/kselftest/runner.sh > @@ -24,16 +24,6 @@ tap_prefix() > fi > } > > -# If stdbuf is unavailable, we must fall back to line-at-a-time piping. > -tap_unbuffer() > -{ > - if ! which stdbuf >/dev/null ; then > - "$@" > - else > - stdbuf -i0 -o0 -e0 "$@" > - fi > -} > - > run_one() > { > DIR="$1" > @@ -54,7 +44,7 @@ run_one() > echo "not ok $test_num $TEST_HDR_MSG" > else > 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") || > -- > 2.17.1 >