From unknown Wed Jul 09 06:15:14 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#8893 <8893@debbugs.gnu.org> To: bug#8893 <8893@debbugs.gnu.org> Subject: Status: [PATCH 1/2] tests: make test runner a script, not a shell function (was: Automake patches for custom test drivers' support break coreutils testsuite) Reply-To: bug#8893 <8893@debbugs.gnu.org> Date: Wed, 09 Jul 2025 13:15:14 +0000 retitle 8893 [PATCH 1/2] tests: make test runner a script, not a shell func= tion (was: Automake patches for custom test drivers' support break coreutil= s testsuite) reassign 8893 coreutils submitter 8893 Stefano Lattarini severity 8893 normal tag 8893 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 18 13:41:43 2011 Received: (at submit) by debbugs.gnu.org; 18 Jun 2011 17:41:43 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QXzWh-0003MG-11 for submit@debbugs.gnu.org; Sat, 18 Jun 2011 13:41:43 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QXzWd-0003M3-Bs for submit@debbugs.gnu.org; Sat, 18 Jun 2011 13:41:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QXzWW-0000VQ-8R for submit@debbugs.gnu.org; Sat, 18 Jun 2011 13:41:34 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:54590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXzWV-0000VH-UA for submit@debbugs.gnu.org; Sat, 18 Jun 2011 13:41:32 -0400 Received: from eggs.gnu.org ([140.186.70.92]:45449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXzWT-0005AM-Qu for bug-coreutils@gnu.org; Sat, 18 Jun 2011 13:41:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QXzWR-0000Uk-Je for bug-coreutils@gnu.org; Sat, 18 Jun 2011 13:41:29 -0400 Received: from mail-ww0-f49.google.com ([74.125.82.49]:50047) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXzWR-0000SL-2E; Sat, 18 Jun 2011 13:41:27 -0400 Received: by wwf22 with SMTP id 22so559047wwf.30 for ; Sat, 18 Jun 2011 10:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:date:user-agent:cc:references :in-reply-to:mime-version:content-type:message-id; bh=C3XGm14B+nLzZJG0CRFN1Pf3GbzTIdKff7KvGDolXBk=; b=GPGup4Xb5NmbBAV4ejy/kXC16Xyeg0HI8snV7ouUYlS4yehNAWqAoST7dMg60KinHS suq/ghkh+QvvqkaiXCb4nFncqRUkY8c6o1c2eGYa6FgYS2oIhCKPycXQNwCecBGt1blh FSo59B6+Hd9S8fSABpPDF2M/qJXACC6i4f7/g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:message-id; b=nTFy4RE1biW/T1Q08ZV/1r/buAYID9JdX5QeU6qbcsjJ12ii8W+5fLbbQ5SC5KFrjQ xrND80aECaOiYrTIGSfGsculMF2kgo/y63jfKrZ5ffC/HYu/HTT4euYwdeWfMV2E1PYs WVC9LsUICgLUvMF4IkjVDNFqdpIjlGOOR61cg= Received: by 10.216.221.163 with SMTP id r35mr324421wep.22.1308418885615; Sat, 18 Jun 2011 10:41:25 -0700 (PDT) Received: from bigio.localnet (host49-96-dynamic.4-87-r.retail.telecomitalia.it [87.4.96.49]) by mx.google.com with ESMTPS id gb6sm1839896wbb.51.2011.06.18.10.41.23 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 18 Jun 2011 10:41:24 -0700 (PDT) From: Stefano Lattarini To: Jim Meyering Subject: [PATCH 1/2] tests: make test runner a script, not a shell function (was: Automake patches for custom test drivers' support break coreutils testsuite) Date: Sat, 18 Jun 2011 19:41:11 +0200 User-Agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; ) References: <201104291121.07627.stefano.lattarini@gmail.com> <201106181023.43630.stefano.lattarini@gmail.com> <87pqmbe5ve.fsf@rho.meyering.net> In-Reply-To: <87pqmbe5ve.fsf@rho.meyering.net> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_4MO/NXxSae8SNWg" Message-Id: <201106181941.12662.stefano.lattarini@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.1 (-----) X-Debbugs-Envelope-To: submit Cc: Ralf Wildenhues , bug-coreutils@gnu.org, automake-patches@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.1 (-----) --Boundary-00=_4MO/NXxSae8SNWg Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Saturday 18 June 2011, Jim Meyering wrote: > Stefano Lattarini wrote: > >> ... > >> > > >> > In order to work with the upcoming new Automake testsuite harness, coreutils > >> > have two possibilities: > >> > 1. move the `shell_or_perl_' subroutine's functionality into a real acript, > >> > and define the LOG_COMPILER to point to it; or > >> > 2. add a `.pl' extension to the perl test scripts, and define PL_LOG_COMPILER > >> > appropriately (might be a little tricky, considering the hops that the > >> > `shell_or_perl_' subroutine goes through in order to get the flags and > >> > imports right). > >> > >> 1) sounds preferable. > >> > > But it has a serious drawback: the redirection `9>&2' placed at the end > > of TESTS_ENVIRONMENT will be rendered useless by the final exec done > > in the new `shell_or_perl' script (at least for with shells using the > > `cloexec' flag on fds > 2); this will bring back the problems fixed by > > commit `v8.12-82-g6b68745' :-( > > Well, no, that's not true; the "problematic" shells only set the 'close-on-exec' flag on the file descriptors they themselves create, not on the ones they inherit from their parents: $ ksh -c 'exec 9>&1; sh -c "echo foo >&9"' sh: 9: Bad file descriptor $ ksh -c 'sh -c "echo foo >&9"' 9>&1 foo $ (exec 9>&1; ksh -c 'sh -c "echo foo >&9"') foo I should have tested better before reporting an imaginary problem. > > So I now think we should go with solution (2). > > Ok. > I've gone with the less invasive solution (1) instead. See the attached patch. I will soon post a follow up that tries to compensate for the extra forks I've introduced here by removing a couple of grep calls from the `shell-or-perl' script (this is for Cygwin, I know that the overhead on Unix is utterly irrelevant). Regards, Stefano --Boundary-00=_4MO/NXxSae8SNWg Content-Type: text/x-patch; charset="utf-8"; name="0001-tests-make-test-runner-a-script-not-a-shell-function.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="0001-tests-make-test-runner-a-script-not-a-shell-function.patch" =46rom e4dd05df8ea1f0fc99649627f895a76ec776279a Mon Sep 17 00:00:00 2001 Message-Id: =46rom: Stefano Lattarini Date: Sat, 18 Jun 2011 10:26:15 +0200 Subject: [PATCH 1/2] tests: make test runner a script, not a shell function This changes implements a more correct and idiomatic use of the features of the Automake-provided 'parallel-tests' harness. Moreover, this change is required in order for the testsuite to continue to work with the new testsuite harness that is planned to be introduced in Automake 1.12 (which, as of the writing date, is still under development and in alpha state). * tests/shell-or-perl: New auxiliary script. * tests/Makefile.am (EXTRA_DIST): Distribute it. * tests/check.mk (TESTS_ENVIRONMENT): Remove definition of the `shell_or_perl_' shell function, whose code has been moved in the new script above (with few improvements and extensions). Do not use it to run the test scripts. (LOG_COMPILER): New, properly invoking `shell-or-perl'. =2D-- tests/Makefile.am | 1 + tests/check.mk | 27 +++++------- tests/shell-or-perl | 111 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 123 insertions(+), 16 deletions(-) create mode 100644 tests/shell-or-perl diff --git a/tests/Makefile.am b/tests/Makefile.am index a324dc1..f8fbd38 100644 =2D-- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -20,6 +20,7 @@ EXTRA_DIST =3D \ other-fs-tmpdir \ require-perl \ sample-test \ + shell-or-perl \ $(pr_data) =20 root_tests =3D \ diff --git a/tests/check.mk b/tests/check.mk index 9db96af..d45c288 100644 =2D-- a/tests/check.mk +++ b/tests/check.mk @@ -48,6 +48,16 @@ check-am: .built-programs && MAKEFLAGS=3D $(MAKE) -s built_programs.list) \ > $@-t && mv $@-t $@ =20 +## `$f' is set by the Automake-generated test harness to the path of the +## current test script stripped of VPATH components, and is used by the +## shell-or-perl script to determine the name of the temporary files to be +## used. Note that $f is a shell variable, not a make macro, so the use of +## `$$f' below is correct, and not a typo. +LOG_COMPILER =3D \ + $(SHELL) $(srcdir)/shell-or-perl \ + --test-name "$$f" --srcdir '$(srcdir)' \ + --shell '$(SHELL)' --perl '$(PERL)' -- + # Note that the first lines are statements. They ensure that environment # variables that can perturb tests are unset or set to expected values. # The rest are envvar settings that propagate build-related Makefile @@ -58,21 +68,6 @@ TESTS_ENVIRONMENT =3D \ test -d "$$tmp__" && test -w "$$tmp__" || tmp__=3D.; \ . $(srcdir)/envvar-check; \ TMPDIR=3D$$tmp__; export TMPDIR; \ =2D shell_or_perl_() { \ =2D if grep '^\#!/usr/bin/perl' "$$1" > /dev/null; then \ =2D if $(PERL) -e 'use warnings' > /dev/null 2>&1; then \ =2D grep '^\#!/usr/bin/perl -T' "$$1" > /dev/null && T_=3DT || T_=3D; \ =2D $(PERL) -w$$T_ -I$(srcdir) -MCoreutils -MCuSkip \ =2D -M"CuTmpdir qw($$f)" -- "$$1"; \ =2D else \ =2D echo 1>&2 "$$tst: configure did not find a usable version of Perl," \ =2D "so skipping this test"; \ =2D (exit 77); \ =2D fi; \ =2D else \ =2D $(SHELL) "$$1"; \ =2D fi; \ =2D }; \ export \ VERSION=3D'$(VERSION)' \ LOCALE_FR=3D'$(LOCALE_FR)' \ @@ -99,6 +94,6 @@ TESTS_ENVIRONMENT =3D \ REPLACE_GETCWD=3D$(REPLACE_GETCWD) \ ; test -d /usr/xpg4/bin && PATH=3D'/usr/xpg4/bin$(PATH_SEPARATOR)'"$$PAT= H"; \ PATH=3D'$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \ =2D ; shell_or_perl_ 9>&2 + ; 9>&2 =20 VERBOSE =3D yes diff --git a/tests/shell-or-perl b/tests/shell-or-perl new file mode 100644 index 0000000..ff92009 =2D-- /dev/null +++ b/tests/shell-or-perl @@ -0,0 +1,111 @@ +#! /bin/sh +# Run a test script of the coreutils test scripts, picking up the right +# interpreter (i.e., perl or the shell) and the right flags for it (e.g., +# perl `-T' flag for perl scripts that must rn in tainted mode). +# +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# ---------------------------------- # +# Readonly variables and functions # +# ---------------------------------- # + +# Help to avoid typo-related bugs. +set -u + +me=3Dshell-or-perl + +error_ () +{ + echo "$me: $*" >&2 + exit 99 +} + +print_help_ () +{ + cat </dev/null; then + # The test is a perl script. + if $cu_PERL -e 'use warnings' > /dev/null 2>&1; then + # Perl is available, see if we must run the test with taint + # mode on or not. + grep '^#!/usr/bin/perl -T' "$test_script" >/dev/null && T_=3DT || T_=3D + # Now run it. + exec $cu_PERL -w$T_ -I"$srcdir" -MCoreutils -MCuSkip \ + -M"CuTmpdir qw($test_name)" \ + -- "$test_script" ${1+"$@"} + else + # Perl is not available, skip the test. + echo "$test_name: skip: no usable version of Perl found" + exit 77 + fi +else + # Assume the test is a shell script. + exec $cu_SHELL "$test_script" ${1+"$@"} +fi + +# ------------- # +# Not reached # +# ------------- # + +error_ "dead code reached" =2D-=20 1.7.2.3 --Boundary-00=_4MO/NXxSae8SNWg-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 18 14:18:40 2011 Received: (at submit) by debbugs.gnu.org; 18 Jun 2011 18:18:41 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QY06S-0006Uu-Iu for submit@debbugs.gnu.org; Sat, 18 Jun 2011 14:18:40 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QY06Q-0006Ui-Qv for submit@debbugs.gnu.org; Sat, 18 Jun 2011 14:18:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QY06K-0006nW-Gk for submit@debbugs.gnu.org; Sat, 18 Jun 2011 14:18:33 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:35943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QY06K-0006nO-FF for submit@debbugs.gnu.org; Sat, 18 Jun 2011 14:18:32 -0400 Received: from eggs.gnu.org ([140.186.70.92]:33726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QY06J-0008Dc-76 for bug-coreutils@gnu.org; Sat, 18 Jun 2011 14:18:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QY06I-0006n4-4X for bug-coreutils@gnu.org; Sat, 18 Jun 2011 14:18:31 -0400 Received: from mail-ww0-f49.google.com ([74.125.82.49]:64101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QY06H-0006n0-Nz; Sat, 18 Jun 2011 14:18:29 -0400 Received: by wwf22 with SMTP id 22so572273wwf.30 for ; Sat, 18 Jun 2011 11:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:date:user-agent:cc:references :in-reply-to:mime-version:message-id:content-type; bh=caWLOLwFm6rzTaUIdRKXaPQTmYVRaC6vB/him81K2mU=; b=LwCKts+JMii5RcmSu3ZHtmPKMb2UuQE2QRUcUp8A17+DgGJnqtDVsIrpwRSPDSqFy6 OBWgyb0USzzlATHYz5WInZnAB2zIN8fc8ZmYFSoQnVXx6oI7B8yk6VSDCDAGdNxhJ/Pb kdO46zI4TgRRpBZb+b4zfFEMKtmDGdobXGlJc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:message-id:content-type; b=dwRD3ow3wzTAE+3Endrtp1pjV0NCOACY8tS0JZJQLAkKX3Dw4cX2LBh7gfc/hyUuFI Jk14+3CiQYacVpzRnN31ZRIaRFPiI5lWiv0Xid8i5T+zwPQG2ANPYFWFwDi+ErnlMof4 v1odyseOy1KFySBxL4No3xv776/72JnQgtse4= Received: by 10.216.231.165 with SMTP id l37mr3114015weq.78.1308421108673; Sat, 18 Jun 2011 11:18:28 -0700 (PDT) Received: from bigio.localnet (host49-96-dynamic.4-87-r.retail.telecomitalia.it [87.4.96.49]) by mx.google.com with ESMTPS id w10sm2019261weq.3.2011.06.18.11.18.26 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 18 Jun 2011 11:18:27 -0700 (PDT) From: Stefano Lattarini To: Jim Meyering Subject: Re: [PATCH 1/2] tests: make test runner a script, not a shell function (was: Automake patches for custom test drivers' support break coreutils testsuite) Date: Sat, 18 Jun 2011 20:18:10 +0200 User-Agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; ) References: <201104291121.07627.stefano.lattarini@gmail.com> <87pqmbe5ve.fsf@rho.meyering.net> <201106181941.12662.stefano.lattarini@gmail.com> In-Reply-To: <201106181941.12662.stefano.lattarini@gmail.com> MIME-Version: 1.0 Message-Id: <201106182018.10934.stefano.lattarini@gmail.com> Content-Type: Multipart/Mixed; boundary="Boundary-00=_ivO/NdLlpgyLLMJ" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.1 (-----) X-Debbugs-Envelope-To: submit Cc: Ralf Wildenhues , bug-coreutils@gnu.org, automake-patches@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.2 (-----) --Boundary-00=_ivO/NdLlpgyLLMJ Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Saturday 18 June 2011, Stefano Lattarini wrote: > On Saturday 18 June 2011, Jim Meyering wrote: > > Stefano Lattarini wrote: > > >> ... > > >> > > > >> > In order to work with the upcoming new Automake testsuite harness, coreutils > > >> > have two possibilities: > > >> > 1. move the `shell_or_perl_' subroutine's functionality into a real acript, > > >> > and define the LOG_COMPILER to point to it; or > > >> > 2. add a `.pl' extension to the perl test scripts, and define PL_LOG_COMPILER > > >> > appropriately (might be a little tricky, considering the hops that the > > >> > `shell_or_perl_' subroutine goes through in order to get the flags and > > >> > imports right). > > >> > > >> 1) sounds preferable. > > >> > > > But it has a serious drawback: the redirection `9>&2' placed at the end > > > of TESTS_ENVIRONMENT will be rendered useless by the final exec done > > > in the new `shell_or_perl' script (at least for with shells using the > > > `cloexec' flag on fds > 2); this will bring back the problems fixed by > > > commit `v8.12-82-g6b68745' :-( > > > > Well, no, that's not true; the "problematic" shells only set the 'close-on-exec' > flag on the file descriptors they themselves create, not on the ones they inherit > from their parents: > > $ ksh -c 'exec 9>&1; sh -c "echo foo >&9"' > sh: 9: Bad file descriptor > $ ksh -c 'sh -c "echo foo >&9"' 9>&1 > foo > $ (exec 9>&1; ksh -c 'sh -c "echo foo >&9"') > foo > > I should have tested better before reporting an imaginary problem. > > > > So I now think we should go with solution (2). > > > > Ok. > > > I've gone with the less invasive solution (1) instead. See the attached > patch. I will soon post a follow up that tries to compensate for the > extra forks I've introduced here by removing a couple of grep calls from > the `shell-or-perl' script > Here it is. Regards, Stefano --Boundary-00=_ivO/NdLlpgyLLMJ Content-Type: text/x-patch; charset="utf-8"; name="0002-tests-avoid-extra-forks-in-the-testsuite.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="0002-tests-avoid-extra-forks-in-the-testsuite.patch" =46rom bb3cbef9eece619dd694a60e5a738e71e939f9aa Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: =46rom: Stefano Lattarini Date: Sat, 18 Jun 2011 17:57:53 +0200 Subject: [PATCH 2/2] tests: avoid extra forks in the testsuite * tests/shell-or-perl: Prefer the `read' builtin over `grep' to look at the shebang line of test scripts. Since `read' is a special builtin, it might abort the whole program upon failures, so add extra sanity checks, verifying that the test script exists and is readable, before trying to read from it. =2D-- tests/shell-or-perl | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/shell-or-perl b/tests/shell-or-perl index ff92009..8c92f87 100644 =2D-- a/tests/shell-or-perl +++ b/tests/shell-or-perl @@ -84,12 +84,19 @@ test -z "$test_name" && test_name=3D$test_script # Run the test script # # --------------------- # =20 =2Dif grep '^#!/usr/bin/perl' "$test_script" >/dev/null; then +test -f "$test_script" && test -r "$test_script" \ + || error_ "test script '$test_script' does not exist, or isn't readable" + +read shebang_line < "$test_script" \ + || error_ "cannot read from the test script '$test_script'" + +case $shebang_line in +'#!/usr/bin/perl'*) # The test is a perl script. if $cu_PERL -e 'use warnings' > /dev/null 2>&1; then # Perl is available, see if we must run the test with taint # mode on or not. =2D grep '^#!/usr/bin/perl -T' "$test_script" >/dev/null && T_=3DT || T_= =3D + case $shebang_line in *\ -T*) T_=3DT;; *) T_=3D;; esac # Now run it. exec $cu_PERL -w$T_ -I"$srcdir" -MCoreutils -MCuSkip \ -M"CuTmpdir qw($test_name)" \ @@ -99,10 +106,11 @@ if grep '^#!/usr/bin/perl' "$test_script" >/dev/null; = then echo "$test_name: skip: no usable version of Perl found" exit 77 fi =2Delse + ;; +*) # Assume the test is a shell script. exec $cu_SHELL "$test_script" ${1+"$@"} =2Dfi +esac =20 # ------------- # # Not reached # =2D-=20 1.7.2.3 --Boundary-00=_ivO/NdLlpgyLLMJ-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 19 15:52:01 2011 Received: (at submit) by debbugs.gnu.org; 19 Jun 2011 19:52:01 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QYO2K-0002ba-6F for submit@debbugs.gnu.org; Sun, 19 Jun 2011 15:52:00 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QYO2H-0002bO-Ay for submit@debbugs.gnu.org; Sun, 19 Jun 2011 15:51:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QYO2A-0006oj-QY for submit@debbugs.gnu.org; Sun, 19 Jun 2011 15:51:52 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:33796) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYO2A-0006oe-I1 for submit@debbugs.gnu.org; Sun, 19 Jun 2011 15:51:50 -0400 Received: from eggs.gnu.org ([140.186.70.92]:52193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYO28-0002gt-OA for bug-coreutils@gnu.org; Sun, 19 Jun 2011 15:51:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QYO27-0006lq-98 for bug-coreutils@gnu.org; Sun, 19 Jun 2011 15:51:48 -0400 Received: from mx.meyering.net ([82.230.74.64]:60759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYO24-0006l3-2S; Sun, 19 Jun 2011 15:51:44 -0400 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id CE5DB60141; Sun, 19 Jun 2011 21:51:42 +0200 (CEST) From: Jim Meyering To: Stefano Lattarini Subject: Re: [PATCH 1/2] tests: make test runner a script, not a shell function In-Reply-To: <201106181941.12662.stefano.lattarini@gmail.com> (Stefano Lattarini's message of "Sat, 18 Jun 2011 19:41:11 +0200") References: <201104291121.07627.stefano.lattarini@gmail.com> <201106181023.43630.stefano.lattarini@gmail.com> <87pqmbe5ve.fsf@rho.meyering.net> <201106181941.12662.stefano.lattarini@gmail.com> Date: Sun, 19 Jun 2011 21:51:42 +0200 Message-ID: <87wrgh8ur5.fsf@rho.meyering.net> Lines: 45 MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -6.1 (------) X-Debbugs-Envelope-To: submit Cc: Ralf Wildenhues , bug-coreutils@gnu.org, automake-patches@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) Thank you! That patch looks fine modulo two typos. I'm folding in these corrections and have adjusted the grammar in the commit log (included below). diff --git a/tests/shell-or-perl b/tests/shell-or-perl index ff92009..08604eb 100644 --- a/tests/shell-or-perl +++ b/tests/shell-or-perl @@ -1,7 +1,7 @@ #! /bin/sh # Run a test script of the coreutils test scripts, picking up the right # interpreter (i.e., perl or the shell) and the right flags for it (e.g., -# perl `-T' flag for perl scripts that must rn in tainted mode). +# perl `-T' flag for perl scripts that must run in tainted mode). # # Copyright (C) 2011 Free Software Foundation, Inc. # @@ -71,7 +71,7 @@ while test $# -gt 0; do shift done -unset assing_optarg_to_var var +unset assign_optarg_to_var var case $# in 0) error_ "missing argument";; ------------------------------ tests: make test runner a script, not a shell function This change implements a more correct and idiomatic use of the features of the Automake-provided 'parallel-tests' harness. Moreover, this change is required in order for the testsuite to continue to work with the new testsuite harness that is planned to be introduced in Automake 1.12 (which, as of the writing date, is still under development and in alpha state). * tests/shell-or-perl: New auxiliary script. * tests/Makefile.am (EXTRA_DIST): Distribute it. * tests/check.mk (TESTS_ENVIRONMENT): Remove definition of the `shell_or_perl_' shell function, whose code has been moved in the new script above (with a few improvements and extensions). Do not use it to run the test scripts. (LOG_COMPILER): New, properly invoking `shell-or-perl'. From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 19 16:27:11 2011 Received: (at submit) by debbugs.gnu.org; 19 Jun 2011 20:27:11 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QYOaN-0004yw-9q for submit@debbugs.gnu.org; Sun, 19 Jun 2011 16:27:11 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QYOaK-0004yl-Qo for submit@debbugs.gnu.org; Sun, 19 Jun 2011 16:27:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QYOaE-0003JF-LJ for submit@debbugs.gnu.org; Sun, 19 Jun 2011 16:27:03 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:58152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYOaE-0003It-Ij for submit@debbugs.gnu.org; Sun, 19 Jun 2011 16:27:02 -0400 Received: from eggs.gnu.org ([140.186.70.92]:39847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYOaD-00066K-89 for bug-coreutils@gnu.org; Sun, 19 Jun 2011 16:27:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QYOaC-0003Ie-B4 for bug-coreutils@gnu.org; Sun, 19 Jun 2011 16:27:01 -0400 Received: from mx.meyering.net ([82.230.74.64]:47622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYOa9-0003I8-Vp; Sun, 19 Jun 2011 16:26:58 -0400 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 165E9600E0; Sun, 19 Jun 2011 22:26:27 +0200 (CEST) From: Jim Meyering To: Stefano Lattarini Subject: Re: [PATCH 1/2] tests: make test runner a script, not a shell function In-Reply-To: <201106182018.10934.stefano.lattarini@gmail.com> (Stefano Lattarini's message of "Sat, 18 Jun 2011 20:18:10 +0200") References: <201104291121.07627.stefano.lattarini@gmail.com> <87pqmbe5ve.fsf@rho.meyering.net> <201106181941.12662.stefano.lattarini@gmail.com> <201106182018.10934.stefano.lattarini@gmail.com> Date: Sun, 19 Jun 2011 22:26:26 +0200 Message-ID: <87r56p8t59.fsf@rho.meyering.net> Lines: 51 MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -6.1 (------) X-Debbugs-Envelope-To: submit Cc: Ralf Wildenhues , bug-coreutils@gnu.org, automake-patches@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) Stefano Lattarini wrote: > Subject: [PATCH 2/2] tests: avoid extra forks in the testsuite > > * tests/shell-or-perl: Prefer the `read' builtin over `grep' to > look at the shebang line of test scripts. Since `read' is a > special builtin, it might abort the whole program upon failures, > so add extra sanity checks, verifying that the test script exists > and is readable, before trying to read from it. > --- > tests/shell-or-perl | 16 ++++++++++++---- > 1 files changed, 12 insertions(+), 4 deletions(-) > > diff --git a/tests/shell-or-perl b/tests/shell-or-perl > index ff92009..8c92f87 100644 > --- a/tests/shell-or-perl > +++ b/tests/shell-or-perl > @@ -84,12 +84,19 @@ test -z "$test_name" && test_name=$test_script > # Run the test script # > # --------------------- # > > -if grep '^#!/usr/bin/perl' "$test_script" >/dev/null; then > +test -f "$test_script" && test -r "$test_script" \ > + || error_ "test script '$test_script' does not exist, or isn't readable" > + > +read shebang_line < "$test_script" \ > + || error_ "cannot read from the test script '$test_script'" > + > +case $shebang_line in > +'#!/usr/bin/perl'*) > # The test is a perl script. > if $cu_PERL -e 'use warnings' > /dev/null 2>&1; then > # Perl is available, see if we must run the test with taint > # mode on or not. > - grep '^#!/usr/bin/perl -T' "$test_script" >/dev/null && T_=T || T_= > + case $shebang_line in *\ -T*) T_=T;; *) T_=;; esac > # Now run it. > exec $cu_PERL -w$T_ -I"$srcdir" -MCoreutils -MCuSkip \ > -M"CuTmpdir qw($test_name)" \ > @@ -99,10 +106,11 @@ if grep '^#!/usr/bin/perl' "$test_script" >/dev/null; then > echo "$test_name: skip: no usable version of Perl found" > exit 77 > fi > -else > + ;; > +*) > # Assume the test is a shell script. > exec $cu_SHELL "$test_script" ${1+"$@"} > -fi > +esac Thank you. I pushed that as-is. From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 22 17:45:16 2011 Received: (at control) by debbugs.gnu.org; 22 Jul 2011 21:45:16 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QkNX2-00056h-1V for submit@debbugs.gnu.org; Fri, 22 Jul 2011 17:45:16 -0400 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QkNWz-0004uL-RC for control@debbugs.gnu.org; Fri, 22 Jul 2011 17:45:14 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 460566006C for ; Fri, 22 Jul 2011 23:45:08 +0200 (CEST) From: Jim Meyering To: control@debbugs.gnu.org Subject: tests: make test runner a script, not a shell function Date: Fri, 22 Jul 2011 23:45:08 +0200 Message-ID: <87y5zq6lcr.fsf@rho.meyering.net> Lines: 5 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -6.1 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) close 8893 thanks Fixed by this: http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=a51c6e0356e5c6 From unknown Wed Jul 09 06:15:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 20 Aug 2011 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator