tap-doc.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 that an example given in the documentation really works.
  17. # See section "Simple Tests" subsection "Script-based Testsuites".
  18. . test-init.sh
  19. fetch_tap_driver
  20. cat >> configure.ac <<END
  21. AC_PROG_CC
  22. AC_OUTPUT
  23. END
  24. cat > Makefile.am << 'END'
  25. TESTS = foo.sh zardoz.tap bar.sh mu.tap
  26. TEST_EXTENSIONS = .sh .tap
  27. TAP_LOG_DRIVER = $(srcdir)/tap-driver
  28. ## Ensure the test scripts are run in the correct order.
  29. mu.log: bar.log
  30. bar.log: zardoz.log
  31. zardoz.log: foo.log
  32. END
  33. cat > foo.sh <<'END'
  34. #!/bin/sh
  35. exit 0
  36. END
  37. cat > bar.sh <<'END'
  38. #!/bin/sh
  39. exit 77
  40. END
  41. cat > zardoz.tap << 'END'
  42. #!/bin/sh
  43. echo 1..4
  44. echo 'ok 1 - Daemon started'
  45. echo 'ok 2 - Daemon responding'
  46. echo 'ok 3 - Daemon uses /proc # SKIP /proc is not mounted'
  47. echo 'ok 4 - Daemon stopped'
  48. END
  49. cat > mu.tap << 'END'
  50. #!/bin/sh
  51. echo 1..2
  52. echo 'ok'
  53. echo 'not ok # TODO frobnication not yet implemented'
  54. END
  55. chmod a+x *.sh *.tap
  56. $ACLOCAL
  57. $AUTOCONF
  58. $AUTOMAKE -a
  59. ./configure
  60. run_make -O check
  61. cat > exp <<'END'
  62. PASS: foo.sh
  63. PASS: zardoz.tap 1 - Daemon started
  64. PASS: zardoz.tap 2 - Daemon responding
  65. SKIP: zardoz.tap 3 - Daemon uses /proc # SKIP /proc is not mounted
  66. PASS: zardoz.tap 4 - Daemon stopped
  67. SKIP: bar.sh
  68. PASS: mu.tap 1
  69. XFAIL: mu.tap 2 # TODO frobnication not yet implemented
  70. END
  71. sed -n '/^PASS: foo\.sh/,/^XFAIL: mu\.tap/p' stdout > t
  72. cat t
  73. # Strip extra "informative" lines that could be printed by Solaris
  74. # Distributed Make.
  75. LC_ALL=C $EGREP -v ' --> ([0-9][0-9]* job|[Jj]ob output)' t > got
  76. cat exp
  77. cat got
  78. diff exp got
  79. :