test-driver-custom-multitest.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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: check that we can easily support 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. . test-init.sh
  21. cp "$am_testaux_srcdir"/trivial-test-driver . \
  22. || fatal_ "failed to fetch auxiliary script trivial-test-driver"
  23. cat >> configure.ac << 'END'
  24. AC_OUTPUT
  25. END
  26. cat > Makefile.am << 'END'
  27. TEST_EXTENSIONS = .t
  28. T_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
  29. TESTS = \
  30. pass.t \
  31. fail.t \
  32. fail2.t \
  33. pass-fail.t \
  34. pass4-skip.t \
  35. pass3-skip2-xfail.t \
  36. pass-xpass-fail-xfail-skip-error.t
  37. END
  38. cat > pass.t << 'END'
  39. echo %% pass %%
  40. echo PASS: pass
  41. END
  42. cat > fail.t << 'END'
  43. echo %% fail %%
  44. echo FAIL: fail
  45. END
  46. cat > fail2.t << 'END'
  47. echo %% fail2 %%
  48. echo FAIL: stdout >&1
  49. echo FAIL: stderr >&2
  50. echo :PASS: this should be ignored
  51. END
  52. cat > pass-fail.t << 'END'
  53. echo %% pass-fail %%
  54. echo 'FAIL: this fails :-('
  55. echo 'some randome message'
  56. echo 'some randome warning' >&2
  57. echo 'PASS: this passes :-)'
  58. echo 'INFO: blah'
  59. echo 'WARNING: blah blah' >&2
  60. END
  61. cat > pass4-skip.t << 'END'
  62. echo %% pass4-skip %%
  63. echo PASS: on stdout >&1
  64. echo PASS: on stderr >&2
  65. echo PASS: 3
  66. echo PASS: 4
  67. echo SKIP: 1
  68. echo this FAIL: should be ignored
  69. echo FAIL as should this
  70. exit 99
  71. END
  72. cat > pass3-skip2-xfail.t << 'END'
  73. echo %% pass4-skip2-xfail %%
  74. echo 'PASS: -v'
  75. echo 'PASS: --verbose'
  76. echo 'SKIP: Oops, unsupported system.'
  77. echo 'PASS: -#-#-#-'
  78. cp || echo "SKIP: cp cannot read users' mind" >&2
  79. mv || echo "XFAIL: mv cannot read users' mind yet"
  80. exit 127
  81. END
  82. cat > pass-xpass-fail-xfail-skip-error.t << 'END'
  83. echo PASS:
  84. echo FAIL:
  85. echo XFAIL:
  86. echo XPASS:
  87. echo SKIP:
  88. echo ERROR:
  89. echo %% pass-xpass-fail-xfail-skip-error %%
  90. END
  91. chmod a+x *.t
  92. $ACLOCAL
  93. $AUTOCONF
  94. $AUTOMAKE
  95. for vpath in : false; do
  96. if $vpath; then
  97. mkdir build
  98. cd build
  99. srcdir=..
  100. else
  101. srcdir=.
  102. fi
  103. $srcdir/configure
  104. run_make -O -e FAIL check || { cat test-suite.log; exit 1; }
  105. cat test-suite.log
  106. # Couple of sanity checks. These might need to be updated if the
  107. # 'trivial-test-driver' script is changed.
  108. $FGREP INVALID.NAME stdout test-suite.log && exit 1
  109. test -f BAD.LOG && exit 1
  110. test -f BAD.TRS && exit 1
  111. # These log files must all have been created by the testsuite.
  112. cat pass.log
  113. cat fail.log
  114. cat fail2.log
  115. cat pass-fail.log
  116. cat pass4-skip.log
  117. cat pass3-skip2-xfail.log
  118. cat pass-xpass-fail-xfail-skip-error.log
  119. count_test_results total=23 pass=10 fail=5 skip=4 xfail=2 xpass=1 error=1
  120. tst=pass-xpass-fail-xfail-skip-error
  121. grep "^PASS: $tst\.t, testcase 1" stdout
  122. grep "^FAIL: $tst\.t, testcase 2" stdout
  123. grep "^XFAIL: $tst\.t, testcase 3" stdout
  124. grep "^XPASS: $tst\.t, testcase 4" stdout
  125. grep "^SKIP: $tst\.t, testcase 5" stdout
  126. grep "^ERROR: $tst\.t, testcase 6" stdout
  127. # Check that the content of, and only of, the test logs with at least
  128. # one failing test case has been copied into 'test-suite.log'. Note
  129. # that test logs containing skipped or xfailed test cases are *not*
  130. # copied into 'test-suite.log' -- a behaviour that deliberately differs
  131. # from the one of the built-in Automake test drivers.
  132. grep '%%' test-suite.log # For debugging.
  133. grep '%% fail %%' test-suite.log
  134. grep '%% fail2 %%' test-suite.log
  135. grep '%% pass-fail %%' test-suite.log
  136. grep '%% pass-xpass-fail-xfail-skip-error %%' test-suite.log
  137. test $(grep -c '%% ' test-suite.log) -eq 4
  138. run_make -O TESTS='pass.t pass3-skip2-xfail.t' check
  139. cat test-suite.log
  140. count_test_results total=7 pass=4 fail=0 skip=2 xfail=1 xpass=0 error=0
  141. cd $srcdir
  142. done
  143. :