More misc, test-related changes. (some to allow running tests as root)
authorJim Meyering <jim@meyering.net>
Wed, 12 Sep 2007 12:52:26 +0000 (14:52 +0200)
committerJim Meyering <jim@meyering.net>
Sat, 15 Sep 2007 06:40:39 +0000 (08:40 +0200)
75 files changed:
tests/chgrp/no-x
tests/chmod/no-x
tests/chown/preserve-root
tests/cp/fail-perm
tests/dd/misc
tests/du/inacc-dest
tests/du/inacc-dir
tests/du/inaccessible-cwd
tests/du/no-x
tests/install/basic-1
tests/ls/stat-failed
tests/misc/pathchk1
tests/misc/selinux
tests/misc/shred-remove
tests/mkdir/p-3
tests/mv/Makefile.am
tests/mv/childproof
tests/mv/dup-source
tests/mv/hard-2
tests/mv/hard-3
tests/mv/i-2
tests/mv/i-3
tests/mv/leak-fd
tests/mv/part-fail
tests/mv/perm-1
tests/rm/Makefile.am
tests/rm/cycle
tests/rm/dangling-symlink
tests/rm/deep-1
tests/rm/dir-no-w
tests/rm/dir-nonrecur
tests/rm/dot-rel
tests/rm/empty-inacc
tests/rm/f-1
tests/rm/fail-2eperm
tests/rm/fail-eacces
tests/rm/hash
tests/rm/i-1
tests/rm/i-never
tests/rm/i-no-r
tests/rm/ignorable
tests/rm/inaccessible
tests/rm/interactive-always
tests/rm/interactive-once
tests/rm/ir-1
tests/rm/isatty
tests/rm/no-give-up
tests/rm/one-file-system
tests/rm/r-1
tests/rm/r-2
tests/rm/r-3
tests/rm/r-4
tests/rm/readdir-bug
tests/rm/rm1
tests/rm/rm2
tests/rm/rm3
tests/rm/rm4
tests/rm/rm5
tests/rm/sunos-1
tests/rm/unread2
tests/rm/unread3
tests/rm/v-slash
tests/rmdir/Makefile.am
tests/rmdir/fail-perm
tests/rmdir/ignore
tests/rmdir/t-slash
tests/sample-test
tests/test-lib.sh
tests/touch/empty-file
tests/touch/fail-diag
tests/touch/fifo
tests/touch/no-rights
tests/touch/not-owner
tests/touch/read-only
tests/touch/relative

index a98ba90..57900d8 100755 (executable)
@@ -24,9 +24,8 @@ fi
 
 . $srcdir/../lang-default
 . $srcdir/../group-names
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
-
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 set _ $groups; shift
 g1=$1
index 64dffb9..8e84ad2 100755 (executable)
@@ -23,10 +23,10 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
-mkdir -p d/no-x/y || framework_failure
+mkdir -p d/no-x/y a/b || framework_failure
 chmod u=rw d/no-x || framework_failure
 
 fail=0
@@ -52,7 +52,6 @@ EOF
 
 compare out exp || fail=1
 
-mkdir -p a/b
 cd a
 # This will fail with ``chmod: fts_read failed: Permission denied''
 chmod a-x . b 2> /dev/null && fail=1
index de45cbc..e418472 100755 (executable)
@@ -22,8 +22,8 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 mkdir d && ln -s / d/slink-to-root
 
index 0ed9166..49b06b0 100755 (executable)
@@ -22,8 +22,8 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 mkdir D D/D || framework_failure
 touch D/a || framework_failure
index aea9491..76183b3 100755 (executable)
@@ -31,14 +31,9 @@ tmp_out=dd-out.$$
 
 fail=0
 warn=0
-test_failure=0
-echo data > $tmp_in || test_failure=1
-ln $tmp_in $tmp_in2 || test_failure=1
-ln -s $tmp_in $tmp_sym || test_failure=1
-if test $test_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+echo data > $tmp_in || framework_failure
+ln $tmp_in $tmp_in2 || framework_failure
+ln -s $tmp_in $tmp_sym || framework_failure
 
 dd if=$tmp_in of=$tmp_out 2> /dev/null || fail=1
 compare $tmp_in $tmp_out || fail=1
index cd2e1e8..c2bab2c 100755 (executable)
@@ -23,8 +23,8 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 mkdir f && cd f && mkdir a b c d e && touch c/j && chmod a-x c \
     || framework_failure
index 1ee5943..f7d553a 100755 (executable)
@@ -21,6 +21,7 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 mkdir -p a/sub || framework_failure
 
index 6706c19..8eb6693 100755 (executable)
@@ -25,8 +25,8 @@ if test "$VERBOSE" = yes; then
   du --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 cwd=`pwd`
 mkdir -p no-x a/b || framework_failure
index 630ca17..5f888ed 100755 (executable)
@@ -23,8 +23,8 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 mkdir -p d/no-x/y || framework_failure
 chmod u=rw d/no-x || framework_failure
index 89d14d2..ca24a9d 100755 (executable)
@@ -21,9 +21,9 @@ if test "$VERBOSE" = yes; then
   ginstall --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../lang-default
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 dir=dir
 file=file
index 02c3bf1..2d6e988 100755 (executable)
@@ -23,8 +23,8 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 mkdir d || framework_failure
 ln -s / d/s || framework_failure
index ffe9179..453a8e2 100755 (executable)
@@ -21,8 +21,8 @@ if test "$VERBOSE" = yes; then
   pathchk --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 touch file || framework_failure
 
index 90ab2d6..a4fc78a 100755 (executable)
@@ -12,8 +12,8 @@ fi
 
 . $srcdir/../lang-default
 . $srcdir/../selinux
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 # Create a regular file, dir, fifo.
 touch f || framework_failure
index ae7443b..f09c6f3 100755 (executable)
@@ -21,8 +21,8 @@ if test "$VERBOSE" = yes; then
   shred --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 # The length of the basename is what matters.
 # In this case, shred would try to rename the file 256^10 times
