. $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
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
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
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
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
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
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
fi
. $srcdir/../test-lib.sh
+skip_if_root_
mkdir -p a/sub || framework_failure
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
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
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
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
pathchk --version
fi
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
. $srcdir/../test-lib.sh
+skip_if_root_
touch file || framework_failure
. $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
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
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
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
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
fi
. $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
. $srcdir/../test-lib.sh
+skip_if_root_
fail=0
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
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
# 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
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
# 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
# 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"
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"
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
# along with this program. If not, see <http://www.gnu.org/licenses/>.
TESTS = \
+ deep-1 \
+ hash \
+ dangling-symlink \
v-slash \
i-never \
fail-eacces \
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)
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
PACKAGE_VERSION=$(PACKAGE_VERSION) \
PROG=rm
+
+include $(top_srcdir)/tests/check.mk
#!/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
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
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
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 &
#!/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
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
# 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
# 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
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
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
# 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
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
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
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
#!/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
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.
#!/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
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
. $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
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
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
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
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
# 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
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
#!/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
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
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
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
#!/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
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
# 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
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
(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
# 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
#!/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
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
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
#!/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
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
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
#!/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
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
# 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
#!/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
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
# 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
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
#!/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
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
#!/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
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
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
#!/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
# 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
#!/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
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
#!/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
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
#!/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
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
#!/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
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
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
#!/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
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
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
#!/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
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
#!/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
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
# 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
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
#!/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
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.
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
#!/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
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
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
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
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
PROG=rmdir
+
+include $(top_srcdir)/tests/check.mk
# 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
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
#!/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
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
#!/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
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
# 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"; }
(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,.*/,,'; }
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.
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 "$@"; }
: ${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...
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
. $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:
fail=0
-touch $tmp || fail=1
+touch fifo || fail=1
exit $fail
. $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
fi
. $srcdir/../lang-default
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
test=../../src/test
if $test -w /; then
fi
. $srcdir/../test-lib.sh
+skip_if_root_
fail=0
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
. $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