test-driver-custom-multitest-recheck2.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. In particular,
  18. # check that this still works when we override $(TESTS) and $(TEST_LOGS)
  19. # at make runtime.
  20. # See also related tests 'test-driver-custom-multitest-recheck.sh' and
  21. # 'parallel-tests-recheck-override.sh'.
  22. . test-init.sh
  23. cp "$am_testaux_srcdir"/trivial-test-driver . \
  24. || fatal_ "failed to fetch auxiliary script trivial-test-driver"
  25. cat >> configure.ac << 'END'
  26. AC_OUTPUT
  27. END
  28. cat > Makefile.am << 'END'
  29. TEST_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
  30. TESTS = a.test b.test c.test
  31. END
  32. cat > a.test << 'END'
  33. #! /bin/sh
  34. echo PASS: 1
  35. echo PASS: 2
  36. : > a.run
  37. END
  38. cat > b.test << 'END'
  39. #! /bin/sh
  40. echo SKIP: b0
  41. if test -f b.ok; then
  42. echo XFAIL: b1
  43. else
  44. echo FAIL: b2
  45. fi
  46. : > b.run
  47. END
  48. cat > c.test << 'END'
  49. #! /bin/sh
  50. if test -f c.err; then
  51. echo ERROR: xxx
  52. elif test -f c.ok; then
  53. echo PASS: ok
  54. else
  55. echo XPASS: xp
  56. fi
  57. : > c.run
  58. END
  59. chmod a+x *.test
  60. $ACLOCAL
  61. $AUTOCONF
  62. $AUTOMAKE
  63. for vpath in : false; do
  64. if $vpath; then
  65. mkdir build
  66. cd build
  67. srcdir=..
  68. else
  69. srcdir=.
  70. fi
  71. $srcdir/configure
  72. : Run the tests for the first time.
  73. run_make -O -e FAIL check
  74. # All the test scripts should have run.
  75. test -f a.run
  76. test -f b.run
  77. test -f c.run
  78. count_test_results total=5 pass=2 fail=1 xpass=1 xfail=0 skip=1 error=0
  79. rm -f *.run
  80. : An empty '$(TESTS)' or '$(TEST_LOGS)' means that no test should be run.
  81. for var in TESTS TEST_LOGS; do
  82. run_make -O "$var=" recheck
  83. count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
  84. test ! -e a.run
  85. test ! -e b.run
  86. test ! -e c.run
  87. done
  88. unset var
  89. : a.test was successful the first time, no need to re-run it.
  90. using_gmake || $sleep # Required by BSD make.
  91. run_make -O TESTS=a.test recheck
  92. count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
  93. test ! -e a.run
  94. test ! -e b.run
  95. test ! -e c.run
  96. : b.test failed, it should be re-run. And make it pass this time.
  97. using_gmake || $sleep # Required by BSD make.
  98. echo OK > b.ok
  99. run_make -O TEST_LOGS=b.log recheck
  100. test ! -e a.run
  101. test -f b.run
  102. test ! -e c.run
  103. count_test_results total=2 pass=0 fail=0 xpass=0 xfail=1 skip=1 error=0
  104. rm -f *.run
  105. : No need to re-run a.test or b.test anymore.
  106. using_gmake || $sleep # Required by BSD make.
  107. run_make -O TEST_LOGS=b.log recheck
  108. count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
  109. test ! -e a.run
  110. test ! -e b.run
  111. test ! -e c.run
  112. using_gmake || $sleep # Required by BSD make.
  113. run_make -O TESTS='a.test b.test' recheck
  114. count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
  115. test ! -e a.run
  116. test ! -e b.run
  117. test ! -e c.run
  118. : No need to re-run a.test anymore, but c.test should be rerun,
  119. : as it contained an XPASS. And this time, make it fail with
  120. : an hard error.
  121. echo dummy > c.err
  122. run_make -e FAIL -O TEST_LOGS='a.log c.log' recheck
  123. count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1
  124. test ! -e a.run
  125. test ! -e b.run
  126. test -f c.run
  127. rm -f *.run *.err
  128. : c.test contained and hard error the last time, so it should be re-run.
  129. : This time, make it pass
  130. # Use 'echo', not ':'; see comments above for why.
  131. using_gmake || $sleep # Required by BSD make.
  132. echo dummy > c.ok
  133. run_make -O TESTS='c.test a.test' recheck
  134. count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
  135. test ! -e a.run
  136. test ! -e b.run
  137. test -f c.run
  138. rm -f *.run *.err *.ok
  139. : Nothing should be rerun anymore, as all tests have been eventually
  140. : successful.
  141. using_gmake || $sleep # Required by BSD make.
  142. run_make -O recheck
  143. count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
  144. test ! -e a.run
  145. test ! -e b.run
  146. test ! -e c.run
  147. cd $srcdir
  148. done
  149. :