index ff011e6..4010911 100755 (executable)
@@ -23,8 +23,8 @@ if test "$VERBOSE" = yes; then
   mkdir --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 mkdir no-access || framework_failure
 mkdir no-acce2s || framework_failure
index d043c8b..4fa09fb 100644 (file)
@@ -32,10 +32,18 @@ TESTS = \
   perm-1 \
   i-link-no \
   part-fail \
-  dup-source childproof i-4 i-5 update i-2 mv-special-1 \
-  into-self into-self-2 into-self-3 into-self-4 \
+  dup-source childproof update mv-special-1 \
+  into-self \
+  into-self-2 \
+  into-self-3 \
+  into-self-4 \
+  i-1 \
+  i-2 \
+  i-3 \
+  i-4 \
+  i-5 \
   backup-is-src \
-  i-1 hard-link-1 force partition-perm to-symlink dir-file diag \
+  hard-link-1 force partition-perm to-symlink dir-file diag \
   part-symlink part-rename trailing-slash
 
 EXTRA_DIST = $(TESTS) vfat
index 6d93974..cdce932 100755 (executable)
@@ -26,8 +26,8 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 mkdir a b c || framework_failure
 echo a > a/f || framework_failure
index a851ba8..a3eff6b 100755 (executable)
@@ -26,8 +26,8 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 fail=0
 
index 62467e6..7833e43 100755 (executable)
@@ -23,8 +23,8 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 mkdir dst || framework_failure
 (cd dst && touch a b c) || framework_failure
index cb02422..8d532a7 100755 (executable)
@@ -35,8 +35,8 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 mkdir -p x dst/x || framework_failure
 touch dst/x/b || framework_failure
index 6c654c9..49f9d98 100755 (executable)
@@ -27,8 +27,8 @@ fi
 # Make sure we get English translations.
 . $srcdir/../lang-default
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 for i in a b c d e f g h; do
   echo $i > $i || framework_failure
index 8a75de7..15f25ce 100755 (executable)
@@ -23,8 +23,9 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../input-tty
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 touch f g h i || framework_failure
 chmod 0 g i || framework_failure
@@ -40,7 +41,7 @@ kill $pid
 
 # Make sure out contains the prompt.
 case "`cat out`" in
-  "mv: overwrite \`g', overriding mode 0000?"*) ;;
+  "mv: try to overwrite \`g', overriding mode 0000"*) ;;
   *) fail=1 ;;
 esac
 
index 515ad20..7a0a0ba 100755 (executable)
@@ -27,8 +27,8 @@ fi
 # framework-failure on systems with a smaller command-line length
 . $srcdir/../expensive
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 cleanup_() { rm -rf "$other_partition_tmpdir"; }
 . "$abs_top_srcdir/tests/other-fs-tmpdir"
 
index 1a43baf..4f12c14 100755 (executable)
@@ -25,8 +25,8 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 cleanup_() { t=$other_partition_tmpdir; chmod -R 700 "$t"; rm -rf "$t"; }
 . "$abs_top_srcdir/tests/other-fs-tmpdir"
 
index af85919..08a4eaa 100755 (executable)
@@ -23,8 +23,8 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 mkdir -p no-write/dir || framework_failure
 chmod u-w no-write || framework_failure
index 2246ecd..21d3f4d 100644 (file)
@@ -17,6 +17,9 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 TESTS = \
+  deep-1 \
+  hash \
+  dangling-symlink \
   v-slash \
   i-never \
   fail-eacces \
@@ -32,8 +35,8 @@ TESTS = \
   dir-no-w \
   fail-2eperm \
   cycle i-no-r fail-eperm \
-  dangling-symlink rm1 rm2 rm3 rm4 rm5 \
-  unread2 r-1 r-2 r-3 r-4 i-1 ir-1 f-1 sunos-1 deep-1 hash \
+  rm1 rm2 rm3 rm4 rm5 \
+  unread2 r-1 r-2 r-3 r-4 i-1 ir-1 f-1 sunos-1 \
   interactive-always interactive-once \
   isatty # unreadable empty-name
 EXTRA_DIST = $(TESTS)
@@ -48,3 +51,5 @@ TESTS_ENVIRONMENT = \
   PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
   PACKAGE_VERSION=$(PACKAGE_VERSION) \
   PROG=rm
+
+include $(top_srcdir)/tests/check.mk
index b6e3576..9f7bfcc 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # rm (coreutils-4.5.4) could be tricked into mistakenly reporting a cycle.
 
-# Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2003, 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,25 +22,13 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+skip_if_root_
 
-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
 mkdir -p a/b
 touch a/b/file
 chmod u-w a/b
 
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
-
 fail=0
 
 rm -rf a a 2>&1 | sed 's/:[^:]*$//' > out || fail=1
@@ -49,7 +37,6 @@ rm: cannot remove `a/b/file'
 rm: cannot remove `a/b/file'
 EOF
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 8728190..12d0731 100755 (executable)
@@ -24,22 +24,11 @@ if test "$VERBOSE" = yes; then
   rm --version
 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
+. $srcdir/../test-lib.sh
+
 ln -s no-file dangle
 ln -s / symlink
 
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
-
 fail=0
 
 rm ---presume-input-tty dangle symlink &
index c9c60eb..a0f72e8 100755 (executable)
@@ -1,8 +1,7 @@
 #!/bin/sh
 # Test "rm" with a deep hierarchy.
 
-# Copyright (C) 1997, 2002, 2003, 2004, 2006 Free Software Foundation,
-# Inc.
+# Copyright (C) 1997, 2002-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
@@ -29,10 +28,7 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
+. $srcdir/../test-lib.sh
 
 umask 022
 
@@ -46,16 +42,17 @@ k200=$k20$k20$k20$k20$k20$k20$k20$k20$k20$k20
 # operates on the full pathname (like `test') would choke.
 k_deep=$k200$k200
 
