uninstall-fail.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  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.
  8. #
  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.
  13. #
  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/>.
  16. # "make uninstall" complains and errors out on failures.
  17. # FIXME: this test only deal with DATA primary; maybe we need sister
  18. # tests for other primaries too? E.g., SCRIPTS, PROGRAMS, LISP, PYTHON,
  19. # etc...
  20. . test-init.sh
  21. mkdir d
  22. : > d/f
  23. chmod a-w d || skip "cannot make directories unwritable"
  24. # On Solaris 10, if '/bin/rm' is run with the '-f' option, it doesn't
  25. # print any error message when failing to remove a file (due to e.g.,
  26. # "Permission denied"). And it gets weirder. On OpenIndiana 11, the
  27. # /bin/sh shell (in many respects a decent POSIX shell) seems to somehow
  28. # "eat" the error message from 'rm' in some situation, although the 'rm'
  29. # utility itself correctly prints it when invoked from (say) 'env' or
  30. # 'bash'. Yikes.
  31. # We'll cater to these incompatibilities by relaxing a test below if
  32. # a faulty shell or 'rm' program is detected.
  33. st=0; $SHELL -c 'rm -f d/f' 2>stderr || st=$?
  34. cat stderr >&2
  35. test $st -gt 0 || skip_ "can delete files from unwritable directories"
  36. if grep 'rm:' stderr; then
  37. rm_f_is_silent_on_error=no
  38. else
  39. rm_f_is_silent_on_error=yes
  40. fi
  41. cat >> configure.ac << 'END'
  42. AC_OUTPUT
  43. END
  44. cat > Makefile.am << 'END'
  45. data_DATA = foobar.txt
  46. END
  47. : > foobar.txt
  48. $ACLOCAL
  49. $AUTOMAKE
  50. $AUTOCONF
  51. # Weird name, to make it harder to experience false positives when
  52. # grepping error messages.
  53. inst=__inst-dir__
  54. ./configure --prefix="$(pwd)/$inst"
  55. mkdir $inst $inst/share
  56. : > $inst/share/foobar.txt
  57. chmod a-w $inst/share
  58. run_make -M -e FAIL uninstall
  59. if test $rm_f_is_silent_on_error = yes; then
  60. : "rm -f" is silent on errors, skip the grepping of make output
  61. else
  62. grep "rm: .*foobar\.txt" output
  63. fi
  64. chmod a-rwx $inst/share
  65. (cd $inst/share) && skip_ "cannot make directories fully unreadable"
  66. run_make -M -e FAIL uninstall
  67. # Some shells, like Solaris 10 /bin/ksh and /usr/xpg4/bin/sh, do not
  68. # report the name of the 'cd' builtin upon a chdir error:
  69. #
  70. # $ /bin/ksh -c 'cd /none'
  71. # /bin/ksh: /none: not found
  72. #
  73. # and also print a line number in the error message *if the command
  74. # contains newlines*:
  75. #
  76. # $ /bin/ksh -c 'cd unreadable'
  77. # /bin/ksh: unreadable: permission denied
  78. # $ /bin/ksh -c '\
  79. # > \
  80. # > cd unreadable'
  81. # /bin/ksh[3]: unreadable: permission denied
  82. $EGREP "(cd|sh)(\[[0-9]*[0-9]\])?: .*$inst/share" output
  83. :