summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.x-sc_GPL_version1
-rw-r--r--ChangeLog33
-rw-r--r--Makefile.am1
-rw-r--r--build-aux/check.mk48
-rw-r--r--tests/Makefile.am33
-rw-r--r--tests/check.mk22
-rw-r--r--tests/du/Makefile.am4
-rw-r--r--tests/ls/Makefile.am2
-rw-r--r--tests/misc/Makefile.am8
-rwxr-xr-xtests/misc/cut2
-rwxr-xr-xtests/misc/ls-time (renamed from tests/ls/time-1)0
-rwxr-xr-xtests/mkdtemp107
-rw-r--r--tests/test-lib.sh40
-rw-r--r--tests/touch/Makefile.am2
-rwxr-xr-xtests/touch/dangling-symlink4
-rwxr-xr-xtests/touch/dir-12
-rwxr-xr-xtests/touch/empty-file9
-rwxr-xr-xtests/touch/fail-diag12
-rwxr-xr-xtests/touch/fifo5
-rwxr-xr-xtests/touch/no-create-missing22
-rwxr-xr-xtests/touch/no-rights40
-rwxr-xr-xtests/touch/not-owner17
-rwxr-xr-xtests/touch/obsolescent20
-rwxr-xr-xtests/touch/read-only10
-rwxr-xr-xtests/touch/relative14
25 files changed, 314 insertions, 144 deletions
diff --git a/.x-sc_GPL_version b/.x-sc_GPL_version
new file mode 100644
index 000000000..d496afaad
--- /dev/null
+++ b/.x-sc_GPL_version
@@ -0,0 +1 @@
+^build-aux/check\.mk$
diff --git a/ChangeLog b/ChangeLog
index 5d537cf49..3a499f3b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -332,6 +332,33 @@
* src/install.c (main): Likewise.
* NEWS: Document the fix.
+2007-08-20 Jim Meyering <jim@meyering.net>
+
+ Parallel "make check" support.
+ * build-aux/check.mk: New file, from The Vaucanson Group.
+ * .x-sc_GPL_version: New file, to allow "version 2 or later"
+ in build-aux/check.mk.
+ * Makefile.am (EXTRA_DIST): Add .x-sc_GPL_version.
+ * tests/check.mk: New file.
+ * tests/Makefile.am (EXTRA_DIST): Add check.mk, mkdtemp and test-lib.sh.
+
+ Begin factoring "sample-test" out of test scripts.
+ * tests/test-lib.sh: New file, to be sourced by all tests that
+ were previously derived from the "sample-test" template.
+ * tests/mkdtemp: New file.
+ * tests/touch/dir-1: Use test-lib.sh.
+ * tests/touch/empty-file: Likewise.
+ * tests/touch/fail-diag: Likewise.
+ * tests/touch/fifo: Likewise.
+ * tests/touch/no-create-missing: Likewise.
+ * tests/touch/no-rights: Likewise. Also, don't sleep.
+ * tests/touch/not-owner: Likewise.
+ * tests/touch/obsolescent: Likewise.
+ * tests/touch/read-only: Likewise.
+ * tests/touch/relative: Likewise.
+ * tests/touch/Makefile.am: Include $(top_srcdir)/tests/check.mk,
+ to get the parallel-"make check" bits.
+
2007-08-18 Jim Meyering <jim@meyering.net>
Use new "idcache.h" header.
@@ -373,6 +400,12 @@
2007-08-15 Jim Meyering <jim@meyering.net>
+ Move a slow test into tests/misc.
+ * tests/ls/time-1: Move this file to tests/misc/ls-time.
+ * tests/misc/ls-time: New file. From tests/ls/time-1.
+ * tests/ls/Makefile.am (TESTS): Remove time-1.
+ * tests/misc/Makefile.am (TESTS): Add ls-time.
+
od --skip (-j) works even on files in /proc, when the kernel lies
* src/od.c (skip): Don't let kernel misinformation (nonempty files
in /proc with stat.st_size == 0) make "od -j N" misbehave.
diff --git a/Makefile.am b/Makefile.am
index 8136526a5..7ff2e0b5c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,6 +20,7 @@ EXTRA_DIST = Makefile.cfg Makefile.maint GNUmakefile \
.prev-version THANKS-to-translators THANKStt.in \
.vg-suppressions \
.x-po-check \
+ .x-sc_GPL_version \
.x-sc_file_system .x-sc_obsolete_symbols \
.x-sc_prohibit_atoi_atof \
.x-sc_prohibit_strcmp \
diff --git a/build-aux/check.mk b/build-aux/check.mk
index 0674f2376..aee037053 100644
--- a/build-aux/check.mk
+++ b/build-aux/check.mk
@@ -42,7 +42,7 @@ max < length($$0) { \
final= final (final ? "\n" : "") " " $$0; \
max = length($$0); \
} \
-END { \
+END { \
for (i = 0; i < max + 2 ; ++i) \
line = line "="; \
print line; \
@@ -53,10 +53,11 @@ END { \
# If stdout is a tty, use colors. If test -t is not supported, then
# this fails; a conservative approach. Of course do not redirect
# stdout here, just stderr...
-am__tty_colors = \
+am__tty_colors = \
if test -t 1 2>/dev/null; then \
red=''; \
grn=''; \
+ lgn=''; \
blu=''; \
std=''; \
fi
@@ -79,7 +80,7 @@ case $$estatus:" $(XFAIL_TESTS) " in \
0:*" $$(basename $<) "*) col=$$red; res=XPASS;; \
0:*) col=$$grn; res=PASS ;; \
77:*) col=$$blu; res=SKIP ;; \
- *:*" $$(basename $<) "*) col=$$grn; res=XFAIL;; \
+ *:*" $$(basename $<) "*) col=$$lgn; res=XFAIL;; \
*:*) col=$$red; res=FAIL ;; \
esac; \
echo "$${col}$$res$${std}: $$(basename $<)"; \
@@ -109,24 +110,29 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
skip=$$(echo "$$results" | grep -c '^SKIP'); \
xfail=$$(echo "$$results" | grep -c '^XFAIL'); \
xpass=$$(echo "$$results" | grep -c '^XPASS'); \
- case fail=$$fail:xfail=$$xfail:xpass=$$xpass in \
- fail=0:xfail=0:xpass=*) \
- msg="All $$all tests passed. ";; \
- fail=0:xfail=*:xpass=*) \
+ failures=$$(expr $$fail + $$xpass); \
+ case fail=$$fail:xpass=$$xpass:xfail=$$xfail in \
+ fail=0:xpass=0:xfail=0) \
+ msg="All $$all tests passed. "; \
+ exit=true;; \
+ fail=0:xpass=0:xfail=*) \
msg="All $$all tests behaved as expected"; \
- msg="$$msg ($$xfail expected failures). ";; \
- fail=*:xfail=*:xpass=0) \
- msg="$$fail of $$all tests failed. ";; \
- fail=*:xfail=*:xpass=*) \
- msg="$$fail of $$all tests did not behave as expected"; \
- msg="$$msg ($$xpass unexpected passes). ";; \
+ msg="$$msg ($$xfail expected failures). "; \
+ exit=true;; \
+ fail=*:xpass=0:xfail=*) \
+ msg="$$fail of $$all tests failed. "; \
+ exit=false;; \
+ fail=*:xpass=*:xfail=*) \
+ msg="$$failures of $$all tests did not behave as expected"; \
+ msg="$$msg ($$xpass unexpected passes). "; \
+ exit=false;; \
*) \
echo >&2 "incorrect case"; exit 4;; \
esac; \
if test "$$skip" -ne 0; then \
msg="$$msg($$skip tests were not run). "; \
fi; \
- if test "$$fail" -ne 0; then \
+ if test "$$failures" -ne 0; then \
{ \
echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
$(am__rst_title); \
@@ -149,13 +155,13 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
fi; \
fi; \
$(am__tty_colors); \
- if test "$$fail" -eq 0; then echo $$grn; else echo $$red; fi; \
+ if $$exit; then echo $$grn; else echo $$red; fi; \
echo "$$msg" | $(am__text_box); \
echo $$std; \
- if test x"$$VERBOSE" != x && test "$$fail" -ne 0; then \
- cat $(TEST_SUITE_LOG); \
- fi; \
- test "$$fail" -eq 0
+ test x"$$VERBOSE" = x || $$exit || cat $(TEST_SUITE_LOG); \
+ $$exit
+
+# if test x"$$VERBOSE" != x && ! $exit; then
# Run all the tests.
check-TESTS:
@@ -183,13 +189,13 @@ TEST_SUITE_HTML = $(TEST_SUITE_LOG:.log=.html)
exit 2; \
fi; \
$$R2H $< >$@.tmp
- mv $@.tmp $@
+ @mv $@.tmp $@
# Be sure to run check-TESTS first, and then to convert the result.
# Beware of concurrent executions. And expect check-TESTS to fail.
check-html:
@if $(MAKE) $(AM_MAKEFLAGS) check-TESTS; then :; else \
- rv=$?; \
+ rv=$$?; \
$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_HTML); \
exit $$rv; \
fi
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b39e5f2b6..5d91f5956 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,13 +14,32 @@ TESTS_ENVIRONMENT = \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../src$(PATH_SEPARATOR)$$PATH"
-EXTRA_DIST = \
- $(TESTS) Coreutils.pm CuTmpdir.pm Makefile.am.in README acl envvar-check \
- expensive group-names input-tty lang-default mk-script \
- other-fs-tmpdir priv-check \
- rwx-to-mode sample-test selinux setgid-check sparse-file \
- strace \
- umask-check very-expensive
+EXTRA_DIST = \
+ $(TESTS) \
+ Coreutils.pm \
+ CuTmpdir.pm \
+ Makefile.am.in \
+ README \
+ acl \
+ check.mk \
+ envvar-check \
+ expensive \
+ group-names \
+ input-tty \
+ lang-default \
+ mk-script \
+ mkdtemp \
+ other-fs-tmpdir \
+ priv-check \
+ rwx-to-mode \
+ sample-test \
+ selinux \
+ setgid-check \
+ sparse-file \
+ strace \
+ test-lib.sh \
+ umask-check \
+ very-expensive
## N O T E :: Please do not add new tests/ directories.
## There are too many already. Put new tests in misc/.
diff --git a/tests/check.mk b/tests/check.mk
new file mode 100644
index 000000000..f5c08a259
--- /dev/null
+++ b/tests/check.mk
@@ -0,0 +1,22 @@
+# FIXME: add comment
+
+# Ensure that all version-controlled executable files are listed in TESTS.
+_v = TESTS
+FIXME_hook_this_to_make_distcheck:
+ sed -n '/^$(_v) =/,/[^\]$$/p' $(srcdir)/Makefile.am \
+ | sed 's/^ *//;/^\$$.*/d;/^$(_v) =/d' \
+ | tr -s '\012\\' ' ' | fmt -1 | sort -u > t1
+ find `$(top_srcdir)/build-aux/vc-list-files $(srcdir)` \
+ -type f -perm -111 -printf '%f\n'|sort -u \
+ | diff -u t1 -
+
+# Append this, because automake does the same.
+TESTS_ENVIRONMENT += \
+ abs_top_srcdir=$(abs_top_srcdir) \
+ srcdir=$(srcdir)
+
+TEST_LOGS = $(TESTS:=.log)
+
+# Parallel replacement of Automake's check-TESTS target.
+# Include it last.
+include $(top_srcdir)/build-aux/check.mk
diff --git a/tests/du/Makefile.am b/tests/du/Makefile.am
index 71ef3f341..badc0c98d 100644
--- a/tests/du/Makefile.am
+++ b/tests/du/Makefile.am
@@ -16,12 +16,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
TESTS = \
+ 2g \
inacc-dir \
one-file-system \
inacc-dest \
long-from-unreadable \
long-sloop \
- 2g \
files0-from \
inaccessible-cwd \
deref-args \
@@ -34,3 +34,5 @@ TESTS_ENVIRONMENT = \
PERL="$(PERL)" \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
+
+include $(top_srcdir)/tests/check.mk
diff --git a/tests/ls/Makefile.am b/tests/ls/Makefile.am
index 2d6e0cde3..b2aca8b5a 100644
--- a/tests/ls/Makefile.am
+++ b/tests/ls/Makefile.am
@@ -22,7 +22,7 @@ TESTS = \
stat-failed \
stat-dtype \
inode dangle file-type recursive dired infloop \
- rt-1 time-1 symlink-slash follow-slink no-arg m-option \
+ rt-1 symlink-slash follow-slink no-arg m-option \
stat-vs-dirent x-option
EXTRA_DIST = $(TESTS)
diff --git a/tests/misc/Makefile.am b/tests/misc/Makefile.am
index 236fb7f04..98951d8dd 100644
--- a/tests/misc/Makefile.am
+++ b/tests/misc/Makefile.am
@@ -25,7 +25,6 @@ TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \
abs_top_builddir=$(abs_top_builddir) \
abs_top_srcdir=$(abs_top_srcdir) \
- srcdir=$(srcdir) \
PACKAGE_VERSION=$(PACKAGE_VERSION) \
PERL="$(PERL)" \
BUILD_SRC_DIR="`pwd`/../../src" \
@@ -43,6 +42,7 @@ TESTS_ENVIRONMENT = \
TESTS = \
head-elide-tail \
+ ls-time \
date \
xstrtol \
od \
@@ -97,8 +97,4 @@ TESTS = \
test-diag \
tty-eof
-TEST_LOGS = $(TESTS:=.log)
-
-# Parallel replacement of Automake's check-TESTS target.
-# Include it last: TEST_LOGS has a default value there.
-include $(top_srcdir)/build-aux/check.mk
+include $(top_srcdir)/tests/check.mk
diff --git a/tests/misc/cut b/tests/misc/cut
index be2378250..44758343c 100755
--- a/tests/misc/cut
+++ b/tests/misc/cut
@@ -26,7 +26,7 @@ $PERL -e 1 > /dev/null 2>&1 || {
}
me=`echo $0|sed 's,.*/,,'`
-exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\FILE_EOF
+exec $PERL -w -I$srcdir/.. -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF
require 5.003;
use strict;
diff --git a/tests/ls/time-1 b/tests/misc/ls-time
index 9456411bd..9456411bd 100755
--- a/tests/ls/time-1
+++ b/tests/misc/ls-time
diff --git a/tests/mkdtemp b/tests/mkdtemp
new file mode 100755
index 000000000..48fe054ff
--- /dev/null
+++ b/tests/mkdtemp
@@ -0,0 +1,107 @@
+#!/bin/sh
+# Create a temporary directory, sort of like mktemp -d does.
+# Usage: mkdtemp /tmp phoey.XXXXXXXXXX
+
+# First, try to use the mktemp program.
+# Failing that, we'll roll our own mktemp-like function:
+# - try to get random bytes from /dev/urandom
+# - failing that, generate output from a combination of quickly-varying
+# sources and gzip. Ignore non-varying gzip header, and extract
+# "random" bits from there.
+# - given those bits, map to file-name bytes using tr, and try to create
+# the desired directory.
+# - make only $MAX_TRIES attempts
+
+ME=$(basename "$0")
+die() { echo >&2 "$ME: $@"; exit 1; }
+
+MAX_TRIES=4
+
+rand_bytes()
+{
+ n=$1
+
+ chars=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
+
+ dev_rand=/dev/urandom
+ if test -r "$dev_rand"; then
+ # Note: 256-length($chars) == 194; 3 copies of $chars is 186 + 8 = 194.
+ head -c$n "$dev_rand" | tr -c $chars 01234567$chars$chars$chars
+ return
+ fi
+
+ cmds='date; date +%N; free; who -a; w; ps auxww; ps ef; netstat -n'
+ data=$( (eval "$cmds") 2>&1 | gzip )
+
+ n_plus_50=$(expr $n + 50)
+
+ # Ensure that $data has length at least 50+$n
+ while :; do
+ len=$(echo "$data"|wc -c)
+ test $n_plus_50 -le $len && break;
+ data=$( (echo "$data"; eval "$cmds") 2>&1 | gzip )
+ done
+
+ echo "$data" \
+ | dd bs=1 skip=50 count=$n 2>/dev/null \
+ | tr -c $chars 01234567$chars$chars$chars
+}
+
+mkdtemp()
+{
+ case $# in
+ 2);;
+ *) die "Usage: $ME DIR TEMPLATE";;
+ esac
+
+ destdir=$1
+ template=$2
+
+ case $template in
+ *XXXX) ;;
+ *) die "invalid template: $template (must have a suffix of at least 4 X's)";;
+ esac
+
+ fail=0
+
+ # First, try to use mktemp.
+ d=$(env -u TMPDIR mktemp -d -t -p "$destdir" "$template" 2>/dev/null) \
+ || fail=1
+
+ # The resulting name must be in the specified directory.
+ case $d in "$destdir"*);; *) fail=1;; esac
+
+ # It must have created the directory.
+ test -d "$d" || fail=1
+
+ # It must have 0700 permissions.
+ perms=$(ls -dgo "$d" 2>/dev/null) || fail=1
+ case $perms in drwx------*) ;; *) fail=1;; esac
+
+ test $fail = 0 && {
+ echo "$d"
+ return
+ }
+
+ # If we reach this point, we'll have to create a directory manually.
+
+ # Get a copy of the template without its suffix of X's.
+ base_template=$(echo "$template"|sed 's/XX*$//')
+
+ # Calculate how many X's we've just removed.
+ nx=$(expr length "$template" - length "$base_template")
+
+ err=
+ i=1
+ while :; do
+ X=$(rand_bytes $nx)
+ candidate_dir="$destdir/$base_template$X"
+ err=$(mkdir -m 0700 "$candidate_dir" 2>&1) \
+ && { echo "$candidate_dir"; return; }
+ test $MAX_TRIES -le $i && break;
+ i=$(expr $i + 1)
+ done
+ die "$err"
+}
+
+mkdtemp "$@"
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
new file mode 100644
index 000000000..79d0ef2c7
--- /dev/null
+++ b/tests/test-lib.sh
@@ -0,0 +1,40 @@
+# source this file; set up for tests
+
+# Skip this test if the shell lacks support for functions.
+unset function_test
+eval 'function_test() { return 11; }; function_test'
+if test $? != 11; then
+ echo "$0: /bin/sh lacks support for functions; skipping this test." 1>&2
+ (exit 77); exit 77
+fi
+
+test_dir_=$(pwd)
+
+this_test_() { echo "./$0" | sed 's,.*/,,'; }
+this_test=$(this_test_)
+
+. $srcdir/../envvar-check
+
+# This is a stub function that is run upon trap (upon regular exit and
+# interrupt). Override it with a per-test function, e.g., to unmount
+# a partition, or to undo any other global state changes.
+cleanup_() { :; }
+
+t_=$($abs_top_srcdir/tests/mkdtemp $test_dir_ cu-$this_test.XXXXXXXXXX) \
+ || error "failed to create temporary directory in $test_dir_"
+
+# Run each test from within a temporary sub-directory named after the
+# test itself, and arrange to remove it upon exception or normal exit.
+trap 'st=$?; cleanup_; d='"$t_"';
+ cd '"$test_dir_"' && chmod -R u+rwx "$d" && rm -rf "$d" && exit $st' 0
+trap '(exit $?); exit $?' 1 2 13 15
+
+cd $t_ || error "failed to cd to $t_"
+
+if ( diff --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
+ compare() { diff -u "$@"; }
+elif ( cmp --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
+ compare() { cmp -s "$@"; }
+else
+ compare() { cmp "$@"; }
+fi
diff --git a/tests/touch/Makefile.am b/tests/touch/Makefile.am
index e772f384e..6978a51b4 100644
--- a/tests/touch/Makefile.am
+++ b/tests/touch/Makefile.am
@@ -26,3 +26,5 @@ TESTS_ENVIRONMENT = \
host_triplet=$(host_triplet) \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
+
+include $(top_srcdir)/tests/check.mk
diff --git a/tests/touch/dangling-symlink b/tests/touch/dangling-symlink
index c3c00e959..908f30a8a 100755
--- a/tests/touch/dangling-symlink
+++ b/tests/touch/dangling-symlink
@@ -2,7 +2,7 @@
# Make sure touch can create a file through a dangling symlink.
# This was broken in the 4.0[e-i] test releases.
-# Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 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
@@ -22,6 +22,8 @@ if test "$VERBOSE" = yes; then
touch --version
fi
+. $srcdir/../test-lib.sh
+
rm -f touch-target t-symlink
ln -s touch-target t-symlink
fail=0
diff --git a/tests/touch/dir-1 b/tests/touch/dir-1
index bbfbd68a6..383e00df4 100755
--- a/tests/touch/dir-1
+++ b/tests/touch/dir-1
@@ -7,6 +7,8 @@ if test "$VERBOSE" = yes; then
touch --version
fi
+. $srcdir/../test-lib.sh
+
fail=0
touch . || fail=1
exit $fail
diff --git a/tests/touch/empty-file b/tests/touch/empty-file
index 6ab07e388..013d93f99 100755
--- a/tests/touch/empty-file
+++ b/tests/touch/empty-file
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure touch can set the mtime on an empty file.
-# Copyright (C) 1998, 1999, 2000, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1998, 1999, 2000, 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
@@ -26,7 +26,7 @@ if test "$VERBOSE" = yes; then
touch --version
fi
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
DEFAULT_SLEEP_SECONDS=2
SLEEP_SECONDS=${SLEEP_SECONDS=$DEFAULT_SLEEP_SECONDS}
@@ -50,11 +50,6 @@ for d in $TOUCH_DIR_LIST; do
test -f $d/c || framework_failure=1
done
-if test $framework_failure = 1; then
- echo 'failure in testing framework'
- exit 1
-fi
-
echo sleeping for $SLEEP_SECONDS seconds...
sleep $SLEEP_SECONDS
for d in $TOUCH_DIR_LIST; do
diff --git a/tests/touch/fail-diag b/tests/touch/fail-diag
index a43b0d9ca..b1abdba37 100755
--- a/tests/touch/fail-diag
+++ b/tests/touch/fail-diag
@@ -1,7 +1,7 @@
#!/bin/sh
# make sure touch gives reasonable diagnostics
-# Copyright (C) 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001-2004, 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
@@ -25,14 +25,9 @@ fi
. $srcdir/../lang-default
PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
-pwd=`pwd`
-tmp=fail-diag.$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
+. $srcdir/../test-lib.sh
framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
d1=no-$$
dir=/$d1/such-dir
@@ -51,7 +46,6 @@ cat <<EOF > exp
touch: cannot touch \`$dir': No such file or directory
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/touch/fifo b/tests/touch/fifo
index 335b0c200..0e841a06c 100755
--- a/tests/touch/fifo
+++ b/tests/touch/fifo
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure touch works on fifos without hanging.
-# Copyright (C) 2000 Free Software Foundation, Inc.
+# Copyright (C) 2000, 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
@@ -21,6 +21,8 @@ if test "$VERBOSE" = yes; then
touch --version
fi
+. $srcdir/../test-lib.sh
+
framework_failure=0
tmp=fifo-$$
@@ -41,6 +43,5 @@ fi
fail=0
touch $tmp || fail=1
-rm -rf $tmp
exit $fail
diff --git a/tests/touch/no-create-missing b/tests/touch/no-create-missing
index c18db48a7..79a2452e3 100755
--- a/tests/touch/no-create-missing
+++ b/tests/touch/no-create-missing
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that touch -c no-such-file no longer fails (it did in 4.1.8).
-# Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2004-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
@@ -21,19 +21,7 @@ if test "$VERBOSE" = yes; then
touch --version
fi
-pwd=`pwd`
-tmp=`echo "$0"|sed 's,.*/,,'`.tmp
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+. $srcdir/../test-lib.sh
fail=0
@@ -41,11 +29,13 @@ touch -c no-file > /dev/null 2>&1 || fail=1
touch -cm no-file > /dev/null 2>&1 || fail=1
touch -ca no-file > /dev/null 2>&1 || fail=1
+test="$abs_top_builddir/src/test"
+
# If >&- works, test "touch -c -" etc.
# >&- apparently does not work in HP-UX 11.23.
# This test is ineffective unless /dev/stdout also works.
-if "$pwd/../../src/test" -w /dev/stdout >/dev/null &&
- "$pwd/../../src/test" ! -w /dev/stdout >&-; then
+if "$test" -w /dev/stdout >/dev/null &&
+ "$test" ! -w /dev/stdout >&-; then
touch -c - >&- 2> /dev/null || fail=1
touch -cm - >&- 2> /dev/null || fail=1
touch -ca - >&- 2> /dev/null || fail=1
diff --git a/tests/touch/no-rights b/tests/touch/no-rights
index e867d300f..72c3caad7 100755
--- a/tests/touch/no-rights
+++ b/tests/touch/no-rights
@@ -2,7 +2,7 @@
# Make sure touch can update the times on a file that is neither
# readable nor writable.
-# Copyright (C) 1999, 2000, 2002, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2002, 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
@@ -22,34 +22,30 @@ if test "$VERBOSE" = yes; then
touch --version
fi
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
-DEFAULT_SLEEP_SECONDS=2
-SLEEP_SECONDS=${SLEEP_SECONDS=$DEFAULT_SLEEP_SECONDS}
+# Make sure t2 is newer than t1.
+touch -d '2000-01-01 00:00' t1 || framework_failure=1
+touch -d '2000-01-02 00:00' t2 || framework_failure=1
-t1=no-rw1
-t2=no-rw2
-rm -rf $t1 $t2
-: > $t1
+framework_failure=0
+set x `ls -t t1 t2`
+test "$*" = "x t2 t1" || framework_failure=1
-# Make sure $t2 is two seconds newer than $t1.
-echo sleeping for $SLEEP_SECONDS seconds...
-sleep $SLEEP_SECONDS
-: > $t2
-fail=0
+if test $framework_failure = 1; then
+ echo "$0: failure in testing framework" 1>&2
+ (exit 1); exit 1
+fi
-set x `ls -t $t1 $t2`
-test "$*" = "x $t2 $t1" || fail=1
+fail=0
-chmod 0 $t1
-touch -d tomorrow -c $t1 || fail=1
+chmod 0 t1
+touch -d '2000-01-03 00:00' -c t1 || fail=1
-set x `ls -t $t1 $t2`
-test "$*" = "x $t1 $t2" || fail=1
+set x `ls -t t1 t2`
+test "$*" = "x t1 t2" || fail=1
# Also test the combination of --no-create and -a.
-touch -a --no-create $t1 || fail=1
-
-rm -f $t1 $t2
+touch -a --no-create t1 || fail=1
exit $fail
diff --git a/tests/touch/not-owner b/tests/touch/not-owner
index 3719eb231..a7496a006 100755
--- a/tests/touch/not-owner
+++ b/tests/touch/not-owner
@@ -2,7 +2,7 @@
# Make sure that touch gives reasonable diagnostics when applied
# to an unwritable directory owned by some other user.
-# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2003-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
@@ -22,7 +22,6 @@ if test "$VERBOSE" = yes; then
touch --version
fi
-. $srcdir/../envvar-check
. $srcdir/../lang-default
PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
@@ -37,19 +36,7 @@ if $test -O / || $test -G /; then
(exit 77); exit 77
fi
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+. $srcdir/../test-lib.sh
fail=0
diff --git a/tests/touch/obsolescent b/tests/touch/obsolescent
index a1504f31d..dc1008d10 100755
--- a/tests/touch/obsolescent
+++ b/tests/touch/obsolescent
@@ -1,7 +1,7 @@
#!/bin/sh
# Test touch with obsolescent 8- or 10-digit time stamps.
-# Copyright (C) 2000, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2004-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,27 +16,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-_POSIX2_VERSION=199209; export _POSIX2_VERSION
-POSIXLY_CORRECT=1; export POSIXLY_CORRECT
-
if test "$VERBOSE" = yes; then
set -x
touch --version
fi
-pwd=`pwd`
-tmp=obsol.$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+. $srcdir/../test-lib.sh
-if test $framework_failure = 1; then
- echo 'failure in testing framework'
- (exit 1); exit 1
-fi
+_POSIX2_VERSION=199209; export _POSIX2_VERSION
+POSIXLY_CORRECT=1; export POSIXLY_CORRECT
fail=0
diff --git a/tests/touch/read-only b/tests/touch/read-only
index e0daef610..771eca4af 100755
--- a/tests/touch/read-only
+++ b/tests/touch/read-only
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure that touch can operate on read-only files
-# 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
@@ -23,15 +23,9 @@ fi
PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
+. $srcdir/../test-lib.sh
framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
: > read-only || framework_failure=1
chmod 444 read-only || framework_failure=1
diff --git a/tests/touch/relative b/tests/touch/relative
index 925c83473..02dfe9c6c 100755
--- a/tests/touch/relative
+++ b/tests/touch/relative
@@ -2,7 +2,7 @@
# Demonstrate using a combination of --reference and --date to
# set the time of a file back by an arbitrary amount.
-# Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2004, 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
@@ -22,16 +22,9 @@ if test "$VERBOSE" = yes; then
touch --version
fi
-. $srcdir/../envvar-check
-
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
+. $srcdir/../test-lib.sh
framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
TZ=UTC0 touch --date='2004-01-16 12:00 +0000' f || framework_failure=1
if test $framework_failure = 1; then
@@ -51,7 +44,6 @@ cat <<\EOF > exp || fail=1
2004-01-11
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail