test-trs-recover.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 parallel harness features:
  17. # - recovery from deleted '.trs' files, in various scenarios
  18. # This test is complex and tricky, but that's acceptable since we are
  19. # testing semantics that are potentially complex and tricky.
  20. . test-init.sh
  21. cat >> configure.ac <<END
  22. AC_OUTPUT
  23. END
  24. cat > Makefile.am << 'END'
  25. TESTS = foo.test bar.test baz.test
  26. TEST_LOG_COMPILER = $(SHELL)
  27. END
  28. echo 'exit $TEST_STATUS' > foo.test
  29. echo 'exit $TEST_STATUS' > bar.test
  30. : > baz.test
  31. TEST_STATUS=0; export TEST_STATUS
  32. # Slower and possible overkill in some situations, but also clearer
  33. # and safer.
  34. update_stamp () { $sleep && touch stamp && $sleep; }
  35. $ACLOCAL
  36. $AUTOCONF
  37. $AUTOMAKE -a
  38. ./configure
  39. : Create the required log files.
  40. $MAKE check
  41. : Recreate by hand.
  42. rm -f foo.trs bar.trs baz.trs
  43. $MAKE foo.trs
  44. test -f foo.trs
  45. test ! -e bar.trs
  46. test ! -e baz.trs
  47. : Recreate by hand, several at the same time.
  48. rm -f foo.trs bar.trs baz.trs
  49. $MAKE foo.trs bar.trs
  50. test -f foo.trs
  51. test -f bar.trs
  52. test ! -e baz.trs
  53. : Recreate by hand, with a failing test.
  54. rm -f foo.trs bar.trs
  55. run_make -O TEST_STATUS=1 bar.trs baz.trs
  56. test ! -e foo.trs
  57. test -f bar.trs
  58. test -f baz.trs
  59. grep '^FAIL: bar\.test' stdout
  60. $EGREP '^(baz|foo)\.test' stdout && exit 1
  61. : Recreate with a sweeping "make check", and ensure that also up-to-date
  62. : '.trs' files are remade.
  63. update_stamp
  64. rm -f foo.trs bar.trs
  65. $MAKE check
  66. test -f foo.trs
  67. test -f bar.trs
  68. is_newest baz.trs stamp
  69. : Recreate with a sweeping "make check" with failing tests. Again,
  70. : ensure that also up-to-date '.trs' files are remade -- this time we
  71. : grep the "make check" output verify that.
  72. rm -f foo.trs bar.trs
  73. run_make -O -e FAIL TEST_STATUS=1 check
  74. test -f foo.trs
  75. test -f bar.trs
  76. grep '^FAIL: foo\.test' stdout
  77. grep '^FAIL: bar\.test' stdout
  78. grep '^PASS: baz\.test' stdout
  79. : Recreate with a "make check" with redefined TESTS.
  80. rm -f foo.trs bar.trs baz.trs
  81. run_make TESTS=foo.test check
  82. test -f foo.trs
  83. test ! -e bar.trs
  84. test ! -e baz.trs
  85. : Recreate with a "make check" with redefined TEST_LOGS.
  86. rm -f foo.trs bar.trs baz.trs
  87. run_make TEST_LOGS=bar.log check
  88. test ! -e foo.trs
  89. test -f bar.trs
  90. test ! -e baz.trs
  91. : Interactions with "make recheck" are OK.
  92. rm -f foo.trs bar.trs baz.log baz.trs
  93. run_make -O recheck
  94. test -f foo.trs
  95. test -f bar.trs
  96. test ! -e baz.trs
  97. test ! -e baz.log
  98. grep '^PASS: foo\.test' stdout
  99. grep '^PASS: bar\.test' stdout
  100. grep 'baz\.test' stdout && exit 1
  101. count_test_results total=2 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=0
  102. : Setup for the next check.
  103. $MAKE check
  104. test -f foo.trs
  105. test -f bar.trs
  106. test -f baz.trs
  107. : Recreate by remaking the global test log, and ensure that up-to-date
  108. : '.trs' files are *not* remade.
  109. update_stamp
  110. rm -f foo.trs bar.trs test-suite.log
  111. run_make -O test-suite.log
  112. grep '^PASS: foo\.test' stdout
  113. grep '^PASS: bar\.test' stdout
  114. grep 'baz\.test' stdout && exit 1
  115. stat *.trs *.log stamp || : # For debugging.
  116. # Check that make has updated what it needed to, but no more.
  117. test -f foo.trs
  118. test -f bar.trs
  119. is_newest stamp baz.trs
  120. is_newest test-suite.log foo.trs bar.trs
  121. : Setup for the next check.
  122. $MAKE check
  123. test -f foo.trs
  124. test -f bar.trs
  125. test -f baz.trs
  126. : Interactions with lazy test reruns are OK.
  127. rm -f foo.trs
  128. update_stamp
  129. touch bar.test
  130. run_make -O RECHECK_LOGS= check
  131. # Check that make has updated what it needed to, but no more.
  132. test -f foo.trs
  133. is_newest bar.trs bar.test
  134. is_newest stamp baz.trs
  135. grep '^PASS: foo\.test' stdout
  136. grep '^PASS: bar\.test' stdout
  137. grep 'baz\.test' stdout && exit 1
  138. :