* gnulib: Update submodule to latest.
[coreutils.git] / tests / rm / inaccessible
blobfc46b021fd683b4a9279074b2852edfab652428b
1 #!/bin/sh
2 # Ensure that rm works even when run from a directory
3 # for which the user has no access at all.
5 # Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if test "$VERBOSE" = yes; then
21 set -x
22 rm --version
25 . $srcdir/test-lib.sh
27 # Skip this test if your system has neither the openat-style functions
28 # nor /proc/self/fd support with which to emulate them.
29 skip=yes
30 grep '^#define HAVE_OPENAT' $CONFIG_HEADER > /dev/null && skip=no
31 test -d /proc/self/fd && skip=no
32 if test $skip = yes; then
33 skip_test_ 'this system lacks openat support'
36 skip_if_root_
38 p=`pwd`
39 mkdir abs1 abs2 no-access || framework_failure
41 fail=0
43 set +x
44 (cd no-access; chmod 0 . && rm -r "$p/abs1" rel "$p/abs2") 2> out && fail=1
45 test -d "$p/abs1" && fail=1
46 test -d "$p/abs2" && fail=1
48 cat <<\EOF > exp || fail=1
49 rm: cannot remove `rel': Permission denied
50 EOF
52 # AIX 4.3.3 fails with a different diagnostic.
53 # Transform their diagnostic
54 # ...: The file access permissions do not allow the specified action.
55 # to the expected one:
56 sed 's/: The file access permissions.*/: Permission denied/'<out>o1;mv o1 out
58 compare out exp || fail=1
60 Exit $fail