Message ID | 20230203152603.11450-1-guillaume.tucker@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp899787wrn; Fri, 3 Feb 2023 07:27:39 -0800 (PST) X-Google-Smtp-Source: AK7set+9zYGA8SX5gQpwuluI9LsZBbnEtIxygrCobXqmsK4bt3c5oDjTUbeGh8ktw/UvVN5uij/k X-Received: by 2002:a50:aa95:0:b0:46b:eadf:8d34 with SMTP id q21-20020a50aa95000000b0046beadf8d34mr11240677edc.7.1675438059731; Fri, 03 Feb 2023 07:27:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675438059; cv=none; d=google.com; s=arc-20160816; b=U5UeSOaiKudPa4pKWTUAT7rVMSjW+//eT/ik0cP4jmG7gpGvXkaRq0GnNXT0QN49v0 BHZ3syaoeig4ZEQKRG9a2B+8qr8/w7Ly33M0z42hjcdNYSdg/KixPAG6hRzoCGA9rFQX HaT1H/ZcT56ny0YYvF+cP+yNCkm5Arior3VSw85nrHsSjoSUe0rgFPlCxjVuFZnlisbX bD0pJvJ2QmLuLb10IsgzSBYT2tfPz6hAbOUXaSfEYBfngaYPY9dw85XjvXQZu12eXg/N MM1UGlE2iNeAEKvvvbqzoHQEwBY8liVHtjk5ncPQImzJx8BqiYL0sfhIykWlHkEiVuKd JhPw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=RDfKShJtyWA9tkw/vqnzuH6PbtY1JS+FAMAL/QkD0GA=; b=thK+DD98I28H5m9RlM+DnAA0Ea6ViFJ1cNNb0qd2vbJJ8yaHiT2IWcfshJdnAkG+qv Z0I+MJsBNVZUPC7ALhGNrQGP22Uud4sBLGvzA9GRBStvEw/f77HjOfxpMLNh2xaZ3XQs d1056AheKhGbSF1HVE5ITQ6FJB6cJudyvHMG++tlOrke4qn6wa5bdRpYucyP3AY8523O 9gCMqdh92vlEcQ6Ddf7w6jeLtwrcMBCEKTWoY5+m0jOqfl/NK5wtP1HNOitVwxNhdztD qETFmyvQWNNd2+ytvN+HjqeiTh+UQJ6k2y2zl0ZDmABuJSBm13F8t4pyZ688xn/Pcb6a NOJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fqjVdAP7; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a056402350e00b0049e10026952si3876088edd.10.2023.02.03.07.27.15; Fri, 03 Feb 2023 07:27:39 -0800 (PST) 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; dkim=pass header.i=@collabora.com header.s=mail header.b=fqjVdAP7; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232924AbjBCP0U (ORCPT <rfc822;il.mystafa@gmail.com> + 99 others); Fri, 3 Feb 2023 10:26:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232806AbjBCP0A (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 3 Feb 2023 10:26:00 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A93C79F30; Fri, 3 Feb 2023 07:25:31 -0800 (PST) Received: from localhost.localdomain (ip-185-104-137-32.ptr.icomera.net [185.104.137.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: gtucker) by madras.collabora.co.uk (Postfix) with ESMTPSA id 53A076602F05; Fri, 3 Feb 2023 15:25:26 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675437930; bh=LJFhso2nOYttoMJgKwPgZoKqQrPyp5Qa3zt/8fIFdZQ=; h=From:To:Cc:Subject:Date:From; b=fqjVdAP75KxK9vv+9nwdq6WcQuwVar1CX4fbwPzZuHljWxhNP5f/6XIqdPE1qCfwc z3qhbTxUKI812BAQIronE5hAXjUc7Z93VSOsKuh0/KVA93F6TVNv/gtyuezK7cHDKo BXDJdLoMc1A/XDkvnh5w2P44+LHCogt2H8HIzFmAMGG6jJAVxzYkBHTLpIgkkC+uLi HhFhgke3fesExQdDioyeKYvKajwRypfkcXjRSjXBVxTSbzr+9EB4wP4eJMmT9fTn36 RoOi1wtp9m082A5oDIeC83uGHzNIlDD+NsLUFFHe9opdybO/Nx/awcmqx2zuv+aqiJ /cjeaz69H651w== From: Guillaume Tucker <guillaume.tucker@collabora.com> To: Guillaume Tucker <guillaume.tucker@gmail.com>, Shuah Khan <shuah@kernel.org>, Gautam <gautammenghani201@gmail.com> Cc: kernel@collabora.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, kernelci@lists.linux.dev Subject: [PATCH] selftests: find echo binary to use -ne options Date: Fri, 3 Feb 2023 16:26:03 +0100 Message-Id: <20230203152603.11450-1-guillaume.tucker@collabora.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756824138881777362?= X-GMAIL-MSGID: =?utf-8?q?1756824138881777362?= |
Series |
selftests: find echo binary to use -ne options
|
|
Commit Message
Guillaume Tucker
Feb. 3, 2023, 3:26 p.m. UTC
Find the actual echo binary using $(which echo) and use it for
formatted output with -ne. On some systems, the default echo command
doesn't handle the -e option and the output looks like this (arm64
build):
-ne Emit Tests for alsa
-ne Emit Tests for amd-pstate
-ne Emit Tests for arm64
This is for example the case with the KernelCI Docker images
e.g. kernelci/gcc-10:x86-kselftest-kernelci. With the actual echo
binary (e.g. in /bin/echo), the output is formatted as expected (x86
build this time):
Emit Tests for alsa
Emit Tests for amd-pstate
Skipping non-existent dir: arm64
Only the install target is using "echo -ne" so keep the $ECHO variable
local to it.
Reported-by: "kernelci.org bot" <bot@kernelci.org>
Fixes: 3297a4df805d ("kselftests: Enable the echo command to print newlines in Makefile")
Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com>
---
tools/testing/selftests/Makefile | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
On 2/3/23 08:26, Guillaume Tucker wrote: > Find the actual echo binary using $(which echo) and use it for > formatted output with -ne. On some systems, the default echo command > doesn't handle the -e option and the output looks like this (arm64 > build): > > -ne Emit Tests for alsa > > -ne Emit Tests for amd-pstate > > -ne Emit Tests for arm64 > > This is for example the case with the KernelCI Docker images > e.g. kernelci/gcc-10:x86-kselftest-kernelci. With the actual echo > binary (e.g. in /bin/echo), the output is formatted as expected (x86 > build this time): > > Emit Tests for alsa > Emit Tests for amd-pstate > Skipping non-existent dir: arm64 > > Only the install target is using "echo -ne" so keep the $ECHO variable > local to it. > > Reported-by: "kernelci.org bot" <bot@kernelci.org> > Fixes: 3297a4df805d ("kselftests: Enable the echo command to print newlines in Makefile") > Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com> > --- Thank you - will appear shortly in linuxk-selftest next. thanks, -- Shuah
From: Guillaume Tucker > Sent: 03 February 2023 15:26 > > Find the actual echo binary using $(which echo) and use it for > formatted output with -ne. On some systems, the default echo command > doesn't handle the -e option and the output looks like this (arm64 > build): > > -ne Emit Tests for alsa > > -ne Emit Tests for amd-pstate > > -ne Emit Tests for arm64 Nack. There is no reason to suppose that /bin/echo is any different from the version of echo builtin to the shell that make uses. Not only that 'which' is a horrid shell script that is trying to emulate csh builtin. The bourne shell equivalent is 'type' and the posix one 'command'. In any case the portable way to fix this is to use printf. This is a well defined program and is bultin to all modern shells. David > > This is for example the case with the KernelCI Docker images > e.g. kernelci/gcc-10:x86-kselftest-kernelci. With the actual echo > binary (e.g. in /bin/echo), the output is formatted as expected (x86 > build this time): > > Emit Tests for alsa > Emit Tests for amd-pstate > Skipping non-existent dir: arm64 > > Only the install target is using "echo -ne" so keep the $ECHO variable > local to it. > > Reported-by: "kernelci.org bot" <bot@kernelci.org> > Fixes: 3297a4df805d ("kselftests: Enable the echo command to print newlines in Makefile") > Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com> > --- > tools/testing/selftests/Makefile | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile > index 41b649452560..9619d0f3b2ff 100644 > --- a/tools/testing/selftests/Makefile > +++ b/tools/testing/selftests/Makefile > @@ -234,10 +234,11 @@ ifdef INSTALL_PATH > @# While building kselftest-list.text skip also non-existent TARGET dirs: > @# they could be the result of a build failure and should NOT be > @# included in the generated runlist. > + ECHO=`which echo`; \ > for TARGET in $(TARGETS); do \ > BUILD_TARGET=$$BUILD/$$TARGET; \ > - [ ! -d $(INSTALL_PATH)/$$TARGET ] && echo "Skipping non-existent dir: $$TARGET" && > continue; \ > - echo -ne "Emit Tests for $$TARGET\n"; \ > + [ ! -d $(INSTALL_PATH)/$$TARGET ] && $$ECHO "Skipping non-existent dir: $$TARGET" && > continue; \ > + $$ECHO -ne "Emit Tests for $$TARGET\n"; \ > $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \ > -C $$TARGET emit_tests >> $(TEST_LIST); \ > done; > -- > 2.30.2 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On 04/02/2023 14:04, David Laight wrote: > From: Guillaume Tucker >> Sent: 03 February 2023 15:26 >> >> Find the actual echo binary using $(which echo) and use it for >> formatted output with -ne. On some systems, the default echo command >> doesn't handle the -e option and the output looks like this (arm64 >> build): >> >> -ne Emit Tests for alsa >> >> -ne Emit Tests for amd-pstate >> >> -ne Emit Tests for arm64 > > Nack. > There is no reason to suppose that /bin/echo is any different from > the version of echo builtin to the shell that make uses. > > Not only that 'which' is a horrid shell script that is trying to > emulate csh builtin. > The bourne shell equivalent is 'type' and the posix one 'command'. > > In any case the portable way to fix this is to use printf. > This is a well defined program and is bultin to all modern shells. Ah great, thanks for the review. Will send a v2 with printf. Guillaume >> This is for example the case with the KernelCI Docker images >> e.g. kernelci/gcc-10:x86-kselftest-kernelci. With the actual echo >> binary (e.g. in /bin/echo), the output is formatted as expected (x86 >> build this time): >> >> Emit Tests for alsa >> Emit Tests for amd-pstate >> Skipping non-existent dir: arm64 >> >> Only the install target is using "echo -ne" so keep the $ECHO variable >> local to it. >> >> Reported-by: "kernelci.org bot" <bot@kernelci.org> >> Fixes: 3297a4df805d ("kselftests: Enable the echo command to print newlines in Makefile") >> Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com> >> --- >> tools/testing/selftests/Makefile | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile >> index 41b649452560..9619d0f3b2ff 100644 >> --- a/tools/testing/selftests/Makefile >> +++ b/tools/testing/selftests/Makefile >> @@ -234,10 +234,11 @@ ifdef INSTALL_PATH >> @# While building kselftest-list.text skip also non-existent TARGET dirs: >> @# they could be the result of a build failure and should NOT be >> @# included in the generated runlist. >> + ECHO=`which echo`; \ >> for TARGET in $(TARGETS); do \ >> BUILD_TARGET=$$BUILD/$$TARGET; \ >> - [ ! -d $(INSTALL_PATH)/$$TARGET ] && echo "Skipping non-existent dir: $$TARGET" && >> continue; \ >> - echo -ne "Emit Tests for $$TARGET\n"; \ >> + [ ! -d $(INSTALL_PATH)/$$TARGET ] && $$ECHO "Skipping non-existent dir: $$TARGET" && >> continue; \ >> + $$ECHO -ne "Emit Tests for $$TARGET\n"; \ >> $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \ >> -C $$TARGET emit_tests >> $(TEST_LIST); \ >> done; >> -- >> 2.30.2 > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) > >
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 41b649452560..9619d0f3b2ff 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -234,10 +234,11 @@ ifdef INSTALL_PATH @# While building kselftest-list.text skip also non-existent TARGET dirs: @# they could be the result of a build failure and should NOT be @# included in the generated runlist. + ECHO=`which echo`; \ for TARGET in $(TARGETS); do \ BUILD_TARGET=$$BUILD/$$TARGET; \ - [ ! -d $(INSTALL_PATH)/$$TARGET ] && echo "Skipping non-existent dir: $$TARGET" && continue; \ - echo -ne "Emit Tests for $$TARGET\n"; \ + [ ! -d $(INSTALL_PATH)/$$TARGET ] && $$ECHO "Skipping non-existent dir: $$TARGET" && continue; \ + $$ECHO -ne "Emit Tests for $$TARGET\n"; \ $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \ -C $$TARGET emit_tests >> $(TEST_LIST); \ done;