tests: factor 350 fail=0 initializations into test-lib.sh
[platform/upstream/coreutils.git] / tests / rm / fail-eacces
1 #!/bin/sh
2 # Ensure that rm -rf unremovable-non-dir gives a diagnostic.
3 # Test both a regular file and a symlink -- it makes a difference to rm.
4 # With the symlink, rm from coreutils-6.9 would fail with a misleading
5 # ELOOP diagnostic.
6
7 # Copyright (C) 2006-2009 Free Software Foundation, Inc.
8
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
22 if test "$VERBOSE" = yes; then
23   set -x
24   rm --version
25 fi
26
27 . $srcdir/test-lib.sh
28 skip_if_root_
29
30 ok=0
31 mkdir d           &&
32   touch d/f       &&
33   ln -s f d/slink &&
34   chmod a-w d     &&
35   ok=1
36 test $ok = 1 || framework_failure
37
38 mkdir e           &&
39   ln -s f e/slink &&
40   chmod a-w e     &&
41   ok=1
42 test $ok = 1 || framework_failure
43
44
45 rm -rf d/f 2> out && fail=1
46 cat <<\EOF > exp
47 rm: cannot remove `d/f': Permission denied
48 EOF
49 compare out exp || fail=1
50
51 # This used to fail with ELOOP.
52 rm -rf e 2> out && fail=1
53 cat <<\EOF > exp
54 rm: cannot remove `e/slink': Permission denied
55 EOF
56 compare out exp || fail=1
57
58 Exit $fail