tap-more.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. # More on TAP support:
  17. # - more than one TAP-generating test script in $(TESTS)
  18. # - VPATH builds
  19. # - use with parallel make (if supported)
  20. # - basic use of diagnostic messages (lines beginning with "#")
  21. # - flags for TAP driver defined through AC_SUBST in configure.ac
  22. # - messages generated by the testsuite harness reference the
  23. # correct test script(s)
  24. # - "make distcheck" works
  25. . test-init.sh
  26. fetch_tap_driver
  27. cat >> configure.ac <<END
  28. AC_SUBST([AM_TEST_LOG_DRIVER_FLAGS], ['--comments'])
  29. AC_OUTPUT
  30. END
  31. cat > Makefile.am << 'END'
  32. TEST_LOG_DRIVER = $(srcdir)/tap-driver
  33. TESTS = 1.test 2.test 3.test
  34. EXTRA_DIST = $(TESTS) tap-driver
  35. END
  36. cat > 1.test <<'END'
  37. #! /bin/sh
  38. echo 1..2
  39. echo ok 1 - mu
  40. if test -f not-skip; then
  41. echo "not ok 2 zardoz"
  42. else
  43. echo "ok 2 zardoz # SKIP"
  44. fi
  45. END
  46. cat > 2.test <<'END'
  47. #! /bin/sh
  48. echo 1..3
  49. echo "ok"
  50. echo "not ok # TODO not implemented"
  51. echo "ok 3"
  52. END
  53. cat > 3.test <<END
  54. #! /bin/sh
  55. echo 1..1
  56. echo ok - blah blah blah
  57. echo '# Some diagnostic'
  58. if test -f bail-out; then
  59. echo 'Bail out! Kernel Panic'
  60. else
  61. :
  62. fi
  63. END
  64. chmod a+x [123].test
  65. $ACLOCAL
  66. $AUTOCONF
  67. $AUTOMAKE
  68. # Try a VPATH and by default serial build first, and then an in-tree
  69. # and by default parallel build.
  70. for try in 0 1; do
  71. if test $try -eq 0; then
  72. # VPATH serial build.
  73. mkdir build
  74. cd build
  75. srcdir=..
  76. am_make=$MAKE
  77. elif test $try -eq 1; then
  78. # In-tree parallel build.
  79. srcdir=.
  80. case $MAKE in
  81. *\ -j*)
  82. # Degree of parallelism already specified by the user: do
  83. # not override it.
  84. :
  85. ;;
  86. *)
  87. # Some make implementations (e.g., HP-UX) don't grok '-j',
  88. # some require no space between '-j' and the number of jobs
  89. # (e.g., older GNU make versions), and some *do* require a
  90. # space between '-j' and the number of jobs (e.g., Solaris
  91. # dmake). We need a runtime test to see what works.
  92. echo 'all:' > Makefile
  93. for am_make in "$MAKE -j3" "$MAKE -j 3" "$MAKE"; do
  94. $am_make && break
  95. done
  96. rm -f Makefile
  97. MAKE=$am_make
  98. unset am_make
  99. ;;
  100. esac
  101. else
  102. fatal_ "internal error, invalid value of '$try' for \$try"
  103. fi
  104. $srcdir/configure
  105. ls -l # For debugging.
  106. # Success.
  107. run_make -O check
  108. count_test_results total=6 pass=4 fail=0 xpass=0 xfail=1 skip=1 error=0
  109. grep '^PASS: 1\.test 1 - mu$' stdout
  110. grep '^SKIP: 1\.test 2 zardoz # SKIP$' stdout
  111. test $(grep -c '1\.test' stdout) -eq 2
  112. grep '^PASS: 2\.test 1$' stdout
  113. grep '^XFAIL: 2\.test 2 # TODO not implemented$' stdout
  114. grep '^PASS: 2\.test 3$' stdout
  115. test $(grep -c '2\.test' stdout) -eq 3
  116. grep '^PASS: 3\.test 1 - blah blah blah$' stdout
  117. grep '^# 3\.test: Some diagnostic$' stdout
  118. test $(grep -c '3\.test' stdout) -eq 2
  119. # Failure.
  120. : > not-skip
  121. : > bail-out
  122. run_make -e FAIL -O check
  123. count_test_results total=7 pass=4 fail=1 xpass=0 xfail=1 skip=0 error=1
  124. grep '^PASS: 1\.test 1 - mu$' stdout
  125. grep '^FAIL: 1\.test 2 zardoz$' stdout
  126. test $(grep -c '1\.test' stdout) -eq 2
  127. grep '^PASS: 2\.test 1$' stdout
  128. grep '^XFAIL: 2\.test 2 # TODO not implemented$' stdout
  129. grep '^PASS: 2\.test 3$' stdout
  130. test $(grep -c '2\.test' stdout) -eq 3
  131. grep '^PASS: 3\.test 1 - blah blah blah$' stdout
  132. grep '^# 3\.test: Some diagnostic$' stdout
  133. grep '^ERROR: 3\.test - Bail out! Kernel Panic$' stdout
  134. test $(grep -c '3\.test' stdout) -eq 3
  135. cd $srcdir
  136. done
  137. $MAKE distcheck
  138. :