*** empty log message ***
[coreutils.git] / tests / rm / rm1
blob998a30673a415679473d19421e010566aacf927d
1 #!/bin/sh
2 # exercise another small part of remove.c
4 if test "$VERBOSE" = yes; then
5 set -x
6 rm --version
7 fi
9 . $srcdir/../envvar-check
10 . $srcdir/../lang-default
11 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
13 pwd=`pwd`
14 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
15 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
16 trap '(exit $?); exit' 1 2 13 15
18 framework_failure=0
19 mkdir -p $tmp || framework_failure=1
20 cd $tmp || framework_failure=1
21 mkdir -p b/a/p b/c b/d || framework_failure=1
22 chmod u-w b/a || framework_failure=1
24 if test $framework_failure = 1; then
25 echo "$0: failure in testing framework" 1>&2
26 (exit 1); exit
29 fail=0
31 # This should fail.
32 rm -rf b > out 2>&1 && fail=1
33 cat <<\EOF > exp
34 rm: cannot remove directory `b/a/p': Permission denied
35 EOF
37 # On some systems, rm doesn't have enough information to
38 # say it's a directory.
39 cat <<\EOF > exp2
40 rm: cannot remove `b/a/p': Permission denied
41 EOF
43 cmp out exp > /dev/null 2>&1 || {
44 cmp out exp2 || fail=1
46 test $fail = 1 && diff out exp 2> /dev/null
48 test -d b/a/p || fail=1
49 test -d b/c && fail=1
50 test -d b/d && fail=1
52 (exit $fail); exit