-# Create a directory in $tmp with lots of `k' components.
-deep=$tmp$k_deep
+t=t
+# Create a directory in $t with lots of `k' components.
+deep=$t$k_deep
 mkdir -p $deep || fail=1
 
 # Make sure the deep dir was created.
 test -d $deep || fail=1
 
-rm -r $tmp || fail=1
+rm -r $t || fail=1
 
-# Make sure all of $tmp was deleted.
-test -d $tmp && fail=1
+# Make sure all of $t was deleted.
+test -d $t && fail=1
 
 (exit $fail); exit $fail
index c2fbf5b..2ed6926 100755 (executable)
@@ -2,7 +2,7 @@
 # rm (without -r) must give a diagnostic for any directory.
 # It must not prompt, even if that directory is unwritable.
 
-# Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2005, 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,23 +22,10 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
+. $srcdir/../test-lib.sh
 
-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
-mkdir --mode=0500 unwritable-dir || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir --mode=0500 unwritable-dir || framework_failure
 
 fail=0
 
@@ -56,7 +43,6 @@ EOF
 sed 's/remove directory/remove/' out-t > out
 rm -f out-t
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 92ab1d4..b912e63 100755 (executable)
@@ -2,7 +2,7 @@
 # Ensure that `rm dir' (i.e., without --recursive) gives a reasonable
 # diagnostic when failing.
 
-# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2005, 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
@@ -23,21 +23,9 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
+. $srcdir/../test-lib.sh
 
-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
-mkdir d || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir d || framework_failure
 
 fail=0
 
@@ -47,7 +35,6 @@ rm: cannot remove `d': Is a directory
 EOF
 
 # Before coreutils-5.93 this test would fail on Solaris 9 and newer.
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index cb16b1a..f31e6f0 100755 (executable)
@@ -22,22 +22,10 @@ if test "$VERBOSE" = yes; then
   rm --version
 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
+. $srcdir/../test-lib.sh
 
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-mkdir a b || framework_failure=1
-touch a/f b/f || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir a b || framework_failure
+touch a/f b/f || framework_failure
 
 fail=0
 
index a92b528..32772e7 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Ensure that rm -rf removes an empty-and-inaccessible directory.
 
-# 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
@@ -21,27 +21,15 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+skip_if_root_
 
-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
-mkdir -m0 inacc || framework_failure=1
+mkdir -m0 inacc || framework_failure
 
 # Also exercise the different code path that's taken for a directory
 # that is empty (hence removable) and unreadable.
 mkdir -m a-r -p a/unreadable
 
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
-
 fail=0
 
 # This would fail for e.g., coreutils-5.93.
index 7fce0bb..750d660 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test "rm -f" with a nonexistent file.
 
-# Copyright (C) 1997, 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1997, 2002, 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
@@ -23,20 +23,11 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
+. $srcdir/../test-lib.sh
 
-test_failure=0
-mkdir -p $tmp || test_failure=1
-
-if test $test_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+mkdir -p d || framework_failure
 
 fail=0
-rm -f $tmp/no-such-file || fail=1
+rm -f d/no-such-file || fail=1
 
 (exit $fail); exit $fail
index ed43807..bafd5bf 100755 (executable)
@@ -24,27 +24,14 @@ fi
 
 . $srcdir/../lang-default
 PRIV_CHECK_ARG=require-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
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+. $srcdir/../test-lib.sh
 
 # The containing directory must be owned by the user who eventually runs rm.
 chown $NON_ROOT_USERNAME .
 
-mkdir a || framework_failure=1
-chmod 1777 a || framework_failure=1
-touch a/b || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir a || framework_failure
+chmod 1777 a || framework_failure
+touch a/b || framework_failure
 
 fail=0
 
@@ -53,7 +40,7 @@ fail=0
 rm_version=`setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm --version|sed -n '1s/.* //p'`
 case $rm_version in
   $PACKAGE_VERSION) ;;
-  *) echo "$0: cannot access required version ($PACKAGE_VERSION) of rm" 1>&2
+  *) echo "$0: cannot access just-built rm as user $NON_ROOT_USERNAME" 1>&2
      fail=1 ;;
 esac
 setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm -rf a 2> out-t && fail=1
@@ -67,7 +54,6 @@ cat <<\EOF > exp
 rm: cannot remove `a/b': Operation not permitted
 EOF
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 3293ad5..b15c2f5 100755 (executable)
@@ -22,22 +22,10 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+skip_if_root_
 
-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
-mkdir d && touch d/f && chmod a-w d || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir d && touch d/f && chmod a-w d || framework_failure
 
 fail=0
 
