tests: misc/printf: accommodate alternate behavior
[platform/upstream/coreutils.git] / tests / rm / inaccessible
1 #!/bin/sh
2 # Ensure that rm works even when run from a directory
3 # for which the user has no access at all.
4
5 # Copyright (C) 2004, 2006-2011 Free Software Foundation, Inc.
6
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.
11
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.
16
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/>.
19
20 . "${srcdir=.}/init.sh"; path_prepend_ ../src
21 print_ver_ rm
22
23 # Skip this test if your system has neither the openat-style functions
24 # nor /proc/self/fd support with which to emulate them.
25 require_openat_support_
26 skip_if_root_
27
28 p=`pwd`
29 mkdir abs1 abs2 no-access || framework_failure_
30
31
32 set +x
33 (cd no-access; chmod 0 . && rm -r "$p/abs1" rel "$p/abs2") 2> out && fail=1
34 test -d "$p/abs1" && fail=1
35 test -d "$p/abs2" && fail=1
36
37 cat <<\EOF > exp || fail=1
38 rm: cannot remove `rel': Permission denied
39 EOF
40
41 # AIX 4.3.3 fails with a different diagnostic.
42 # Transform their diagnostic
43 #   ...: The file access permissions do not allow the specified action.
44 # to the expected one:
45 sed 's/: The file access permissions.*/: Permission denied/'<out>o1;mv o1 out
46
47 compare out exp || fail=1
48
49 Exit $fail