From 5282e54c08883cf4ab7ddb3b1874344ff32e5df7 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 6 Dec 2007 14:21:51 +0100 Subject: 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. --- tests/Makefile.am | 2 +- tests/dd/skip-seek | 8 +------- tests/du/files0-from | 11 ++--------- tests/ls/nameless-uid | 9 +++------ tests/misc/base64 | 12 ++---------- tests/misc/basename | 12 ++---------- tests/misc/cut | 8 +------- tests/misc/date | 8 +------- tests/misc/dircolors | 8 +------- tests/misc/dirname | 12 ++---------- tests/misc/expand | 12 ++---------- tests/misc/expr | 8 +------- tests/misc/factor | 8 +------- tests/misc/fmt | 8 +------- tests/misc/fold | 12 ++---------- tests/misc/head-elide-tail | 10 ++-------- tests/misc/ls-misc | 8 +------- tests/misc/md5sum | 8 +------- tests/misc/md5sum-newline | 8 +------- tests/misc/mktemp | 8 +------- tests/misc/od | 12 ++---------- tests/misc/paste-no-nl | 10 ++-------- tests/misc/pr | 9 +-------- tests/misc/pwd-long | 9 ++------- tests/misc/seq | 8 +------- tests/misc/sha1sum | 8 +------- tests/misc/sha1sum-vec | 8 +------- tests/misc/sha224sum | 12 ++---------- tests/misc/sha256sum | 12 ++---------- tests/misc/sha384sum | 12 ++---------- tests/misc/sha512sum | 12 ++---------- tests/misc/sort-merge | 10 ++-------- tests/misc/stat-printf | 10 ++-------- tests/misc/sum | 8 +------- tests/misc/sum-sysv | 7 ++----- tests/misc/test-diag | 8 +------- tests/misc/tsort | 8 +------- tests/misc/tty-eof | 9 ++------- tests/misc/unexpand | 8 +------- tests/misc/wc-files0-from | 13 ++----------- tests/misc/xstrtol | 8 +------- tests/mv/i-1 | 8 +------- tests/require-perl | 6 ++++++ tests/rm/empty-name | 5 +---- tests/rm/fail-eperm | 5 +---- tests/rm/unreadable | 5 +---- 46 files changed, 72 insertions(+), 338 deletions(-) create mode 100644 tests/require-perl diff --git a/tests/Makefile.am b/tests/Makefile.am index ede631065..d955dd74f 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 f2c0393fe..ce0121c62 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 88f83aab9..4d9b37cb3 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 a78846ca4..a72438863 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 3276635e8..0428c04c5 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 e492b9e0d..4302e0b82 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 2fc4bed05..3bf52163d 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 4a87e648a..ff18b4c0f 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 01f221128..31614f9da 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 0530175bf..6b9a8d7b7 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 b58ff2970..6a568be80 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 360d90583..6d2cbbd1f 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 ebe0d6434..a350ca9e3 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 0cc9ba251..49067ad9b 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 a43ebf12f..960d6893d 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 4bdcf535b..4de108d4a 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 9e0706577..9290eb4d7 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 1b12e83ad..ca23d9432 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 df3254e71..41139816a 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 ed4b3c2bf..affb0d17c 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 bf41c3846..498e57a85 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 aa5049c7a..ec2399182 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 0b7e0a210..550c6d6f2 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 5e5b5ad5d..6ab218810 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 3365d9521..9c1e48f01 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 62de889d7..b7d288fa2 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 2dd666c39..b00ece284 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 1fdfd3d50..022379cad 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 f4f25d863..f28ef8ff1 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 bfb9ed092..0eb55872f 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 55798fc70..5977915fc 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 2795b60f5..7ac9f8440 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 60d7b6ffa..f175ba1f0 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 d87bdd03f..14871ec2d 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 5181cff0a..d960f9818 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 9f0c7cd70..b7d899b63 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 9a078aec4..440c60e2d 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 086f19cd6..1de1d1f82 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 e35434403..d2762f12a 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 6d0bb8c99..61340d66a 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 7fdc4da56..874b4a502 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 0fee59cb2..326d72e1a 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 000000000..1f98edfe4 --- /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 1384a2fd1..a250985c9 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 c619574ce..4abc9dec6 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 05024c2dc..4fb40235c 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 -- cgit v1.2.3-54-g00ecf