@@ -46,7 +34,6 @@ cat <<\EOF > exp
 rm: cannot remove `d/f': Permission denied
 EOF
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 40c238f..0261eef 100755 (executable)
@@ -3,7 +3,7 @@
 # Before then, rm would fail occasionally, sometimes via
 # a failed assertion, others with a seg fault.
 
-# Copyright (C) 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2002, 2003, 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,29 +25,17 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && rm -rf $t0 || exit $?; exit $status' 0
-trap 'exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp
+. $srcdir/../test-lib.sh
 
 # Create a hierarchy with 3*26 leaf directories, each at depth 153.
 echo "$0: creating 78 trees, each of depth 153; this will take a while..." >&2
 y=`seq 1 150|tr -sc '\n' y|tr '\n' /`
 for i in 1 2 3; do
   for j in a b c d e f g h i j k l m n o p q r s t u v w x y z; do
-    mkdir -p t/$i/$j/$y || framework_failure=1
+    mkdir -p t/$i/$j/$y || framework_failure
   done
 done
 
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
-
 fail=0
 
 rm -r t || fail=1
index 14ba0dc..b0d939c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test "rm -i".
 
-# Copyright (C) 1997, 1998, 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1997-1998, 2002, 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
@@ -23,33 +23,25 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
+. $srcdir/../test-lib.sh
 
-test_failure=0
-mkdir -p $tmp || test_failure=1
-echo > $tmp/a || test_failure=1
-test -f $tmp/a || test_failure=1
+t=t
+mkdir -p $t || framework_failure
+echo > $t/a || framework_failure
+test -f $t/a || framework_failure
 
-if test $test_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
-
-echo y > $tmp/$test.Iy
-echo n > $tmp/$test.In
+echo y > $t/$test.Iy
+echo n > $t/$test.In
 
 fail=0
-rm -i $tmp/a < $tmp/$test.In > /dev/null 2>&1 || fail=1
+rm -i $t/a < $t/$test.In > /dev/null 2>&1 || fail=1
 # The file should not have been removed.
-test -f $tmp/a || fail=1
+test -f $t/a || fail=1
 
-rm -i $tmp/a < $tmp/$test.Iy > /dev/null 2>&1 || fail=1
+rm -i $t/a < $t/$test.Iy > /dev/null 2>&1 || fail=1
 # The file should have been removed this time.
-test -f $tmp/a && fail=1
+test -f $t/a && fail=1
 
-rm -rf $tmp
+rm -rf $t
 
 (exit $fail); exit $fail
index c70e3ea..16edcf6 100755 (executable)
@@ -22,30 +22,17 @@ if test "$VERBOSE" = yes; then
   rm --version
 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
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-touch f || framework_failure=1
-chmod 0 f || framework_failure=1
-touch exp || 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
+skip_if_root_
+
+touch f || framework_failure
+chmod 0 f || framework_failure
+touch exp || framework_failure
 
 fail=0
 
 rm --interactive=never f > out || fail=1
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 9362aed..0c2e898 100755 (executable)
@@ -23,21 +23,10 @@ if test "$VERBOSE" = yes; then
   rm --version
 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
-mkdir dir || framework_failure=1
-echo y > y || 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
+
+mkdir dir || framework_failure
+echo y > y || framework_failure
 
 fail=0
 
index 142af2f..a3fe1dc 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Ensure that rm -f existing-non-dir/anything exits successfully
 
-# 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
@@ -21,22 +21,10 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+skip_if_root_
 
-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
-touch existing-non-dir || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+touch existing-non-dir || framework_failure
 
 fail=0
 
index 0d6e539..8d05b3e 100755 (executable)
@@ -2,7 +2,7 @@
 # Ensure that rm works even when run from a directory
 # for which the user has no access at all.
 
-# 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,7 +22,6 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../lang-default
 
 # Skip this test if your system has neither the openat-style functions
@@ -35,24 +34,14 @@ if test $skip = yes; 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
+. $srcdir/../test-lib.sh
+skip_if_root_
 
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-mkdir abs1 abs2 no-access || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+p=`pwd`
+mkdir abs1 abs2 no-access || framework_failure
 
 fail=0
 
-p=$pwd/$tmp
 set +x
 (cd no-access; chmod 0 . && rm -r "$p/abs1" rel "$p/abs2") 2> out && fail=1
 test -d "$p/abs1" && fail=1
@@ -68,7 +57,6 @@ EOF
 # to the expected one:
 sed 's/: The file access permissions.*/: Permission denied/'<out>o1;mv o1 out
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 686ac2f..f085ec1 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test the --interactive[=WHEN] changes added to coreutils 6.0
 
-# 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
@@ -24,27 +24,14 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-
-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
+. $srcdir/../test-lib.sh
 
 touch file1-1 file1-2 file2-1 file2-2 file3-1 file3-2 file4-1 file4-2 \
-  || framework_failure=1
+  || framework_failure
 # If asked, answer no to first question, then yes to second.
 echo 'n
-y' > $test.I || framework_failure=1
-rm -f out err || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+y' > $test.I || framework_failure
+rm -f out err || framework_failure
 
 fail=0
 
@@ -102,10 +89,7 @@ rm: remove regular empty file `file4-1'? rm: remove regular empty file `file4-2'
 rm: remove all arguments recursively? .
 EOF
 
-cmp out expout || fail=1
-cmp err experr || fail=1
-test $fail = 1 && {
-  diff out expout 2> /dev/null; diff err experr 2> /dev/null
-}
+compare out expout || fail=1
+compare err experr || fail=1
 
 (exit $fail); exit $fail
index cd3c2b2..e09db7c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test the -I option added to coreutils 6.0
 
-# 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
@@ -24,27 +24,14 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
+. $srcdir/../test-lib.sh
 
-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
-
-mkdir -p dir1-1 dir2-1 dir2-2 || framework_failure=1
+mkdir -p dir1-1 dir2-1 dir2-2 || framework_failure
 touch file1-1 file2-1 file2-2 file2-3 file3-1 file3-2 file3-3 file3-4 \
-  || framework_failure=1
-echo y > $test.Iy || framework_failure=1
-echo n > $test.In || framework_failure=1
-rm -f out err || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+  || framework_failure
+echo y > $test.Iy || framework_failure
+echo n > $test.In || framework_failure
+rm -f out err || framework_failure
 
 fail=0
 
@@ -122,10 +109,7 @@ multiple files, recursion, answer yes
 rm: remove all arguments recursively? .
 EOF
 
-cmp out expout || fail=1
-cmp err experr || fail=1
-test $fail = 1 && {
-  diff out expout 2> /dev/null; diff err experr 2> /dev/null
-}
+compare out expout || fail=1
+compare err experr || fail=1
 
 (exit $fail); exit $fail
index 6bd278d..c3af0ac 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test "rm -ir".
 
-# Copyright (C) 1997, 1998, 2002, 2004, 2006 Free Software Foundation,
+# Copyright (C) 1997, 1998, 2002, 2004, 2006, 2007 Free Software Foundation,
 # Inc.
 
 # This program is free software: you can redistribute it and/or modify
@@ -24,21 +24,13 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
+. $srcdir/../test-lib.sh
 
