diff options
Diffstat (limited to 'tests/rm')
37 files changed, 222 insertions, 665 deletions
diff --git a/tests/rm/Makefile.am b/tests/rm/Makefile.am index 2246ecd6f..21d3f4db2 100644 --- a/tests/rm/Makefile.am +++ b/tests/rm/Makefile.am @@ -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 diff --git a/tests/rm/cycle b/tests/rm/cycle index b6e3576fd..9f7bfcc79 100755 --- a/tests/rm/cycle +++ b/tests/rm/cycle @@ -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 diff --git a/tests/rm/dangling-symlink b/tests/rm/dangling-symlink index 872819048..12d07312a 100755 --- a/tests/rm/dangling-symlink +++ b/tests/rm/dangling-symlink @@ -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 & diff --git a/tests/rm/deep-1 b/tests/rm/deep-1 index c9c60eb22..a0f72e82c 100755 --- a/tests/rm/deep-1 +++ b/tests/rm/deep-1 @@ -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 diff --git a/tests/rm/dir-no-w b/tests/rm/dir-no-w index c2fbf5bbb..2ed6926bf 100755 --- a/tests/rm/dir-no-w +++ b/tests/rm/dir-no-w @@ -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 diff --git a/tests/rm/dir-nonrecur b/tests/rm/dir-nonrecur index 92ab1d495..b912e6362 100755 --- a/tests/rm/dir-nonrecur +++ b/tests/rm/dir-nonrecur @@ -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 diff --git a/tests/rm/dot-rel b/tests/rm/dot-rel index cb16b1af9..f31e6f04c 100755 --- a/tests/rm/dot-rel +++ b/tests/rm/dot-rel @@ -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 diff --git a/tests/rm/empty-inacc b/tests/rm/empty-inacc index a92b52849..32772e755 100755 --- a/tests/rm/empty-inacc +++ b/tests/rm/empty-inacc @@ -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. diff --git a/tests/rm/f-1 b/tests/rm/f-1 index 7fce0bb8c..750d66038 100755 --- a/tests/rm/f-1 +++ b/tests/rm/f-1 @@ -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 diff --git a/tests/rm/fail-2eperm b/tests/rm/fail-2eperm index ed43807c9..bafd5bfcc 100755 --- a/tests/rm/fail-2eperm +++ b/tests/rm/fail-2eperm @@ -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 diff --git a/tests/rm/fail-eacces b/tests/rm/fail-eacces index 3293ad550..b15c2f544 100755 --- a/tests/rm/fail-eacces +++ b/tests/rm/fail-eacces @@ -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 diff --git a/tests/rm/hash b/tests/rm/hash index 40c238ff9..0261eef2c 100755 --- a/tests/rm/hash +++ b/tests/rm/hash @@ -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 diff --git a/tests/rm/i-1 b/tests/rm/i-1 index 14ba0dc38..b0d939c2a 100755 --- a/tests/rm/i-1 +++ b/tests/rm/i-1 @@ -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 diff --git a/tests/rm/i-never b/tests/rm/i-never index c70e3eadf..16edcf6f7 100755 --- a/tests/rm/i-never +++ b/tests/rm/i-never @@ -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 diff --git a/tests/rm/i-no-r b/tests/rm/i-no-r index 9362aed62..0c2e898d2 100755 --- a/tests/rm/i-no-r +++ b/tests/rm/i-no-r @@ -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 diff --git a/tests/rm/ignorable b/tests/rm/ignorable index 142af2f94..a3fe1dcaf 100755 --- a/tests/rm/ignorable +++ b/tests/rm/ignorable @@ -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 diff --git a/tests/rm/inaccessible b/tests/rm/inaccessible index 0d6e5399e..8d05b3ede 100755 --- a/tests/rm/inaccessible +++ b/tests/rm/inaccessible @@ -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 diff --git a/tests/rm/interactive-always b/tests/rm/interactive-always index 686ac2feb..f085ec169 100755 --- a/tests/rm/interactive-always +++ b/tests/rm/interactive-always @@ -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 diff --git a/tests/rm/interactive-once b/tests/rm/interactive-once index cd3c2b234..e09db7c12 100755 --- a/tests/rm/interactive-once +++ b/tests/rm/interactive-once @@ -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 diff --git a/tests/rm/ir-1 b/tests/rm/ir-1 index 6bd278d47..c3af0acc1 100755 --- a/tests/rm/ir-1 +++ b/tests/rm/ir-1 @@ -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 diff --git a/tests/rm/isatty b/tests/rm/isatty index 6c26c118c..cb3f0fd2b 100755 --- a/tests/rm/isatty +++ b/tests/rm/isatty @@ -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 diff --git a/tests/rm/no-give-up b/tests/rm/no-give-up index e112ff705..14d2a4694 100755 --- a/tests/rm/no-give-up +++ b/tests/rm/no-give-up @@ -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 diff --git a/tests/rm/one-file-system b/tests/rm/one-file-system index 9d71a21c7..471216c2c 100755 --- a/tests/rm/one-file-system +++ b/tests/rm/one-file-system @@ -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 diff --git a/tests/rm/r-1 b/tests/rm/r-1 index 61350bb70..5e05d43ea 100755 --- a/tests/rm/r-1 +++ b/tests/rm/r-1 @@ -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 diff --git a/tests/rm/r-2 b/tests/rm/r-2 index d4ad64e34..0e381ad40 100755 --- a/tests/rm/r-2 +++ b/tests/rm/r-2 @@ -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 @@ -18,38 +18,25 @@ # 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 diff --git a/tests/rm/r-3 b/tests/rm/r-3 index feca33a5c..485832d0b 100755 --- a/tests/rm/r-3 +++ b/tests/rm/r-3 @@ -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 @@ -25,18 +24,14 @@ # 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 diff --git a/tests/rm/r-4 b/tests/rm/r-4 index b7a1fd2f0..8320542f7 100755 --- a/tests/rm/r-4 +++ b/tests/rm/r-4 @@ -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 @@ -16,39 +16,26 @@ # 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 diff --git a/tests/rm/readdir-bug b/tests/rm/readdir-bug index b9e90b4ef..6386b7583 100755 --- a/tests/rm/readdir-bug +++ b/tests/rm/readdir-bug @@ -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 diff --git a/tests/rm/rm1 b/tests/rm/rm1 index 1f062a6d7..37705639d 100755 --- a/tests/rm/rm1 +++ b/tests/rm/rm1 @@ -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 diff --git a/tests/rm/rm2 b/tests/rm/rm2 index 3798856ac..2524db06f 100755 --- a/tests/rm/rm2 +++ b/tests/rm/rm2 @@ -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 diff --git a/tests/rm/rm3 b/tests/rm/rm3 index 9ec07e416..cfa1b02a7 100755 --- a/tests/rm/rm3 +++ b/tests/rm/rm3 @@ -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 diff --git a/tests/rm/rm4 b/tests/rm/rm4 index 25a5c7b52..c158e6905 100755 --- a/tests/rm/rm4 +++ b/tests/rm/rm4 @@ -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 diff --git a/tests/rm/rm5 b/tests/rm/rm5 index d7d72f40f..c3243233e 100755 --- a/tests/rm/rm5 +++ b/tests/rm/rm5 @@ -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 diff --git a/tests/rm/sunos-1 b/tests/rm/sunos-1 index b1d2a6965..a0e431287 100755 --- a/tests/rm/sunos-1 +++ b/tests/rm/sunos-1 @@ -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 diff --git a/tests/rm/unread2 b/tests/rm/unread2 index 7ba63512f..966bfa1b8 100755 --- a/tests/rm/unread2 +++ b/tests/rm/unread2 @@ -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 diff --git a/tests/rm/unread3 b/tests/rm/unread3 index 6fb13d950..71089f5d6 100755 --- a/tests/rm/unread3 +++ b/tests/rm/unread3 @@ -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 diff --git a/tests/rm/v-slash b/tests/rm/v-slash index ad20d5141..7e1fb3d47 100755 --- a/tests/rm/v-slash +++ b/tests/rm/v-slash @@ -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 |