From: Jim Meyering Date: Thu, 6 Dec 2007 13:21:51 +0000 (+0100) Subject: tests: factor out the perl-requiring code in many test scripts X-Git-Tag: v6.11~160 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5282e54c08883cf4ab7ddb3b1874344ff32e5df7;p=thirdparty%2Fcoreutils.git tests: factor out the perl-requiring code in many test scripts * tests/require-perl: New file. * tests/Makefile.am (EXTRA_DIST): Add require-perl. * tests/dd/skip-seek: Use it, and remove manual tests. * tests/du/files0-from: Likewise. * tests/ls/nameless-uid: Likewise. * tests/misc/base64: Likewise. * tests/misc/basename: Likewise. * tests/misc/cut: Likewise. * tests/misc/date: Likewise. * tests/misc/dircolors: Likewise. * tests/misc/dirname: Likewise. * tests/misc/expand: Likewise. * tests/misc/expr: Likewise. * tests/misc/factor: Likewise. * tests/misc/fmt: Likewise. * tests/misc/fold: Likewise. * tests/misc/head-elide-tail: Likewise. * tests/misc/ls-misc: Likewise. * tests/misc/md5sum: Likewise. * tests/misc/md5sum-newline: Likewise. * tests/misc/mktemp: Likewise. * tests/misc/od: Likewise. * tests/misc/paste-no-nl: Likewise. * tests/misc/pr: Likewise. * tests/misc/pwd-long: Likewise. * tests/misc/seq: Likewise. * tests/misc/sha1sum: Likewise. * tests/misc/sha1sum-vec: Likewise. * tests/misc/sha224sum: Likewise. * tests/misc/sha256sum: Likewise. * tests/misc/sha384sum: Likewise. * tests/misc/sha512sum: Likewise. * tests/misc/sort-merge: Likewise. * tests/misc/stat-printf: Likewise. * tests/misc/sum: Likewise. * tests/misc/sum-sysv: Likewise. * tests/misc/test-diag: Likewise. * tests/misc/tsort: Likewise. * tests/misc/tty-eof: Likewise. * tests/misc/unexpand: Likewise. * tests/misc/wc-files0-from: Likewise. * tests/misc/xstrtol: Likewise. * tests/mv/i-1: Likewise. * tests/rm/empty-name: Likewise. * tests/rm/fail-eperm: Likewise. * tests/rm/unreadable: Likewise. (EXTRA_DIST): *do* require require-perl as a stand-alone, 'source'able script. --- diff --git a/tests/Makefile.am b/tests/Makefile.am index ede6310652..d955dd74f4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -20,7 +20,7 @@ EXTRA_DIST = \ lang-default \ mk-script \ other-fs-tmpdir \ - priv-check \ + require-perl \ rwx-to-mode \ sample-test \ setgid-check \ diff --git a/tests/dd/skip-seek b/tests/dd/skip-seek index f2c0393fe5..ce0121c62b 100755 --- a/tests/dd/skip-seek +++ b/tests/dd/skip-seek @@ -18,14 +18,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl SCRIPT_NAME=$0 export SCRIPT_NAME diff --git a/tests/du/files0-from b/tests/du/files0-from index 88f83aab92..4d9b37cb32 100755 --- a/tests/du/files0-from +++ b/tests/du/files0-from @@ -2,7 +2,7 @@ # -*- perl -*- # Exercise du's --files0-from option. -# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2004, 2005, 2007 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 @@ -17,15 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/ls/nameless-uid b/tests/ls/nameless-uid index a78846ca40..a72438863d 100755 --- a/tests/ls/nameless-uid +++ b/tests/ls/nameless-uid @@ -21,16 +21,13 @@ if test "$VERBOSE" = yes; then ls --version fi +: ${srcdir=.} +. $srcdir/../require-perl + . $srcdir/../lang-default PRIV_CHECK_ARG=require-root . $srcdir/../priv-check . $srcdir/../test-lib.sh -$PERL -e 1 > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - (exit 77); exit 77 -} - nameless_uid=`$PERL -e 'foreach my $i (1000..16*1024) { getpwuid $i or (print "$i\n"), exit }'` if test x$nameless_uid = x; then diff --git a/tests/misc/base64 b/tests/misc/base64 index 3276635e8c..0428c04c52 100755 --- a/tests/misc/base64 +++ b/tests/misc/base64 @@ -17,16 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -PROG=`echo $0|sed 's,.*/,,'`; export PROG - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF @@ -164,7 +156,7 @@ push @Tests, @new; my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; -my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $prog = 'base64'; my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); exit $fail; EOF diff --git a/tests/misc/basename b/tests/misc/basename index e492b9e0dd..4302e0b82c 100755 --- a/tests/misc/basename +++ b/tests/misc/basename @@ -16,16 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -PROG=`echo $0|sed 's,.*/,,'`; export PROG - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - << \EOF @@ -43,7 +35,7 @@ my $stat_double = stat('//'); my $double_slash = ($stat_single->dev == $stat_double->dev && $stat_single->ino == $stat_double->ino) ? '/' : '//'; -my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $prog = 'basename'; my @Tests = ( diff --git a/tests/misc/cut b/tests/misc/cut index 2fc4bed053..3bf52163db 100755 --- a/tests/misc/cut +++ b/tests/misc/cut @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/date b/tests/misc/date index 4a87e648ad..ff18b4c0f4 100755 --- a/tests/misc/date +++ b/tests/misc/date @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/dircolors b/tests/misc/dircolors index 01f2211287..31614f9dae 100755 --- a/tests/misc/dircolors +++ b/tests/misc/dircolors @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/dirname b/tests/misc/dirname index 0530175bf0..6b9a8d7b75 100755 --- a/tests/misc/dirname +++ b/tests/misc/dirname @@ -17,16 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -PROG=`echo $0|sed 's,.*/,,'`; export PROG - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - << \EOF @@ -44,7 +36,7 @@ my $stat_double = stat('//'); my $double_slash = ($stat_single->dev == $stat_double->dev && $stat_single->ino == $stat_double->ino) ? '/' : '//'; -my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $prog = 'dirname'; my @Tests = ( diff --git a/tests/misc/expand b/tests/misc/expand index b58ff2970c..6a568be808 100755 --- a/tests/misc/expand +++ b/tests/misc/expand @@ -17,16 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -PROG=`echo $0|sed 's,.*/,,'`; export PROG - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF @@ -49,7 +41,7 @@ my @Tests = my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; -my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $prog = 'expand'; my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); exit $fail; EOF diff --git a/tests/misc/expr b/tests/misc/expr index 360d905838..6d2cbbd1fe 100755 --- a/tests/misc/expr +++ b/tests/misc/expr @@ -17,14 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - << \EOF diff --git a/tests/misc/factor b/tests/misc/factor index ebe0d64341..a350ca9e36 100755 --- a/tests/misc/factor +++ b/tests/misc/factor @@ -18,14 +18,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - << \EOF diff --git a/tests/misc/fmt b/tests/misc/fmt index 0cc9ba2519..49067ad9be 100755 --- a/tests/misc/fmt +++ b/tests/misc/fmt @@ -18,14 +18,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl # Export this to avoid hassles when run in a UTF-8 locale, # since we use 8-bit characters below, and those values are diff --git a/tests/misc/fold b/tests/misc/fold index a43ebf12f8..960d6893d0 100755 --- a/tests/misc/fold +++ b/tests/misc/fold @@ -17,16 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -PROG=`echo $0|sed 's,.*/,,'`; export PROG - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl # Ensure that we don't run an older version of fold. # Prior to 5.0.91, some of the tests below would cause fold to infloop, @@ -63,7 +55,7 @@ my @Tests = my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; -my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $prog = 'fold'; my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); exit $fail; EOF diff --git a/tests/misc/head-elide-tail b/tests/misc/head-elide-tail index 4bdcf535bf..4de108d4af 100755 --- a/tests/misc/head-elide-tail +++ b/tests/misc/head-elide-tail @@ -2,7 +2,7 @@ # -*- perl -*- # Exercise head's --bytes=-N option. -# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2003, 2005, 2007 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 @@ -17,14 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/ls-misc b/tests/misc/ls-misc index 9e07065774..9290eb4d75 100755 --- a/tests/misc/ls-misc +++ b/tests/misc/ls-misc @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - << \EOF diff --git a/tests/misc/md5sum b/tests/misc/md5sum index 1b12e83ada..ca23d9432b 100755 --- a/tests/misc/md5sum +++ b/tests/misc/md5sum @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/md5sum-newline b/tests/misc/md5sum-newline index df3254e715..41139816ac 100755 --- a/tests/misc/md5sum-newline +++ b/tests/misc/md5sum-newline @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl # See if we can create a filename that contains a newline. # Be careful to do it in a subshell so that we can redirect the diff --git a/tests/misc/mktemp b/tests/misc/mktemp index ed4b3c2bfc..affb0d17c3 100755 --- a/tests/misc/mktemp +++ b/tests/misc/mktemp @@ -18,14 +18,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/od b/tests/misc/od index bf41c38465..498e57a85d 100755 --- a/tests/misc/od +++ b/tests/misc/od @@ -17,16 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -PROG=`echo $0|sed 's,.*/,,'`; export PROG - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` me=`echo $0|sed 's,.*/,,'` @@ -78,7 +70,7 @@ my @Tests = my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; -my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $prog = 'od'; my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); exit $fail; EOF diff --git a/tests/misc/paste-no-nl b/tests/misc/paste-no-nl index aa5049c7a5..ec23991826 100755 --- a/tests/misc/paste-no-nl +++ b/tests/misc/paste-no-nl @@ -2,7 +2,7 @@ # -*- perl -*- # Ensure that paste properly handles files lacking a final newline. -# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2003, 2005, 2007 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 @@ -17,14 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/pr b/tests/misc/pr index 0b7e0a2107..550c6d6f20 100755 --- a/tests/misc/pr +++ b/tests/misc/pr @@ -17,15 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/pwd-long b/tests/misc/pwd-long index 5e5b5ad5d8..6ab2188100 100755 --- a/tests/misc/pwd-long +++ b/tests/misc/pwd-long @@ -16,13 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} - -$PERL -e 1 > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +: ${srcdir=.} +. $srcdir/../require-perl . $srcdir/../test-lib.sh diff --git a/tests/misc/seq b/tests/misc/seq index 3365d9521a..9c1e48f01d 100755 --- a/tests/misc/seq +++ b/tests/misc/seq @@ -17,14 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - << \EOF diff --git a/tests/misc/sha1sum b/tests/misc/sha1sum index 62de889d73..b7d288fa24 100755 --- a/tests/misc/sha1sum +++ b/tests/misc/sha1sum @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/sha1sum-vec b/tests/misc/sha1sum-vec index 2dd666c39c..b00ece284d 100755 --- a/tests/misc/sha1sum-vec +++ b/tests/misc/sha1sum-vec @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/sha224sum b/tests/misc/sha224sum index 1fdfd3d50b..022379cad0 100755 --- a/tests/misc/sha224sum +++ b/tests/misc/sha224sum @@ -16,16 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -PROG=`echo $0|sed 's,.*/,,'`; export PROG - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF @@ -58,7 +50,7 @@ foreach $t (@Tests) my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; -my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $prog = 'sha224sum'; my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); exit $fail; EOF diff --git a/tests/misc/sha256sum b/tests/misc/sha256sum index f4f25d8631..f28ef8ff19 100755 --- a/tests/misc/sha256sum +++ b/tests/misc/sha256sum @@ -16,16 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -PROG=`echo $0|sed 's,.*/,,'`; export PROG - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF @@ -64,7 +56,7 @@ foreach $t (@Tests) my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; -my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $prog = 'sha256sum'; my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); exit $fail; EOF diff --git a/tests/misc/sha384sum b/tests/misc/sha384sum index bfb9ed0921..0eb55872f6 100755 --- a/tests/misc/sha384sum +++ b/tests/misc/sha384sum @@ -16,16 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -PROG=`echo $0|sed 's,.*/,,'`; export PROG - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF @@ -64,7 +56,7 @@ foreach $t (@Tests) my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; -my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $prog = 'sha384sum'; my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); exit $fail; EOF diff --git a/tests/misc/sha512sum b/tests/misc/sha512sum index 55798fc707..5977915fc8 100755 --- a/tests/misc/sha512sum +++ b/tests/misc/sha512sum @@ -16,16 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -PROG=`echo $0|sed 's,.*/,,'`; export PROG - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF @@ -64,7 +56,7 @@ foreach $t (@Tests) my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; -my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $prog = 'sha512sum'; my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); exit $fail; EOF diff --git a/tests/misc/sort-merge b/tests/misc/sort-merge index 2795b60f5f..7ac9f84402 100755 --- a/tests/misc/sort-merge +++ b/tests/misc/sort-merge @@ -1,7 +1,7 @@ #!/bin/sh # Test "sort -m". -# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2005-2007 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 @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/stat-printf b/tests/misc/stat-printf index 60d7b6ffa0..f175ba1f09 100755 --- a/tests/misc/stat-printf +++ b/tests/misc/stat-printf @@ -1,7 +1,7 @@ #!/bin/sh # Test "stat --printf". -# Copyright (C) 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2005-2007 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 @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/sum b/tests/misc/sum index d87bdd03fe..14871ec2d5 100755 --- a/tests/misc/sum +++ b/tests/misc/sum @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/sum-sysv b/tests/misc/sum-sysv index 5181cff0a5..d960f9818e 100755 --- a/tests/misc/sum-sysv +++ b/tests/misc/sum-sysv @@ -21,11 +21,8 @@ if test "$VERBOSE" = yes; then sum --version fi -$PERL -e 1 > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +: ${srcdir=.} +. $srcdir/../require-perl # Avoid a problem when run in a UTF-8 locale. # Otherwise, Perl would try to (and fail to) interpret diff --git a/tests/misc/test-diag b/tests/misc/test-diag index 9f0c7cd70c..b7d899b631 100755 --- a/tests/misc/test-diag +++ b/tests/misc/test-diag @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/tsort b/tests/misc/tsort index 9a078aec45..440c60e2dc 100755 --- a/tests/misc/tsort +++ b/tests/misc/tsort @@ -17,14 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/tty-eof b/tests/misc/tty-eof index 086f19cd67..1de1d1f82b 100755 --- a/tests/misc/tty-eof +++ b/tests/misc/tty-eof @@ -17,13 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} - -$PERL -e 1 > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +: ${srcdir=.} +. $srcdir/../require-perl # Ensure that $TMPDIR is valid. TMPDIR=.; export TMPDIR diff --git a/tests/misc/unexpand b/tests/misc/unexpand index e35434403a..d2762f12a6 100755 --- a/tests/misc/unexpand +++ b/tests/misc/unexpand @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/wc-files0-from b/tests/misc/wc-files0-from index 6d0bb8c994..61340d66a1 100755 --- a/tests/misc/wc-files0-from +++ b/tests/misc/wc-files0-from @@ -3,7 +3,7 @@ # Exercise wc's --files0-from option. # This file bears a striking resemblance to tests/du/files0-from. -# Copyright (C) 2006 Free Software Foundation, Inc. +# Copyright (C) 2006, 2007 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 @@ -18,17 +18,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - - -PROG=`echo $0|sed 's,.*/,,'`; export PROG - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/misc/xstrtol b/tests/misc/xstrtol index 7fdc4da56c..874b4a502f 100755 --- a/tests/misc/xstrtol +++ b/tests/misc/xstrtol @@ -21,14 +21,8 @@ if test "$VERBOSE" = yes; then pr --version fi -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/mv/i-1 b/tests/mv/i-1 index 0fee59cb25..326d72e1a4 100755 --- a/tests/mv/i-1 +++ b/tests/mv/i-1 @@ -16,14 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || { - echo 1>&2 "$0: configure didn't find a usable version of Perl," \ - "so can't run this test" - exit 77 -} +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF diff --git a/tests/require-perl b/tests/require-perl new file mode 100644 index 0000000000..1f98edfe4b --- /dev/null +++ b/tests/require-perl @@ -0,0 +1,6 @@ +: ${PERL=perl} +$PERL -e 'use warnings' > /dev/null 2>&1 || { + echo 1>&2 "$0: configure did not find a usable version of Perl," \ + "so skipping this test" + (exit 77); exit 77 +} diff --git a/tests/rm/empty-name b/tests/rm/empty-name index 1384a2fd15..a250985c96 100755 --- a/tests/rm/empty-name +++ b/tests/rm/empty-name @@ -21,11 +21,8 @@ # actually remove files with names of entries in the current directory # but relative to `/' rather than relative to the current directory. -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || - skip_test_ "configure didn't find a usable version of Perl" +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - << \EOF diff --git a/tests/rm/fail-eperm b/tests/rm/fail-eperm index c619574ce8..4abc9dec67 100755 --- a/tests/rm/fail-eperm +++ b/tests/rm/fail-eperm @@ -29,11 +29,8 @@ fi PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 1 > /dev/null 2>&1 || - skip_test_ "configure didn't find a usable version of Perl" +. $srcdir/../require-perl ARGV_0=$0 export ARGV_0 diff --git a/tests/rm/unreadable b/tests/rm/unreadable index 05024c2dc8..4fb40235c3 100755 --- a/tests/rm/unreadable +++ b/tests/rm/unreadable @@ -16,11 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -: ${PERL=perl} : ${srcdir=.} - -$PERL -e 'use warnings;' > /dev/null 2>&1 || - skip_test_ "configure didn't find a usable version of Perl" +. $srcdir/../require-perl me=`echo $0|sed 's,.*/,,'` exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - << \EOF