-test_failure=0
-mkdir -p $tmp $tmp/a $tmp/b $tmp/c || test_failure=1
-> $tmp/a/a || test_failure=1
-> $tmp/b/bb || test_failure=1
-> $tmp/c/cc || test_failure=1
-
-if test $test_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+t=t
+mkdir -p $t $t/a $t/b $t/c || framework_failure
+> $t/a/a || framework_failure
+> $t/b/bb || framework_failure
+> $t/c/cc || framework_failure
 
 cat <<EOF > $test.I
 y
@@ -58,17 +50,15 @@ EOF
 # determine which one was removed based on order of dir entries.
 # This is a good argument for switching to a dejagnu-style test suite.
 fail=0
-rm --verbose -i -r $tmp < $test.I > /dev/null 2>&1 || fail=1
+rm --verbose -i -r $t < $test.I > /dev/null 2>&1 || fail=1
 
-# $tmp should not have been removed.
-test -d $tmp || fail=1
+# $t should not have been removed.
+test -d $t || fail=1
 
 # There should be only one directory left.
-case `echo $tmp/*` in
-  $tmp/[abc]) ;;
+case `echo $t/*` in
+  $t/[abc]) ;;
   *) fail=1 ;;
 esac
 
-rm -rf $tmp $test.I
-
 (exit $fail); exit $fail
index 6c26c11..cb3f0fd 100755 (executable)
@@ -1,8 +1,7 @@
 #!/bin/sh
 # Make sure `chown 0 f; rm f' prompts before removing f.
 
-# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
-# Inc.
+# Copyright (C) 2001-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,21 +22,8 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
-
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
+. $srcdir/../test-lib.sh
+skip_if_root_
 
 fail=0
 
@@ -69,7 +55,6 @@ EOF
 # Append an `x' and a newline.
 echo x >> out
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index e112ff7..14d2a46 100755 (executable)
@@ -23,26 +23,14 @@ if test "$VERBOSE" = yes; then
 fi
 
 PRIV_CHECK_ARG=require-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
 
-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
-mkdir d || framework_failure=1
-touch d/f || framework_failure=1
-chown -R $NON_ROOT_USERNAME d || framework_failure=1
+mkdir d || framework_failure
+touch d/f || framework_failure
+chown -R $NON_ROOT_USERNAME d || framework_failure
 
 # Ensure that non-root can access files in root-owned ".".
-chmod go=x . || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+chmod go=x . || framework_failure
 
 fail=0
 
index 9d71a21..471216c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Demonstrate rm's new --one-file-system option.
 
-# 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
@@ -23,43 +23,26 @@ fi
 
 PRIV_CHECK_ARG=require-root . $srcdir/../priv-check
 . $srcdir/../lang-default
-. $srcdir/../other-fs-tmpdir
+. $srcdir/../test-lib.sh
 
-if test -z "$other_partition_tmpdir"; 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
-
-t0="$t0 $other_partition_tmpdir"
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+# If used, these must *follow* test-lib.sh.
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
 
 t=$other_partition_tmpdir
 mkdir -p a/b $t/y
-mount --bind $t a/b || framework_failure=1
+mount --bind $t a/b || framework_failure
 
-cat <<\EOF > exp || framework_failure=1
+cat <<\EOF > exp || framework_failure
 rm: skipping `a/b', since it's on a different device
 EOF
 
-if test $framework_failure = 1; then
-  echo "$0: setup failed; skipping this test" 1>&2
-  (exit 77); exit 77
-fi
-
 fail=0
 
 rm --one-file-system -rf a 2> out && fail=1
 test -d $t/y || fail=1
 umount $t
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 61350bb..5e05d43 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test "rm -r --verbose".
 
-# Copyright (C) 1997, 1998, 2000, 2002, 2004, 2006 Free Software
+# Copyright (C) 1997, 1998, 2000, 2002, 2004, 2006, 2007 Free Software
 # Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
@@ -25,30 +25,17 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
+mkdir a a/a || framework_failure
+> b || framework_failure
 
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-mkdir a a/a || framework_failure=1
-> b || framework_failure=1
-
-cat <<\EOF > $test.E || framework_failure=1
+cat <<\EOF > $test.E || framework_failure
 removed directory: `a/a'
 removed directory: `a'
 removed `b'
 EOF
 
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
-
 fail=0
 rm --verbose -r a b > $test.O || fail=1
 
@@ -59,7 +46,6 @@ for d in $dirs; do
 done
 
 # Compare expected and actual output.
-cmp $test.E $test.O || fail=1
-test $fail = 1 && diff $test.E $test.O 2> /dev/null
+compare $test.E $test.O || fail=1
 
 (exit $fail); exit $fail
index d4ad64e..0e381ad 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test "rm -r --verbose".
 
-# Copyright (C) 1997, 1998, 2000, 2002, 2004, 2006 Free Software
+# Copyright (C) 1997, 1998, 2000, 2002, 2004, 2006, 2007 Free Software
 # Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 if test "$VERBOSE" = yes; then
-  rm --version
   set -x
+  rm --version
 fi
 
 . $srcdir/../lang-default
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && rm -rf $t0 || exit $?; exit $status' 0
-trap 'exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp
-
-mkdir t t/a t/a/b || framework_failure=1
-> t/a/f || framework_failure=1
-> t/a/b/g || framework_failure=1
+mkdir t t/a t/a/b || framework_failure
+> t/a/f || framework_failure
+> t/a/b/g || framework_failure
 
 # FIXME: if this fails, it's a framework failure
-cat <<\EOF | sort > t/E || framework_failure=1
+cat <<\EOF | sort > t/E || framework_failure
 removed directory: `t/a'
 removed directory: `t/a/b'
 removed `t/a/b/g'
 removed `t/a/f'
 EOF
 
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
-
 # Note that both the expected output (above) and the actual output lines
 # are sorted, because directory entries may be processed in arbitrary order.
 fail=0
