From: Pádraig Brady
Date: Sun, 1 Jul 2018 01:50:40 +0000 (-0700)
Subject: tests: standardize perl usage in tests
X-Git-Tag: v8.30~1
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89f7fcd05564a2ebc851e4c105373978a8a76ade;p=thirdparty%2Fcoreutils.git
tests: standardize perl usage in tests
* tests/cp/fiemap-FMR.sh: Ensure perl is parameterized to $PERL,
and ensure require_perl_ is used, so tests are skipped appropriately.
* tests/cp/preserve-gid.sh: Likewise.
* tests/du/long-from-unreadable.sh: Likewise.
* tests/misc/env-S-script.sh: Likewise.
* tests/misc/sort-benchmark-random.sh: Likewise.
* tests/rm/deep-2.sh: Likewise.
---
diff --git a/tests/cp/fiemap-FMR.sh b/tests/cp/fiemap-FMR.sh
index 563e2ac516..773c99b46d 100755
--- a/tests/cp/fiemap-FMR.sh
+++ b/tests/cp/fiemap-FMR.sh
@@ -21,7 +21,6 @@ print_ver_ cp
require_valgrind_
require_perl_
-: ${PERL=perl}
$PERL -e 'for (1..600) { sysseek (*STDOUT, 4096, 1)' \
-e '&& syswrite (*STDOUT, "a" x 1024) or die "$!"}' > j || fail=1
diff --git a/tests/cp/preserve-gid.sh b/tests/cp/preserve-gid.sh
index cc29e25713..fa949dd0d8 100755
--- a/tests/cp/preserve-gid.sh
+++ b/tests/cp/preserve-gid.sh
@@ -19,6 +19,7 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ cp
+require_perl_
require_root_
# Some of the tests expect a umask that grants group and/or world read access.
diff --git a/tests/du/long-from-unreadable.sh b/tests/du/long-from-unreadable.sh
index 815aba6550..5fe4d649b9 100755
--- a/tests/du/long-from-unreadable.sh
+++ b/tests/du/long-from-unreadable.sh
@@ -31,6 +31,8 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ du
+require_perl_
+
# ecryptfs for example uses some of the file name space
# for encrypting filenames, so we must check dynamically.
name_max=$(stat -f -c %l .)
@@ -58,7 +60,6 @@ dir=$(printf '%200s\n' ' '|tr ' ' x)
cwd=$(pwd)
# Use perl instead:
-: ${PERL=perl}
$PERL \
-e 'my $d = '$dir'; foreach my $i (1..52)' \
-e ' { mkdir ($d, 0700) && chdir $d or die "$!" }' \
diff --git a/tests/misc/env-S-script.sh b/tests/misc/env-S-script.sh
index 9573e6087f..3b048d64e0 100755
--- a/tests/misc/env-S-script.sh
+++ b/tests/misc/env-S-script.sh
@@ -20,6 +20,7 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ env
print_ver_ printf
+
require_perl_
# a shortcut to avoid long lines
@@ -118,7 +119,7 @@ compare exp4 out4 || fail=1
# Ignoring the absolute paths, the script is:
# #!env -S perl -w -T
# print "hello\n";
-{ printf "#!$dir/env -S perl -w -T\n" ;
+{ printf "#!$dir/env -S $PERL -w -T\n" ;
printf 'print "hello\\n";\n' ; } > env5 || framework_failure_
chmod a+x env5 || framework_failure_
cat<<\EOF>exp5 || framework_failure_
@@ -134,7 +135,7 @@ compare exp5 out5 || fail=1
# The backslash before the '$' is required to prevent env(1) from treating
# $ARGV as an (invalid syntax) envvar, and pass it as-is to Perl.
{ printf "#!$dir/env -S " ;
- printf 'perl -mFile::Basename=basename -e ' ;
+ printf "$PERL -mFile::Basename=basename -e " ;
printf '"print basename(\\$ARGV[0]);"\n' ; } > env6 || framework_failure_
chmod a+x env6 || framework_failure_
# Note: the perl script does not output a newline.
diff --git a/tests/misc/sort-benchmark-random.sh b/tests/misc/sort-benchmark-random.sh
index 9cff74582e..b4290ba2a1 100755
--- a/tests/misc/sort-benchmark-random.sh
+++ b/tests/misc/sort-benchmark-random.sh
@@ -20,10 +20,11 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
+require_perl_
very_expensive_
-perl -e '
+$PERL -e '
my $num_lines = 500000;
my $length = 100;
@@ -39,7 +40,7 @@ for (my $i=0; $i < $num_lines; $i++)
# We need to generate a lot of data for sort to show a noticeable
# improvement in performance. Sorting it in PERL may take awhile.
-perl -e '
+$PERL -e '
open (FILE, "