news: update w.r.t. recent depcomp changes
[automake.git] / t / uninstall-fail.sh
blob6c0c57ce9ed96c8f1eb122406a1bf46d265948b8
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # "make uninstall" complains and errors out on failures.
19 # FIXME: this test only deal with DATA primary; maybe we need sister
20 # tests for other primaries too? E.g., SCRIPTS, PROGRAMS, LISP, PYTHON,
21 # etc...
23 . test-init.sh
25 mkdir d
26 : > d/f
27 chmod a-w d || skip "cannot make directories unwritable"
29 # On Solaris 10, if '/bin/rm' is run with the '-f' option, it doesn't
30 # print any error message when failing to remove a file (due to e.g.,
31 # "Permission denied"). And it gets weirder. On OpenIndiana 11, the
32 # /bin/sh shell (in many respects a decent POSIX shell) seems to somehow
33 # "eat" the error message from 'rm' in some situation, although the 'rm'
34 # utility itself correctly prints it when invoked from (say) 'env' or
35 # 'bash'. Yikes.
36 # We'll cater to these incompatibilities by relaxing a test below if
37 # a faulty shell or 'rm' program is detected.
38 st=0; $SHELL -c 'rm -f d/f' 2>stderr || st=$?
39 cat stderr >&2
40 test $st -gt 0 || skip_ "can delete files from unwritable directories"
41 if grep 'rm:' stderr; then
42 rm_f_is_silent_on_error=no
43 else
44 rm_f_is_silent_on_error=yes
47 cat >> configure.ac << 'END'
48 AC_OUTPUT
49 END
51 cat > Makefile.am << 'END'
52 data_DATA = foobar.txt
53 END
55 : > foobar.txt
57 $ACLOCAL
58 $AUTOMAKE
59 $AUTOCONF
61 # Weird name, to make it harder to experience false positives when
62 # grepping error messages.
63 inst=__inst-dir__
65 ./configure --prefix="$(pwd)/$inst"
67 mkdir $inst $inst/share
68 : > $inst/share/foobar.txt
70 chmod a-w $inst/share
71 $MAKE uninstall >output 2>&1 && { cat output; exit 1; }
72 cat output
73 if test $rm_f_is_silent_on_error = yes; then
74 : "rm -f" is silent on errors, skip the grepping of make output
75 else
76 grep "rm: .*foobar\.txt" output
79 chmod a-rwx $inst/share
80 (cd $inst/share) && skip_ "cannot make directories fully unreadable"
82 $MAKE uninstall >output 2>&1 && { cat output; exit 1; }
83 cat output
85 # Some shells, like Solaris 10 /bin/ksh and /usr/xpg4/bin/sh, do not
86 # report the name of the 'cd' builtin upon a chdir error:
88 # $ /bin/ksh -c 'cd /none'
89 # /bin/ksh: /none: not found
91 # and also print a line number in the error message *if the command
92 # contains newlines*:
94 # $ /bin/ksh -c 'cd unreadable'
95 # /bin/ksh: unreadable: permission denied
96 # $ /bin/ksh -c '\
97 # > \
98 # > cd unreadable'
99 # /bin/ksh[3]: unreadable: permission denied
101 $EGREP "(cd|sh)(\[[0-9]*[0-9]\])?: .*$inst/share" output