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: 13312253 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AB1DC00528 for ; Thu, 13 Jul 2023 13:54:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59427900016; Thu, 13 Jul 2023 09:54:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5413690000B; Thu, 13 Jul 2023 09:54:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BB1D900016; Thu, 13 Jul 2023 09:54:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2CB0490000B for ; Thu, 13 Jul 2023 09:54:55 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CC1C9A02C1 for ; Thu, 13 Jul 2023 13:54:54 +0000 (UTC) X-FDA: 81006734508.10.FF493B5 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf13.hostedemail.com (Postfix) with ESMTP id 24EFF2001A for ; Thu, 13 Jul 2023 13:54:52 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf13.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689256493; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1UY/dJEooJnNbfAHm7UE9cYo3rXDScw1JA9mM8Arq2c=; b=5QQvfvjG+Tz4Y4Xg54XHlW/wl+EaIsG/nVZo3DT7q2u+R63FrlGj1P4x0nna9YeooHiyBB 9q4LYw7iHOFALrjjXg5XG7QqgtidCONi3XmHyDKVPpCKl9DVJD+mUfvHZ+nRALgYc1qZui hkpvBan//3e43Fg11E20Jfu9UO6xb6k= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf13.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689256493; a=rsa-sha256; cv=none; b=QuSjZqHw2rm0OwCEXTpZkrKN2xN7mFarmsm1Y+fvc/PwKfefZQwJYMbZiIlc4AH+NZ5ajl IYfHwbep3Gz6pvq1Zyx2DMp7lL9bQZ0kvlypz5bghwUw4Q3O/RHKB/qBi/roExtoa84m+2 oBB+zPP4x+YUOe7IuJHaJUdUXQKaCpk= 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-Rspamd-Queue-Id: 24EFF2001A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: xhig7nzrtrtizpug63m4cg3odjr9p5y8 X-HE-Tag: 1689256492-849452 X-HE-Meta: U2FsdGVkX1+4RmHNMBfJ06Clr+oegke7fgC4cDPxLh2S6s74O8GZ4s2HKoNGI86b6KQZwfxnWOXLgMfJOY8LmpiUzrqnuzEqQLhKX40hrpwD/7mRUGS7wNO0x+sPCtfrWD432hvTrzEpceUAhcIzpEod4+yCvObYwjipGCMStjOAHWpocSXZ0qskkjvQIGI2Ss629MkVsepzMyNRjWV1X9dsba/BaKZci4pLUDb6g6aeE/u3KKc8iPS6/XIeIEQJMl0/OQk/lTLjmroVHtUb1RPHjRg5SDIL2IE65tZOltmXZWOQCQRsxW96/BpgYuKqqC5Fc+ycFuq9+xXdBzeUuORT3DG2zU/CraA9MfjPplEkQsg2kusX1+OCVwcCJmSsfP/oOQkBx0hv1As/WK16MsZDbvqdO0M9+IWGFYELnXDeO0p/1gZCOL8nu0CxcWYKlnDS1QXAPO3Jr0KjI2yt0Krwdu+FJexMz617VC/L8VfkDEpe8uopigirLNj0Nt6SMLca9ojFzXBdxUEp5mg9XzbUmdm4yGCSCopj9T7b6UaX5tKGAmXyDLV/j9RnEDSKgnJToVl7hp0dXvGbirDvghf+Gw0WRk2voqftgJ0mYmnc5UWnGBqbOaloh+H+WB165q2pPjM/pC/DFq0ZkAR//zziP/mJ1atw1gjeCulOzS2FfFj8Ad53Qv0p+XvWikjE2oBjUSlCL50jV9sHjHbxFwQQNwjxKC8KL/K/2nARJF04zNOeNhpzjrO9FkUwca5UMkHQdwxwKkxhcSIuHqgb9bRul+YZuQjn+HXrOXUZdpsd68OJPf8M8WTdGS+aDyjox4Q1vLlvSUykU9QEIWlfDtNrUKDKUjiVVpbRovHGhYQ6efH55YiqmVYQr2JwgeoKoifqddM3U3bGG0rNkbPwTraxf5r7gimBILg8M14Jqnyr4QEqtKV1aFR1O+GaScjRTea0LOzCrPcLXaLM+Y2 iGMnmV1e vzJ1Uoy5ew9dKFay5oPhsY86FG0ZI3cOvg4cCL9/cYri2WRA68psTUj33NtuLxHRbpr0Hu4v/vrXPdq5TTuogHEsEe0Pm8rZ5y4pzCj8KSKz/st780c+f8H9jXZHp4mMuifnOqmfJ2u6BMmFh6TbO0EQL/TN56pld2Oke X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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"