test-metadata-results.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. # Parallel testsuite harness: check APIs for the registering of test
  17. # results in '*.trs' files, as documented in the automake manual.
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_OUTPUT
  21. END
  22. cat > Makefile.am << 'END'
  23. TEST_LOG_DRIVER = ./dummy-driver
  24. TESTS = foo.test bar.test
  25. END
  26. cat > dummy-driver <<'END'
  27. #! /bin/sh
  28. set -e; set -u
  29. while test $# -gt 0; do
  30. case $1 in
  31. --log-file) log_file=$2; shift;;
  32. --trs-file) trs_file=$2; shift;;
  33. --test-name) test_name=$2; shift;;
  34. --expect-failure|--color-tests|--enable-hard-errors) shift;;
  35. --) shift; break;;
  36. *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
  37. esac
  38. shift
  39. done
  40. : > $log_file
  41. cp $1 $trs_file
  42. END
  43. chmod a+x dummy-driver
  44. mk_check ()
  45. {
  46. stat=0
  47. case $1 in
  48. -e) stat=$2; shift 2;;
  49. esac
  50. run_make -O -e $stat -- check
  51. # Our dummy driver make no testsuite progress report.
  52. grep ': .*\.test' stdout && exit 1
  53. # Nor it writes to the log files.
  54. test -s foo.log && exit 1
  55. test -s bar.log && exit 1
  56. : For 'set -e'.
  57. }
  58. # This must be different from the one defined in 'test/defs', as that
  59. # assumes that the driver does proper testsuite progress reporting.
  60. count_test_results ()
  61. {
  62. total=ERR pass=ERR fail=ERR xpass=ERR xfail=ERR skip=ERR error=ERR
  63. eval "$@"
  64. st=0
  65. grep "^# TOTAL: *$total$" stdout || rc=1
  66. grep "^# PASS: *$pass$" stdout || rc=1
  67. grep "^# XFAIL: *$xfail$" stdout || rc=1
  68. grep "^# SKIP: *$skip$" stdout || rc=1
  69. grep "^# FAIL: *$fail$" stdout || rc=1
  70. grep "^# XPASS: *$xpass$" stdout || rc=1
  71. grep "^# ERROR: *$error$" stdout || rc=1
  72. test $st -eq 0 || exit 1
  73. }
  74. $ACLOCAL
  75. $AUTOCONF
  76. $AUTOMAKE
  77. ./configure
  78. # Basic checks. Also that that ':global-test-result:' fields and
  79. # "old-style" directives with format "RESULT: test-name" are now ignored.
  80. : > foo.test
  81. echo blah blah blah > bar.test
  82. mk_check
  83. count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
  84. cat > foo.test <<END
  85. :test-global-result: PASS
  86. :test-result: FAIL
  87. END
  88. cat > bar.test <<END
  89. :test-result: SKIP
  90. :test-global-result: ERROR
  91. END
  92. mk_check -e FAIL
  93. count_test_results total=2 pass=0 fail=1 xpass=0 xfail=0 skip=1 error=0
  94. cat > foo.test <<END
  95. FAIL: foo.test
  96. :test-result: PASS
  97. :test-global-result: XPASS
  98. END
  99. echo ERROR: bar.test > bar.test
  100. mk_check
  101. count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
  102. cat > foo.test <<END
  103. :test-global-result: SKIP
  104. :test-result: FAIL
  105. END
  106. cat > bar.test <<END
  107. :test-global-result: PASS
  108. END
  109. mk_check -e FAIL
  110. count_test_results total=1 pass=0 fail=1 xpass=0 xfail=0 skip=0 error=0
  111. cat > foo.test <<END
  112. :test-result: XFAIL
  113. :test-result: PASS
  114. :test-result: SKIP
  115. END
  116. cat > bar.test <<END
  117. :test-result: SKIP
  118. :test-result: PASS
  119. :test-result: SKIP
  120. :test-result: PASS
  121. :test-result: PASS
  122. END
  123. mk_check
  124. count_test_results total=8 pass=4 fail=0 xpass=0 xfail=1 skip=3 error=0
  125. # Check that all results expected to be supported are *really* supported.
  126. cat > foo.test <<END
  127. :test-result: PASS
  128. :test-result: SKIP
  129. :test-result: XFAIL
  130. :test-result: FAIL
  131. :test-result: XPASS
  132. :test-result: ERROR
  133. END
  134. : > bar.test
  135. mk_check -e FAIL
  136. count_test_results total=6 pass=1 fail=1 xpass=1 xfail=1 skip=1 error=1
  137. cp foo.test bar.test
  138. mk_check -e FAIL
  139. count_test_results total=12 pass=2 fail=2 xpass=2 xfail=2 skip=2 error=2
  140. # Check that we are liberal w.r.t. whitespace use.
  141. : > foo.test
  142. : > bar.test
  143. for RESULT in PASS FAIL XPASS XFAIL SKIP ERROR; do
  144. sed -e 's/^ *//' -e 's/|//g' >> foo.test <<END
  145. |:test-result:$RESULT|
  146. |:test-result: $tab $RESULT|
  147. |:test-result:$RESULT $tab|
  148. |:test-result:$tab$tab $RESULT$tab $tab |
  149. END
  150. echo " $tab $tab$tab :test-result: $RESULT" >> bar.test
  151. done
  152. cat foo.test # For debugging.
  153. cat bar.test # Likewise.
  154. mk_check -e FAIL
  155. count_test_results total=30 pass=5 fail=5 xpass=5 xfail=5 skip=5 error=5
  156. :