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