parallel-tests-basics.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #! /bin/sh
  2. # Copyright (C) 2009-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. # Basic checks on parallel-tests support:
  17. # - console output
  18. # - log files, and what goes in 'test-suite.log'
  19. # - make clean
  20. # - dependencies between tests
  21. # - TESTS redefinition at runtime
  22. # - TEST_LOGS redefinition at runtime
  23. # - RECHECK_LOGS redefinition at runtime
  24. . test-init.sh
  25. cat >> configure.ac << 'END'
  26. AC_OUTPUT
  27. END
  28. cat > Makefile.am << 'END'
  29. TESTS = foo.test bar.test baz.test
  30. XFAIL_TESTS = bar.test
  31. foo.log: bar.log
  32. bar.log: baz.log
  33. END
  34. # foo.test and bar.test sleep to ensure their logs are always strictly newer
  35. # than the logs of their prerequisites, for HP-UX make. The quoting pleases
  36. # maintainer-check.
  37. cat > foo.test <<'END'
  38. #! /bin/sh
  39. echo "this is $0"
  40. sleep '1'
  41. exit 0
  42. END
  43. cat > bar.test <<'END'
  44. #! /bin/sh
  45. echo "this is $0"
  46. sleep '1'
  47. exit 99
  48. END
  49. cat > baz.test <<'END'
  50. #! /bin/sh
  51. echo "this is $0"
  52. exit 1
  53. END
  54. chmod a+x foo.test bar.test baz.test
  55. $ACLOCAL
  56. $AUTOCONF
  57. $AUTOMAKE -a
  58. ./configure
  59. run_make -O -e FAIL check
  60. count_test_results total=3 pass=1 fail=1 skip=0 xfail=0 xpass=0 error=1
  61. test -f test-suite.log
  62. cat test-suite.log
  63. test $(grep -c '^FAIL:' test-suite.log) -eq 1
  64. test $(grep -c '^ERROR:' test-suite.log) -eq 1
  65. $EGREP '^(X?PASS|XFAIL|SKIP)' test-suite.log && exit 1
  66. test -f baz.log
  67. test -f bar.log
  68. test -f foo.log
  69. $MAKE clean
  70. test ! -e baz.log
  71. test ! -e bar.log
  72. test ! -e foo.log
  73. test ! -e test-suite.log
  74. # Check dependencies: baz.test needs to run before bar.test,
  75. # but foo.test is not needed.
  76. # Note that this usage has a problem: the summary will only
  77. # take bar.log into account, because the $(TEST_SUITE_LOG) rule
  78. # does not "see" baz.log. Hmm.
  79. run_make -O -e FAIL TESTS='bar.test' check
  80. grep '^FAIL: baz\.test$' stdout
  81. grep '^ERROR: bar\.test$' stdout
  82. test -f baz.log
  83. test -f bar.log
  84. test ! -e foo.log
  85. test -f test-suite.log
  86. # Upon a lazy rerun, foo.test should be run, but the others shouldn't.
  87. # Note that the lazy rerun still exits with a failure, due to the previous
  88. # test failures.
  89. # Note that the previous test and this one taken together expose the timing
  90. # issue that requires the check-TESTS rule to always remove TEST_SUITE_LOG
  91. # before running the tests lazily.
  92. run_make -O -e FAIL check RECHECK_LOGS=
  93. test -f foo.log
  94. grep '^PASS: foo\.test$' stdout
  95. grep bar.test stdout && exit 1
  96. grep baz.test stdout && exit 1
  97. grep '^# PASS: *1$' stdout
  98. grep '^# FAIL: *1$' stdout
  99. grep '^# ERROR: *1$' stdout
  100. # Now, explicitly retry with all test logs already updated, and ensure
  101. # that the summary is still displayed.
  102. run_make -O -e FAIL check RECHECK_LOGS=
  103. grep foo.test stdout && exit 1
  104. grep bar.test stdout && exit 1
  105. grep baz.test stdout && exit 1
  106. grep '^# PASS: *1$' stdout
  107. grep '^# FAIL: *1$' stdout
  108. grep '^# ERROR: *1$' stdout
  109. # Lazily rerunning only foo should only rerun this one test.
  110. run_make -O -e FAIL check RECHECK_LOGS=foo.log
  111. grep foo.test stdout
  112. grep bar.test stdout && exit 1
  113. grep baz.test stdout && exit 1
  114. grep '^# PASS: *1$' stdout
  115. grep '^# FAIL: *1$' stdout
  116. grep '^# ERROR: *1$' stdout
  117. $MAKE clean
  118. run_make -O -e FAIL TEST_LOGS=baz.log check
  119. grep foo.test stdout && exit 1
  120. grep bar.test stdout && exit 1
  121. grep baz.test stdout
  122. $MAKE clean
  123. run_make -O -e FAIL TESTS=baz.test check
  124. grep foo.test stdout && exit 1
  125. grep bar.test stdout && exit 1
  126. grep baz.test stdout
  127. :