dejagnu4.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #! /bin/sh
  2. # Copyright (C) 2003-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 the DejaGnu rules work for a simple program and test case.
  17. # Also check PR 488: Failure of the first of several tools tested.
  18. # From the original bug report:
  19. # If you use dejagnu for testing and have multiple tools (i.e.,
  20. # multiple entries in the DEJATOOL variable) then the success/failure
  21. # of "make check" is only dependent on the success/failure of the
  22. # tests on the final tool. Thus there may be failures in the tests on
  23. # previous tools, but at first glance "make check" has passed.
  24. required=runtest
  25. . test-init.sh
  26. cat > hammer << 'END'
  27. #! /bin/sh
  28. echo "Everything looks like a nail to me!"
  29. END
  30. chmod +x hammer
  31. cat > spanner << 'END'
  32. #! /bin/sh
  33. echo "I'm a right spanner!"
  34. END
  35. chmod +x spanner
  36. cat >> configure.ac << 'END'
  37. AC_OUTPUT
  38. END
  39. cat > Makefile.am << 'END'
  40. AUTOMAKE_OPTIONS = dejagnu
  41. DEJATOOL = hammer spanner
  42. AM_RUNTESTFLAGS = HAMMER=$(srcdir)/hammer SPANNER=$(srcdir)/spanner
  43. EXTRA_DIST = hammer hammer.test/hammer.exp
  44. EXTRA_DIST += spanner spanner.test/spanner.exp
  45. END
  46. mkdir hammer.test spanner.test
  47. cat > hammer.test/hammer.exp << 'END'
  48. set test test
  49. spawn $HAMMER
  50. expect {
  51. "Everything looks like a nail to me!" { pass "$test" }
  52. default { fail "$test" }
  53. }
  54. END
  55. cat > spanner.test/spanner.exp << 'END'
  56. set test test
  57. spawn $SPANNER
  58. expect {
  59. "I'm a right spanner!" { pass "$test" }
  60. default { fail "$test" }
  61. }
  62. END
  63. $ACLOCAL
  64. $AUTOCONF
  65. $AUTOMAKE --add-missing
  66. ./configure
  67. $MAKE check
  68. test -f hammer.log
  69. test -f hammer.sum
  70. test -f spanner.log
  71. test -f spanner.sum
  72. $MAKE distcheck
  73. # Test for PR 488.
  74. sed 's/E\(verything\)/Not e\1/' hammer > thammer
  75. mv -f thammer hammer
  76. chmod +x hammer
  77. rm -f hammer.log hammer.sum spanner.log spanner.sum
  78. $MAKE check && exit 1
  79. test -f hammer.log
  80. test -f hammer.sum
  81. test -f spanner.log
  82. test -f spanner.sum
  83. :