dejagnu-siteexp-extend.sh 3.7 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. # Check that the developer can extend the site.exp generated by the
  17. # automake-generated Makefile.
  18. required=runtest
  19. . test-init.sh
  20. write_check_for ()
  21. {
  22. echo "send_user \"$1: \$$1\\n\""
  23. unindent << END
  24. if { \$$1 == "/$1/" } {
  25. pass "test_$1"
  26. } else {
  27. fail "test_$1"
  28. }
  29. END
  30. }
  31. cat >> configure.ac << 'END'
  32. AC_OUTPUT
  33. END
  34. cat > Makefile.am << 'END'
  35. AUTOMAKE_OPTIONS = dejagnu
  36. DEJATOOL = tool
  37. EXTRA_DIST = tool.test/tool.exp
  38. EXTRA_DEJAGNU_SITE_CONFIG = foo.exp
  39. EXTRA_DIST += foo.exp
  40. END
  41. echo 'set foo "/foo/"' > foo.exp
  42. mkdir tool.test
  43. write_check_for foo > tool.test/tool.exp
  44. cat tool.test/tool.exp
  45. $ACLOCAL
  46. $AUTOCONF
  47. $AUTOMAKE --add-missing
  48. ./configure
  49. $MAKE check
  50. cat foo.exp
  51. cat site.exp
  52. grep 'PASS: test_foo' tool.sum
  53. write_check_for bar >> tool.test/tool.exp
  54. write_check_for baz >> tool.test/tool.exp
  55. cat tool.test/tool.exp
  56. # Ensure that foo.exp will be newer than site.exp, which will
  57. # thus have to be remade.
  58. $sleep
  59. # With this, below we'll also check that settings in files coming later in
  60. # $(EXTRA_DEJAGNU_SITE_CONFIG) override those in files coming earlier.
  61. cat >> foo.exp <<'END'
  62. set bar "/foo/"
  63. set baz "/foo/"
  64. set qux "/foo/"
  65. END
  66. $MAKE check && { cat site.exp; exit 1; }
  67. grep 'PASS: test_foo' tool.sum
  68. grep 'FAIL: test_bar' tool.sum
  69. grep 'FAIL: test_baz' tool.sum
  70. cat >> Makefile.am << 'END'
  71. EXTRA_DEJAGNU_SITE_CONFIG += bar bar.dir/bar
  72. EXTRA_DIST += bar
  73. DISTCLEANFILES = bar.dir/bar
  74. bar.dir/bar:
  75. test -d bar.dir || mkdir bar.dir
  76. echo 'set baz "/baz/"' > $@
  77. END
  78. echo 'set bar "/bar/"' > bar
  79. # This will allow us to check one more time that settings in files
  80. # coming later in $(EXTRA_DEJAGNU_SITE_CONFIG) override those in
  81. # files coming earlier.
  82. echo 'set baz "/xyz/"' >> bar
  83. # Ensure that the Makefile will be newer than site.exp, which will
  84. # thus have to be remade.
  85. $sleep
  86. $AUTOMAKE Makefile
  87. ./config.status Makefile
  88. $MAKE check || { cat site.exp; exit 1; }
  89. cat site.exp
  90. cat bar.dir/bar
  91. $FGREP '/bar/' site.exp
  92. $FGREP '/baz/' site.exp
  93. grep 'PASS: test_foo' tool.sum
  94. grep 'PASS: test_bar' tool.sum
  95. grep 'PASS: test_baz' tool.sum
  96. # Check that the features we're testing behave well in VPATH builds.
  97. $MAKE distcheck
  98. # Check that the user can edit the site.exp file, and that his edits
  99. # are retained.
  100. write_check_for zardoz >> tool.test/tool.exp
  101. cat tool.test/tool.exp
  102. echo 'set zardoz "/zardoz/"' >> site.exp
  103. $MAKE check
  104. cat site.exp
  105. grep 'PASS: test_zardoz' tool.sum
  106. cat >> Makefile.am << 'END'
  107. EXTRA_DEJAGNU_SITE_CONFIG += quux.exp
  108. quux.exp:
  109. echo 'set zardoz "/quux/"' > $@
  110. END
  111. # Ensure that the Makefile will be newer than on site.exp, which will
  112. # thus have to be remade.
  113. $sleep
  114. $AUTOMAKE Makefile
  115. ./config.status Makefile
  116. grep 'zardoz.*/quux/' Makefile
  117. $MAKE site.exp
  118. cat site.exp
  119. cat quux.exp
  120. grep 'zardoz.*/quux/' site.exp
  121. $MAKE check
  122. grep 'PASS: test_zardoz' tool.sum
  123. grep 'zardoz: /zardoz/' tool.log
  124. grep 'zardoz.*quux' tool.log && exit 1
  125. # Check that files in $(EXTRA_DEJAGNU_SITE_CONFIG) are not distributed
  126. # by default.
  127. $MAKE distdir
  128. ls -l $distdir
  129. test ! -e $distdir/bar.dir/bar
  130. test ! -e $distdir/quux.exp
  131. :