test-driver-custom-multitest-recheck.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. # Custom test drivers: try the "recheck" functionality with test protocols
  17. # that allow multiple testcases in a single test script. This test not
  18. # only checks implementation details in Automake's custom test drivers
  19. # support, but also serves as a "usability test" for our APIs.
  20. # See also related tests 'test-driver-custom-multitest-recheck2.sh'
  21. # and 'parallel-tests-recheck-override.sh'.
  22. # Keep in sync with 'tap-recheck.sh'.
  23. . test-init.sh
  24. cp "$am_testaux_srcdir"/trivial-test-driver . \
  25. || fatal_ "failed to fetch auxiliary script trivial-test-driver"
  26. cat >> configure.ac << 'END'
  27. AC_OUTPUT
  28. END
  29. cat > Makefile.am << 'END'
  30. TEST_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
  31. TESTS = a.test b.test c.test d.test
  32. END
  33. cat > a.test << 'END'
  34. #! /bin/sh
  35. echo PASS: aa
  36. echo PASS: AA
  37. : > a.run
  38. END
  39. cat > b.test << 'END'
  40. #! /bin/sh
  41. echo PASS:
  42. if test -f b.ok; then
  43. echo PASS:
  44. else
  45. echo ERROR:
  46. fi
  47. : > b.run
  48. END
  49. cat > c.test << 'END'
  50. #! /bin/sh
  51. if test -f c.pass; then
  52. echo PASS: c0
  53. else
  54. echo FAIL: c0
  55. fi
  56. if test -f c.xfail; then
  57. echo XFAIL: c1
  58. else
  59. echo XPASS: c1
  60. fi
  61. echo XFAIL: c2
  62. : > c.run
  63. END
  64. cat > d.test << 'END'
  65. #! /bin/sh
  66. echo SKIP: who cares ...
  67. (. ./d.extra) || echo FAIL: d.extra failed
  68. : > d.run
  69. END
  70. chmod a+x *.test
  71. $ACLOCAL
  72. $AUTOCONF
  73. $AUTOMAKE
  74. do_recheck ()
  75. {
  76. case $* in
  77. --fail) status=FAIL;;
  78. --pass) status=0;;
  79. *) fatal_ "invalid usage of function 'do_recheck'";;
  80. esac
  81. rm -f *.run
  82. run_make -O -e $status recheck || { ls -l; exit 1; }
  83. ls -l
  84. }
  85. for vpath in : false; do
  86. if $vpath; then
  87. mkdir build
  88. cd build
  89. srcdir=..
  90. else
  91. srcdir=.
  92. fi
  93. $srcdir/configure
  94. : A "make recheck" in a clean tree should run no tests.
  95. using_gmake || $sleep # Required by BSD make.
  96. do_recheck --pass
  97. cat test-suite.log
  98. test ! -e a.run
  99. test ! -e a.log
  100. test ! -e b.run
  101. test ! -e b.log
  102. test ! -e c.run
  103. test ! -e c.log
  104. test ! -e d.run
  105. test ! -e d.log
  106. count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
  107. : Run the tests for the first time.
  108. run_make -O -e FAIL check
  109. ls -l
  110. # All the test scripts should have run.
  111. test -f a.run
  112. test -f b.run
  113. test -f c.run
  114. test -f d.run
  115. count_test_results total=9 pass=3 fail=2 xpass=1 xfail=1 skip=1 error=1
  116. : Let us make b.test pass.
  117. using_gmake || $sleep # Required by BSD make.
  118. echo OK > b.ok
  119. do_recheck --fail
  120. # a.test has been successful the first time, so no need to re-run it.
  121. # Similar considerations apply to similar checks, below.
  122. test ! -e a.run
  123. test -f b.run
  124. test -f c.run
  125. test -f d.run
  126. count_test_results total=7 pass=2 fail=2 xpass=1 xfail=1 skip=1 error=0
  127. : Let us make the first part of c.test pass.
  128. using_gmake || $sleep # Required by BSD make.
  129. echo OK > c.pass
  130. do_recheck --fail
  131. test ! -e a.run
  132. test ! -e b.run
  133. test -f c.run
  134. test -f d.run
  135. count_test_results total=5 pass=1 fail=1 xpass=1 xfail=1 skip=1 error=0
  136. : Let us make also the second part of c.test pass.
  137. using_gmake || $sleep # Required by BSD make.
  138. echo KO > c.xfail
  139. do_recheck --fail
  140. test ! -e a.run
  141. test ! -e b.run
  142. test -f c.run
  143. test -f d.run
  144. count_test_results total=5 pass=1 fail=1 xpass=0 xfail=2 skip=1 error=0
  145. : Nothing changed, so only d.test should be run.
  146. for i in 1 2; do
  147. using_gmake || $sleep # Required by BSD make.
  148. do_recheck --fail
  149. test ! -e a.run
  150. test ! -e b.run
  151. test ! -e c.run
  152. test -f d.run
  153. count_test_results total=2 pass=0 fail=1 xpass=0 xfail=0 skip=1 error=0
  154. done
  155. : Let us make d.test run more testcases, and experience _more_ failures.
  156. using_gmake || $sleep # Required by BSD make.
  157. unindent > d.extra <<'END'
  158. echo SKIP: s
  159. echo FAIL: f 1
  160. echo PASS: p 1
  161. echo FAIL: f 2
  162. echo XPASS: xp
  163. echo FAIL: f 3
  164. echo FAIL: f 4
  165. echo ERROR: e 1
  166. echo PASS: p 2
  167. echo ERROR: e 2
  168. END
  169. do_recheck --fail
  170. test ! -e a.run
  171. test ! -e b.run
  172. test ! -e c.run
  173. test -f d.run
  174. count_test_results total=11 pass=2 fail=4 xpass=1 xfail=0 skip=2 error=2
  175. : Let us finally make d.test pass.
  176. using_gmake || $sleep # Required by BSD make.
  177. echo : > d.extra
  178. do_recheck --pass
  179. test ! -e a.run
  180. test ! -e b.run
  181. test ! -e c.run
  182. test -f d.run
  183. count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=0
  184. : All tests have been successful or skipped, nothing should be re-run.
  185. using_gmake || $sleep # Required by BSD make.
  186. do_recheck --pass
  187. test ! -e a.run
  188. test ! -e b.run
  189. test ! -e c.run
  190. test ! -e d.run
  191. count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
  192. cd $srcdir
  193. done
  194. :