From patchwork Thu Jul 13 13:54:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 119926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1855131vqm; Thu, 13 Jul 2023 07:15:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlGn8o2IKaurD6n+7iY6bav6KHyPTi75isNYaj31t/BLGbX9c1eLVQt7a0ogk2/PSEygzhw3 X-Received: by 2002:a2e:b614:0:b0:2b6:faaa:fb53 with SMTP id r20-20020a2eb614000000b002b6faaafb53mr1456692ljn.26.1689257722188; Thu, 13 Jul 2023 07:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689257722; cv=none; d=google.com; s=arc-20160816; b=IAqRszVG3qI6qeRN40/9KyZCN097JIRsA0fwohEbJCmmJmSLYGA+NQrUMzi8Yjj0H4 PUpYYI1RpkAmj4N3DAu0lZQrLpdisEDe8GsmBRxB78hXvY78dDZgcpjOilFuq7at9xaB ezOfShMuPq5Z3JfUExyXe9g9kBOnd+IO1UhLaaVpkoRGnhlP99EUGBrYk6Mysa2C+tXP j2S09CDNN0QYmZ622oH+RA4dBcdsuzIECVU1QwwlEkKmaylcHfxpJz/02QAQC7m6TIFH 86O6Hd+zfy/vLtNE2DLsX4FmoLL1IYtHP2DO6UqrKIMeF0hhRPCTenPpb3bkPnwBk6C9 DGsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1UY/dJEooJnNbfAHm7UE9cYo3rXDScw1JA9mM8Arq2c=; fh=PBHZcfMfFxGGBVmDESRU6Gjyj3qxzeiTc8DMNv9diCw=; b=VGZt17xPYM62ad1cQLe54Qwi5lbIJEfsEx6V7RsCcwfY6v0axYFHnK2FUp4uNtCxON 4TFOT17FzzWVJPuH+npb9euzgLWX+zTgLfD8NAOBc8ei6J5obNHybQcKYHdjdaDmxlVD Jh2IkP5L5nNBGjIqAoBpNCaVw9mbIlXNNryMjSJtFHY7WapNEXENQ6B0gg2pwE5l5BNE 3pIanNsOlgtc2w9c+6fu2UdRS+3zTkOS8Kj/LH1cYKij3D4dOoJN7RrhAENNZpx6rWRd sR3tsbNif8BQNg1mOW3QYfnMdu8PQlCuIQV1GwmDX7t+zDP3OP35Z+x/nxqgJQOfHiMX 57kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o14-20020a170906358e00b009920ac37832si7244074ejb.504.2023.07.13.07.14.57; Thu, 13 Jul 2023 07:15:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231799AbjGMNy6 (ORCPT + 99 others); Thu, 13 Jul 2023 09:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbjGMNyx (ORCPT ); Thu, 13 Jul 2023 09:54:53 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D3181992; Thu, 13 Jul 2023 06:54:52 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B25D71576; Thu, 13 Jul 2023 06:55:34 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A829D3F73F; Thu, 13 Jul 2023 06:54:50 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Shuah Khan , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand , Mark Brown , John Hubbard , Florent Revest , "Liam R. Howlett" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 1/9] selftests: Line buffer test program's stdout Date: Thu, 13 Jul 2023 14:54:32 +0100 Message-Id: <20230713135440.3651409-2-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230713135440.3651409-1-ryan.roberts@arm.com> References: <20230713135440.3651409-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771315105480991985 X-GMAIL-MSGID: 1771315105480991985 The selftests runner pipes the test program's stdout to tap_prefix. The presence of the pipe means that the test program sets its stdout to be fully buffered (as aposed to line buffered when directly connected to the terminal). The block buffering means that there is often content in the buffer at fork() time, which causes the output to end up duplicated. This was causing problems for mm:cow where test results were duplicated 20-30x. Solve this by using `stdbuf`, when available to force the test program to use line buffered mode. This means previously printf'ed results are flushed out of the program before any fork(). Signed-off-by: Ryan Roberts --- tools/testing/selftests/kselftest/runner.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh index 1c952d1401d4..cb2b395ae296 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -105,8 +105,11 @@ run_one() echo "# Warning: file $TEST is missing!" echo "not ok $test_num $TEST_HDR_MSG" else + if [ -x /usr/bin/stdbuf ]; then + stdbuf="/usr/bin/stdbuf --output=L " + fi eval kselftest_cmd_args="\$${kselftest_cmd_args_ref:-}" - cmd="./$BASENAME_TEST $kselftest_cmd_args" + cmd="$stdbuf ./$BASENAME_TEST $kselftest_cmd_args" if [ ! -x "$TEST" ]; then echo "# Warning: file $TEST is not executable"