@@ -61,6 +48,5 @@ fi
 
 # Compare expected and actual output.
 cmp t/E t/O || fail=1
-test $fail = 1 && diff t/E t/O 2> /dev/null
 
 (exit $fail); exit $fail
index feca33a..485832d 100755 (executable)
@@ -1,8 +1,7 @@
 #!/bin/sh
 # Create and remove a directory with more than 254 files.
 
-# Copyright (C) 1997, 2001, 2002, 2003, 2004, 2006 Free Software Foundation,
-# Inc.
+# Copyright (C) 1997, 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
 # are 338 or more files in a directory on a Darwin-6.5 system
 
 if test "$VERBOSE" = yes; then
-  rm --version
   set -x
+  rm --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
+. $srcdir/../test-lib.sh
 
-framework_fail=0
-mkdir -p $tmp || framework_fail=1
-cd $tmp || framework_fail=1
+mkdir t || framework_failure
+cd t || framework_failure
 
 # Create 500 files (20 * 25).
 for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j; do
@@ -44,20 +39,15 @@ for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j; do
   for j in a b c d e f g h i j k l m n o p q r s t u v w x y; do
     files="$files $i$j"
   done
-  touch $files || framework_fail=1
+  touch $files || framework_failure
 done
 
-test -f 0a || framework_fail=1
-test -f by || framework_fail=1
-cd "$pwd" || framework_fail=1
-
-if test $framework_fail = 1; then
-  echo 'failure in testing framework'
-  (exit 1); exit 1
-fi
+test -f 0a || framework_failure
+test -f by || framework_failure
+cd .. || framework_failure
 
 fail=0
-rm -rf $tmp || fail=1
-test -d $tmp && fail=1
+rm -rf t || fail=1
+test -d t && fail=1
 
 (exit $fail); exit $fail
index b7a1fd2..8320542 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Try to remove '.' and '..' recursively.
 
-# 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
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-
 if test "$VERBOSE" = yes; then
-  rm --version
   set -x
+  rm --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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
-
-touch a || framework_failure=1
-cd "$pwd" || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  (exit 1); exit 1
-fi
+mkdir d || framework_failure
+touch d/a || framework_failure
 
 fail=0
-rm -fr $tmp/. 2>/dev/null && fail=1
-rm -fr $tmp/./ 2>/dev/null && fail=1
-rm -fr $tmp/.//// 2>/dev/null && fail=1
-rm -fr $tmp/.. 2>/dev/null && fail=1
-rm -fr $tmp/../ 2>/dev/null && fail=1
+rm -fr d/. 2>/dev/null && fail=1
+rm -fr d/./ 2>/dev/null && fail=1
+rm -fr d/.//// 2>/dev/null && fail=1
+rm -fr d/.. 2>/dev/null && fail=1
+rm -fr d/../ 2>/dev/null && fail=1
 
 # This test is too dangerous -- if there's a bug you're wiped out!
 # rm -fr / 2>/dev/null && fail=1
 
-test -f $tmp/a || fail=1
+test -f d/a || fail=1
 
 (exit $fail); exit $fail
index b9e90b4..6386b75 100755 (executable)
@@ -22,30 +22,18 @@ if test "$VERBOSE" = yes; then
   rm --version
 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
+. $srcdir/../test-lib.sh
 
 # Create a directory containing many files.
 # What counts is a combination of the number of files and
 # the lengths of their names.  For details, see
 # http://lists.gnu.org/archive/html/bug-coreutils/2006-09/msg00326.html
-mkdir b || framework_failure=1
-cd b || framework_failure=1
+mkdir b || framework_failure
+cd b || framework_failure
 for i in `seq 1 250`; do
-  touch `printf %040d $i` || framework_failure=1
+  touch `printf %040d $i` || framework_failure
 done
-cd .. || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+cd .. || framework_failure
 
 fail=0
 
index 1f062a6..3770563 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # exercise another small part of remove.c
 
-# Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002, 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
@@ -21,25 +21,12 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+skip_if_root_
 
-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
-mkdir -p b/a/p b/c b/d || framework_failure=1
-chmod u-w b/a || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir -p b/a/p b/c b/d || framework_failure
+chmod u-w b/a || framework_failure
 
 fail=0
 
index 3798856..2524db0 100755 (executable)
@@ -1,8 +1,7 @@
 #!/bin/sh
 # exercise another small part of remove.c
 
-# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
-# Inc.
+# Copyright (C) 2002-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,27 +21,14 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+skip_if_root_
 
-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
-mkdir -p a/0 || framework_failure=1
-mkdir -p a/1/2 b/3 || framework_failure=1
-mkdir a/2 a/3 || framework_failure=1
-chmod u-x a/1 b || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir -p a/0 || framework_failure
+mkdir -p a/1/2 b/3 || framework_failure
+mkdir a/2 a/3 || framework_failure
+chmod u-x a/1 b || framework_failure
 
 fail=0
 
@@ -60,7 +46,8 @@ rm: cannot remove `a/1/2': Permission denied
 rm: cannot remove `b/3': Permission denied
 EOF
 
-cmp out exp > /dev/null 2>&1 || { cmp out exp-solaris > /dev/null 2>&1 || fail=1; }
+cmp out exp > /dev/null 2>&1 \
+    || { cmp out exp-solaris > /dev/null 2>&1 || fail=1; }
 test $fail = 1 && diff out exp 2> /dev/null
 
 test -d a/0 && fail=1
index 9ec07e4..cfa1b02 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # exercise another small part of remove.c
 
-# Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 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
@@ -21,33 +21,20 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+skip_if_root_
 
-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
-mkdir -p z || framework_failure=1
-cd z || framework_failure=1
-touch empty empty-u || framework_failure=1
+mkdir -p z || framework_failure
+cd z || framework_failure
+touch empty empty-u || framework_failure
 echo not-empty > fu
 ln -s empty-f slink
 ln -s . slinkdot
