6c009759fd19f17cbcb9c8bcb1e9abc77cad1a78
[platform/upstream/coreutils.git] / tests / rm / empty-inacc
1 #!/bin/sh
2 # Ensure that rm -rf removes an empty-and-inaccessible directory.
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   rm --version
7 fi
8
9 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
10
11 pwd=`pwd`
12 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
13 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
14 trap '(exit $?); exit $?' 1 2 13 15
15
16 framework_failure=0
17 mkdir -p $tmp || framework_failure=1
18 cd $tmp || framework_failure=1
19 mkdir -m0 inacc || framework_failure=1
20
21 # Also exercise the different code path that's taken for a directory
22 # that is empty (hence removable) and unreadable.
23 mkdir -m a-r -p a/unreadable
24
25 if test $framework_failure = 1; then
26   echo "$0: failure in testing framework" 1>&2
27   (exit 1); exit 1
28 fi
29
30 fail=0
31
32 # This would fail for e.g., coreutils-5.93.
33 rm -rf inacc || fail=1
34 test -d inacc && fail=1
35
36 # This would fail for e.g., coreutils-5.97.
37 rm -rf a || fail=1
38 test -d a && fail=1
39
40 (exit $fail); exit $fail