check12.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. #! /bin/sh
  2. # Copyright (C) 2010-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. # Test to make sure dejagnu tests, automake-style tests, and check-local
  17. # target can coexist.
  18. # For gen-testsuite-part: ==> try-with-serial-tests <==
  19. required=runtest
  20. . test-init.sh
  21. cat >> configure.ac << 'END'
  22. AC_OUTPUT
  23. END
  24. cat > Makefile.am << 'END'
  25. AUTOMAKE_OPTIONS =
  26. EXTRA_DIST =
  27. CLEANFILES =
  28. END
  29. ## Simple tests.
  30. cat > a.test << 'END'
  31. #!/bin/sh
  32. echo a.test: exit status: ${A_EXIT_STATUS-0}
  33. exit ${A_EXIT_STATUS-0}
  34. END
  35. cat > b.test << 'END'
  36. #!/bin/sh
  37. echo b.test: exit status: ${B_EXIT_STATUS-0}
  38. exit ${B_EXIT_STATUS-0}
  39. END
  40. chmod +x a.test b.test
  41. cat >> Makefile.am << 'END'
  42. TESTS = a.test b.test
  43. EXTRA_DIST += $(TESTS)
  44. END
  45. A_EXIT_STATUS=0; export A_EXIT_STATUS
  46. B_EXIT_STATUS=0; export B_EXIT_STATUS
  47. ## DejaGnu tests.
  48. cat >> Makefile.am << 'END'
  49. AUTOMAKE_OPTIONS += dejagnu
  50. DEJATOOL = hammer spanner
  51. AM_RUNTESTFLAGS = HAMMER=$(srcdir)/hammer SPANNER=$(srcdir)/spanner
  52. EXTRA_DIST += hammer.test/hammer.exp
  53. EXTRA_DIST += spanner.test/spanner.exp
  54. END
  55. cat > hammer << 'END'
  56. #! /bin/sh
  57. echo "Everything looks like a ${NAIL-nail} to me!"
  58. END
  59. NAIL=nail; export NAIL
  60. cat > spanner << 'END'
  61. #! /bin/sh
  62. echo "I'm a right spanner!"
  63. END
  64. chmod +x hammer spanner
  65. mkdir hammer.test spanner.test
  66. cat > hammer.test/hammer.exp << 'END'
  67. set test test_hammer
  68. spawn $HAMMER
  69. expect {
  70. "Everything looks like a nail to me!" { pass "$test" }
  71. default { fail "$test" }
  72. }
  73. END
  74. cat > spanner.test/spanner.exp << 'END'
  75. set test test_spanner
  76. spawn $SPANNER
  77. expect {
  78. "I'm a right spanner!" { pass "$test" }
  79. default { fail "$test" }
  80. }
  81. END
  82. ## User-defined extra tests.
  83. cat >> Makefile.am <<'END'
  84. check-local:
  85. case $$CHECKLOCAL_EXIT_STATUS in \
  86. 0) echo 'check-local succeeded :-)';; \
  87. *) echo 'check-local failed :-(';; \
  88. esac >local.log
  89. exit $$CHECKLOCAL_EXIT_STATUS
  90. CLEANFILES += local.log
  91. END
  92. CHECKLOCAL_EXIT_STATUS=0; export CHECKLOCAL_EXIT_STATUS
  93. ## Go with the testcase execution.
  94. $ACLOCAL
  95. $AUTOCONF
  96. $AUTOMAKE --add-missing
  97. for vpath in : false; do
  98. if $vpath; then
  99. srcdir=..
  100. mkdir build
  101. cd build
  102. else
  103. srcdir=.
  104. fi
  105. if test -f config.status; then
  106. $MAKE distclean
  107. fi
  108. $srcdir/configure
  109. $MAKE check
  110. test -f hammer.log
  111. test -f hammer.sum
  112. test -f spanner.log
  113. test -f spanner.sum
  114. if test x"$am_serial_tests" != x"yes"; then
  115. test -f test-suite.log
  116. test -f a.log
  117. test -f b.log
  118. fi
  119. grep 'check-local succeeded :-)' local.log
  120. cp -f config.status config-status.sav
  121. $MAKE distclean
  122. test ! -e hammer.log
  123. test ! -e hammer.sum
  124. test ! -e spanner.log
  125. test ! -e spanner.sum
  126. test ! -e test-suite.log
  127. test ! -e a.log
  128. test ! -e b.log
  129. test ! -e local.log
  130. mv -f config-status.sav config.status
  131. ./config.status
  132. NAIL=screw $MAKE check && exit 1
  133. test -f hammer.log
  134. test -f hammer.sum
  135. test -f spanner.log
  136. test -f spanner.sum
  137. grep 'FAIL: test_hammer' hammer.sum
  138. grep 'FAIL:' spanner.sum && exit 1
  139. B_EXIT_STATUS=1 $MAKE check && exit 1
  140. if test x"$am_serial_tests" != x"yes"; then
  141. cat test-suite.log
  142. cat a.log
  143. cat b.log
  144. grep '^a\.test: exit status: 0$' a.log
  145. grep '^b\.test: exit status: 1$' b.log
  146. grep '^FAIL: b$' test-suite.log
  147. grep '^b\.test: exit status: 1$' test-suite.log
  148. grep '^a\.test' test-suite.log && exit 1
  149. : For shells with busted 'set -e'.
  150. fi
  151. CHECKLOCAL_EXIT_STATUS=1 $MAKE check && exit 1
  152. grep 'check-local failed :-(' local.log
  153. # Do not trust the exit status of 'make -k'.
  154. NAIL=screw B_EXIT_STATUS=23 CHECKLOCAL_EXIT_STATUS=1 $MAKE -k check || :
  155. test -f hammer.log
  156. test -f hammer.sum
  157. test -f spanner.log
  158. test -f spanner.sum
  159. grep 'FAIL: test_hammer' hammer.sum
  160. grep 'FAIL:' spanner.sum && exit 1
  161. if test x"$am_serial_tests" != x"yes"; then
  162. cat test-suite.log
  163. cat a.log
  164. cat b.log
  165. grep '^a\.test: exit status: 0$' a.log
  166. grep '^b\.test: exit status: 23$' b.log
  167. grep '^FAIL: b$' test-suite.log
  168. grep '^b\.test: exit status: 23$' test-suite.log
  169. grep '^a\.test' test-suite.log && exit 1
  170. : For shells with busted 'set -e'.
  171. fi
  172. grep 'check-local failed :-(' local.log
  173. cd $srcdir
  174. done
  175. $MAKE distcheck
  176. :