-mkdir d du || framework_failure=1
-chmod u-w fu du empty-u || framework_failure=1
+mkdir d du || framework_failure
+chmod u-w fu du empty-u || framework_failure
 cd ..
 
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
-
 fail=0
 
 cat <<EOF > in
@@ -85,8 +72,7 @@ rm: remove write-protected directory \`z/du'
 rm: remove directory \`z'
 EOF
 
-cmp out exp || fail=1
-test $fail = 1 && diff -u out exp 2> /dev/null
+compare out exp || fail=1
 
 test -d z && fail=1
 
index 25a5c7b..c158e69 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # ensure that `rm dir' fails without --recursive
 
-# Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002, 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
@@ -21,24 +21,11 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+skip_if_root_
 
-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
-mkdir dir || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir dir || framework_failure
 
 fail=0
 
index d7d72f4..c324323 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # a basic test of rm -ri
 
-# Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002-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
@@ -21,36 +21,23 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+skip_if_root_
 
-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
-mkdir -p d/e || framework_failure=1
-cat <<EOF > in || framework_failure=1
+mkdir -p d/e || framework_failure
+cat <<EOF > in || framework_failure
 y
 y
 y
 EOF
 
-cat <<\EOF > exp || framework_failure=1
+cat <<\EOF > exp || framework_failure
 rm: descend into directory `d'
 rm: remove directory `d/e'
 rm: remove directory `d'
 EOF
 
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
-
 fail=0
 
 rm -ir d < in > out 2>&1 || fail=1
@@ -66,7 +53,6 @@ mv o2 out
 # Make sure it's been removed.
 test -d d && fail=1
 
-cmp out exp || fail=1
-test $fail = 1 && diff -u out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index b1d2a69..a0e4312 100755 (executable)
@@ -26,19 +26,7 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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
 rm -r '' > /dev/null 2>&1 && fail=1
index 7ba6351..966bfa1 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # exercise one small part of remove.c
 
-# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004, 2005, 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
@@ -21,26 +21,13 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+skip_if_root_
 
-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
-mkdir -p a/b || framework_failure=1
+mkdir -p a/b || framework_failure
 chmod u-r a
 
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
-
 fail=0
 
 # This should fail.
@@ -49,7 +36,6 @@ cat <<\EOF > exp
 rm: cannot remove `a': Permission denied
 EOF
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 6fb13d9..71089f5 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Ensure that rm works even from an unreadable working directory.
 
-# 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
@@ -21,28 +21,16 @@ if test "$VERBOSE" = yes; then
   rm --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+skip_if_root_
 
-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
-mkdir -p a/1 b c d/2 e/3 || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir -p a/1 b c d/2 e/3 || framework_failure
 
 fail=0
 
+t=`pwd`
 cd c
 chmod u=x,go= .
-t=$pwd/$tmp
 
 # With coreutils-5.2.1, this would get a failed assertion.
 rm -r "$t/a" "$t/b" || fail=1
index ad20d51..7e1fb3d 100755 (executable)
@@ -21,21 +21,10 @@ if test "$VERBOSE" = yes; then
   rm --version
 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
-mkdir a || framework_failure=1
-touch a/x || 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
+
+mkdir a || framework_failure
+touch a/x || framework_failure
 
 fail=0
 
@@ -45,7 +34,6 @@ removed `a/x'
 removed directory: `a'
 EOF
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index eadbaba..54e3051 100644 (file)
@@ -9,3 +9,5 @@ TESTS_ENVIRONMENT = \
   CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
   PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
   PROG=rmdir
+
+include $(top_srcdir)/tests/check.mk
index acc5fe5..51e4cf7 100755 (executable)
@@ -2,7 +2,7 @@
 # For unwritable directory `d', `rmdir -p d d/e/f' would emit
 # diagnostics but would not fail.  Fixed in 5.1.2.
 
-# 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,23 +22,10 @@ if test "$VERBOSE" = yes; then
   rmdir --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
 
-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
-mkdir d d/e d/e/f || framework_failure=1
-chmod a-w d || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir d d/e d/e/f || framework_failure
+chmod a-w d || framework_failure
 
 fail=0
 
index 5b6a6bc..5acc786 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # make sure rmdir's --ignore-fail-on-non-empty option works
 
-# Copyright (C) 1999 Free Software Foundation, Inc.
+# Copyright (C) 1999, 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,23 +21,17 @@ if test "$VERBOSE" = yes; then
   rmdir --version
 fi
 
-tmp=rmdir.$$
-trap "rm -rf $tmp" 0 1 2 3 15
+. $srcdir/../test-lib.sh
 
-test_failure=0
-mkdir -p $tmp/a/b $tmp/x || test_failure=1
-
-if test $test_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  exit 1
-fi
+cwd=`pwd`
+mkdir -p $cwd/a/b $cwd/x || framework_failure
 
 fail=0
-rmdir -p --ignore-fail-on-non-empty $tmp/a/b || fail=1
-# $tmp/x should remain
-test -d $tmp/x || fail=1
-# $tmp/{a,b} should be gone
-test -d $tmp/a && fail=1
-test -d $tmp/a/b && fail=1
+rmdir -p --ignore-fail-on-non-empty $cwd/a/b || fail=1
+# $cwd/x should remain
+test -d $cwd/x || fail=1
+# $cwd/{a,b} should be gone
+test -d $cwd/a && fail=1
+test -d $cwd/a/b && fail=1
 
 exit $fail
index e85cbd0..4453f16 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # make sure rmdir -p works on a directory specified with a trailing slash
 
-# Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+# Copyright (C) 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
@@ -21,20 +21,9 @@ if test "$VERBOSE" = yes; then
   rmdir --version
 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
+. $srcdir/../test-lib.sh
 
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-mkdir dir || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir dir || framework_failure
 
 fail=0
 
