parallel-tests-dry-run-2.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. # Check interactions between the parallel test harness and "make -n".
  17. # See also sister test 'parallel-tests-dry-run-1.sh'.
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_OUTPUT
  21. END
  22. cat > Makefile.am <<'END'
  23. TESTS = foo.test bar.test
  24. TEST_LOG_COMPILER = $(SHELL)
  25. END
  26. $ACLOCAL
  27. $AUTOMAKE -a
  28. $AUTOCONF
  29. ./configure
  30. make_n_ ()
  31. {
  32. st=0
  33. run_make -M -- -n "$@" || { ls -l; exit 1; }
  34. # Look out for possible errors from common tools used by recipes.
  35. $EGREP -i ' (exist|permission|denied|no .*(such|file))' output && exit 1
  36. $EGREP '(mv|cp|rm|cat|grep|sed|awk): ' output && exit 1
  37. :
  38. }
  39. : > output
  40. files='foo.log bar.log foo.trs bar.trs'
  41. echo 'exit 0' > foo.test
  42. echo 'exit 1' > bar.test
  43. for target in check recheck test-suite.log; do
  44. make_n_ $target
  45. test ! -e foo.log
  46. test ! -e foo.trs
  47. test ! -e bar.log
  48. test ! -e bar.trs
  49. test ! -e test-suite.log
  50. done
  51. $MAKE check && exit 1
  52. chmod a-w .
  53. make_n_ clean
  54. test -f foo.log
  55. test -f foo.trs
  56. test -f foo.log
  57. test -f bar.trs
  58. cat > foo.test <<END
  59. echo this is bad
  60. exit 1
  61. END
  62. echo 'exit 0' > bar.test
  63. for target in check recheck test-suite.log; do
  64. make_n_ $target
  65. grep '^:test-result: *FAIL' bar.trs
  66. grep 'this is bad' foo.log test-suite.log && exit 1
  67. : For shells with busted 'set -e'.
  68. done
  69. chmod a-rw $files
  70. if test -r foo.log; then
  71. : You can still read unreadable files! Skip these checks.
  72. else
  73. for target in check recheck test-suite.log; do
  74. make_n_ $target
  75. for f in $files; do
  76. test -f $f && test ! -r $f || exit 1
  77. done
  78. done
  79. fi
  80. chmod u+r $files
  81. chmod u+w .
  82. rm -f foo.log bar.trs
  83. chmod a-w .
  84. for target in check recheck test-suite.log $files; do
  85. make_n_ $target
  86. test ! -e foo.log
  87. test -f foo.trs
  88. test ! -e bar.trs
  89. test -f bar.log
  90. done
  91. :