summaryrefslogtreecommitdiff
path: root/tests/ls-2
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-08-18 08:50:00 +0200
committerJim Meyering <jim@meyering.net>2007-08-18 08:53:31 +0200
commitb78c6b68f77d55b6aeb57853a2f5e2bf312584c1 (patch)
treead6065ca95bf0aeb5a9a4601c3220b0c42b97a17 /tests/ls-2
parentd2e5e366a1d813e5ce2d03e250eb1ebe44473b63 (diff)
downloadcoreutils-b78c6b68f77d55b6aeb57853a2f5e2bf312584c1.tar.xz
Run each Coreutils.pm-based test in its own subdirectory.
* tests/CuTmpdir.pm: New file. * tests/Makefile.am (EXTRA_DIST): Add CuTmpdir.pm. * tests/misc/od, tests/misc/base64, tests/misc/basename: * tests/misc/cut, tests/misc/date, tests/misc/dirname: * tests/misc/expand, tests/misc/fold, tests/misc/head-elide-tail: * tests/misc/paste-no-nl, tests/misc/pr, tests/misc/sha224sum: * tests/misc/sha256sum, tests/misc/sha384sum, tests/misc/sha512sum: * tests/misc/sort-merge, tests/misc/stat-printf, tests/misc/test-diag: * tests/misc/wc-files0-from, tests/misc/xstrtol: * tests/dd/skip-seek, tests/dircolors/simple, tests/du/files0-from: * tests/expr/basic, tests/factor/basic, tests/fmt/basic: * tests/ls-2/tests, tests/md5sum/basic-1, tests/md5sum/newline-1: * tests/seq/basic, tests/sha1sum/basic-1, tests/sha1sum/sample-vec: * tests/sum/basic-1, tests/tsort/basic-1, tests/unexpand/basic-1: * tests/mv/i-1, tests/rm/empty-name, tests/rm/unreadable: Use it. * tests/misc/test-diag: Use "$ENV{abs_top_builddir}/src/test", not "../../src/test", so it works when run from a subdirectory. * tests/ls-2/tests: Create temp files and dirs from within the perl script, so that they're removed, when run from a subdirectory.
Diffstat (limited to 'tests/ls-2')
-rw-r--r--tests/ls-2/Makefile.am1
-rwxr-xr-xtests/ls-2/tests27
2 files changed, 14 insertions, 14 deletions
diff --git a/tests/ls-2/Makefile.am b/tests/ls-2/Makefile.am
index 5ea746ed8..edb6accfa 100644
--- a/tests/ls-2/Makefile.am
+++ b/tests/ls-2/Makefile.am
@@ -3,6 +3,7 @@
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
+ abs_top_builddir=$(abs_top_builddir) \
top_srcdir=$(top_srcdir) \
srcdir=$(srcdir) \
PERL="$(PERL)" \
diff --git a/tests/ls-2/tests b/tests/ls-2/tests
index c97104509..c0500fbcb 100755
--- a/tests/ls-2/tests
+++ b/tests/ls-2/tests
@@ -25,20 +25,8 @@ $PERL -e 1 > /dev/null 2>&1 || {
exit 77
}
-# Set up files used by the setuid-etc tests; skip this entire test if
-# that cannot be done for some reason.
-test=../../src/test
-touch setuid && chmod u+s setuid && $test -u setuid &&
-touch setgid && chmod g+s setgid && $test -g setgid &&
-mkdir sticky && chmod +t sticky && $test -k sticky &&
-mkdir owt && chmod +t,o+w owt && $test -k owt &&
-mkdir owr && chmod o+w owr || {
- echo 1>&2 "$0: cannot create setuid/setgid/sticky files," \
- "so can't run this test"
- exit 77
-}
-
-exec $PERL -w -I$srcdir/.. -MCoreutils -- - << \EOF
+me=`echo $0|sed 's,.*/,,'`
+exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - << \EOF
require 5.003;
use strict;
@@ -47,6 +35,17 @@ use strict;
# Turn off localisation of executable's ouput.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+# Set up files used by the setuid-etc tests; skip this entire test if
+# that cannot be done.
+my $test = "$ENV{abs_top_builddir}/src/test";
+system (qq(touch setuid && chmod u+s setuid && $test -u setuid &&
+ touch setgid && chmod g+s setgid && $test -g setgid &&
+ mkdir sticky && chmod +t sticky && $test -k sticky &&
+ mkdir owt && chmod +t,o+w owt && $test -k owt &&
+ mkdir owr && chmod o+w owr)) == 0
+ or (warn "$program_name: cannot create setuid/setgid/sticky files,"
+ . "so can't run this test\n"), exit 77;
+
my $mkdir = {PRE => sub {mkdir 'd',0755 or die "d: $!\n"}};
my $rmdir = {POST => sub {rmdir 'd' or die "d: $!\n"}};