index ca94293..e5e54e4 100644 (file)
@@ -24,8 +24,8 @@ fi
 # FIXME: . $srcdir/../envvar-check
 # FIXME: . $srcdir/../lang-default
 # FIXME: PRIV_CHECK_ARG=require-root . $srcdir/../priv-check
-# FIXME: PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 . $srcdir/../test-lib.sh
+# FIXME skip_if_root_
 
 # If used, these must *follow* test-lib.sh.
 # FIXME: cleanup_() { rm -rf "$other_partition_tmpdir"; }
index 10571a1..9d47242 100644 (file)
@@ -8,12 +8,41 @@ if test $? != 11; then
   (exit 77); exit 77
 fi
 
-framework_failure()
+skip_test_()
 {
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
+  echo "$0: skipping test: $@" 1>&2
+  (exit 77); exit 77
+}
+
+uid_is_privileged_()
+{
+  # Make sure id -u succeeds.
+  my_uid=$(id -u) \
+    || { echo "$0: cannot run \`id -u'" 1>&2; return 1; }
+
+  # Make sure it gives valid output.
+  case $my_uid in
+    0) ;;
+    *[!0-9]*)
+      echo "$0: invalid output (\`$my_uid') from \`id -u'" 1>&2
+      return 1 ;;
+    *) return 1 ;;
+  esac
 }
 
+skip_if_()
+{
+  case $1 in
+    root) skip_test_ must be run as root ;;
+    non-root) skip_test_ must be run as non-root ;;
+    *) ;;  # FIXME?
+  esac
+}
+
+skip_if_root_() { uid_is_privileged_ && skip_test_ "must be run as non-root"; }
+error_() { echo "$0: $@" 1>&2; (exit 1); exit 1; }
+framework_failure() { error_ 'failure in testing framework'; }
+
 test_dir_=$(pwd)
 
 this_test_() { echo "./$0" | sed 's,.*/,,'; }
@@ -27,7 +56,7 @@ this_test=$(this_test_)
 cleanup_() { :; }
 
 t_=$($abs_top_srcdir/tests/mkdtemp $test_dir_ cu-$this_test.XXXXXXXXXX) \
-    || error "failed to create temporary directory in $test_dir_"
+    || 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.
@@ -35,7 +64,7 @@ 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_"
+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 "$@"; }
index 013d93f..296faae 100755 (executable)
@@ -38,16 +38,15 @@ fail=0
 
 : ${TOUCH_DIR_LIST=.}
 
-framework_failure=0
 
 for d in $TOUCH_DIR_LIST; do
   rm -rf $d/a $d/b $d/c
-  > $d/a || framework_failure=1
-  test -f $d/a || framework_failure=1
-  > $d/b || framework_failure=1
-  test -f $d/b || framework_failure=1
-  > $d/c || framework_failure=1
-  test -f $d/c || framework_failure=1
+  > $d/a || framework_failure
+  test -f $d/a || framework_failure
+  > $d/b || framework_failure
+  test -f $d/b || framework_failure
+  > $d/c || framework_failure
+  test -f $d/c || framework_failure
 done
 
 echo sleeping for $SLEEP_SECONDS seconds...
index b1abdba..018d191 100755 (executable)
@@ -21,23 +21,14 @@ if test "$VERBOSE" = yes; then
   touch --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
-
 . $srcdir/../test-lib.sh
-
-framework_failure=0
+skip_if_root_
 
 d1=no-$$
 dir=/$d1/such-dir
 # Ensure that $d1 doesn't already exist.
-ls -d $d1 2> /dev/null && framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
+ls -d $d1 2> /dev/null && framework_failure
 
 fail=0
 
index 0e841a0..796d330 100755 (executable)
@@ -23,13 +23,7 @@ fi
 
 . $srcdir/../test-lib.sh
 
-framework_failure=0
-
-tmp=fifo-$$
-rm -rf $tmp
-mkfifo $tmp || framework_failure=1
-
-if test $framework_failure = 1; then
+if ! mkfifo fifo; then
   # Make an exception of this case -- usually we interpret framework-creation
   # failure as a test failure.  However, in this case, when running on a SunOS
   # system using a disk NFS mounted from OpenBSD, the above fails like this:
@@ -42,6 +36,6 @@ fi
 
 fail=0
 
-touch $tmp || fail=1
+touch fifo || fail=1
 
 exit $fail
index 72c3caa..7fe9d29 100755 (executable)
@@ -25,17 +25,11 @@ fi
 . $srcdir/../test-lib.sh
 
 # 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
+touch -d '2000-01-01 00:00' t1 || framework_failure
+touch -d '2000-01-02 00:00' t2 || framework_failure
 
-framework_failure=0
 set x `ls -t t1 t2`
-test "$*" = "x t2 t1" || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+test "$*" = "x t2 t1" || framework_failure
 
 fail=0
 
index a7496a0..9abb36b 100755 (executable)
@@ -23,7 +23,6 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 
 test=../../src/test
 if $test -w /; then
@@ -37,6 +36,7 @@ if $test -O / || $test -G /; then
 fi
 
 . $srcdir/../test-lib.sh
+skip_if_root_
 
 fail=0
 
index 771eca4..e1389c2 100755 (executable)
@@ -21,18 +21,11 @@ if test "$VERBOSE" = yes; then
   touch --version
 fi
 
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
-
 . $srcdir/../test-lib.sh
+skip_if_root_
 
-framework_failure=0
-: > read-only || framework_failure=1
-chmod 444 read-only || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+: > read-only || framework_failure
+chmod 444 read-only || framework_failure
 
 fail=0
 
index 02dfe9c..910a378 100755 (executable)
@@ -24,13 +24,7 @@ fi
 
 . $srcdir/../test-lib.sh
 
-framework_failure=0
-TZ=UTC0 touch --date='2004-01-16 12:00 +0000' f || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+TZ=UTC0 touch --date='2004-01-16 12:00 +0000' f || framework_failure
 
 fail=0