test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / test-driver-custom.sh
blob0bb29d3b673b00bb74f847a5e585b8e7ebe15735
1 #! /bin/sh
2 # Copyright (C) 2011-2024 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Custom test drivers: per-extension test drivers.
19 . test-init.sh
21 cat >> configure.ac << 'END'
22 AC_OUTPUT
23 END
25 cat > Makefile.am << 'END'
26 # Automake shouldn't match the '/test' in 'sub/test' as '.test' suffix.
27 TESTS = 1.chk 2.test 3 4.c.chk 5.suf sub/test
29 TEST_EXTENSIONS = .chk .test
31 CHK_LOG_DRIVER = ./chk-wrapper
32 TEST_LOG_DRIVER = $(SHELL) $(srcdir)/test-wrapper
33 LOG_DRIVER = noext-wrapper
35 AM_CHK_LOG_DRIVER_FLAGS = --am-chk
36 CHK_LOG_DRIVER_FLAGS = --chk
37 AM_TEST_LOG_DRIVER_FLAGS = -am-test
38 TEST_LOG_DRIVER_FLAGS = -test
39 AM_LOG_DRIVER_FLAGS = am
40 LOG_DRIVER_FLAGS = _
41 END
43 mkdir sub bin
44 PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
46 cat > wrapper.skel <<'END'
47 #! /bin/sh
48 set -e
50 me=`echo "$0" | sed 's,^.*/,,'`
51 if test -z "$me"; then
52 echo "$0: cannot determine program name" >&2
53 exit 99
56 am_log_wflags='@am_log_wflags@'
57 log_wflags='@log_wflags@'
59 test_name=INVALID
60 log_file=BAD.log
61 trs_file=BAD.trs
62 extra_opts=
63 while test $# -gt 0; do
64 case $1 in
65 --test-name) test_name=$2; shift;;
66 --log-file) log_file=$2; shift;;
67 --trs-file) trs_file=$2; shift;;
68 # Ignored.
69 --expect-failure) shift;;
70 --color-tests) shift;;
71 --enable-hard-errors) shift;;
72 # Remembered in the same order they're passed in.
73 $am_log_wflags|$log_wflags) extra_opts="$extra_opts $1";;
74 # Explicitly terminate option list.
75 --) shift; break;;
76 # Shouldn't happen
77 *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
78 esac
79 shift
80 done
82 echo "$me" "$test_name" $extra_opts > "$log_file"
83 : > "$trs_file"
85 exec "$@"
86 exit 127
87 END
89 sed -e 's|@am_log_wflags@|--am-chk|' \
90 -e 's|@log_wflags@|--chk|' \
91 < wrapper.skel > chk-wrapper
93 sed -e 's|@am_log_wflags@|-am-test|' \
94 -e 's|@log_wflags@|-test|' \
95 < wrapper.skel > test-wrapper
97 sed -e 's|@am_log_wflags@|am|' \
98 -e 's|@log_wflags@|_|' \
99 < wrapper.skel > bin/noext-wrapper
101 # 'test-wrapper' is deliberately not made executable.
102 chmod a+x chk-wrapper bin/noext-wrapper
104 # Not needed anymore.
105 rm -f wrapper.skel
107 cat > 1.chk << 'END'
108 #! /bin/sh
109 exit 0
111 chmod a+x 1.chk
112 cp 1.chk 2.test
113 cp 1.chk 3
114 cp 1.chk 4.c.chk
115 cp 1.chk 5.suf
116 cp 1.chk sub/test
118 $ACLOCAL
119 $AUTOCONF
120 $AUTOMAKE
122 ./configure
123 $MAKE
124 VERBOSE=yes $MAKE check
125 ls -l . sub
127 test ! -e BAD.log
128 test ! -e BAD.trs
130 echo 'chk-wrapper 1.chk --am-chk --chk' > 1.exp
131 echo 'test-wrapper 2.test -am-test -test' > 2.exp
132 echo 'noext-wrapper 3 am _' > 3.exp
133 echo 'chk-wrapper 4.c.chk --am-chk --chk' > 4.c.exp
134 echo 'noext-wrapper 5.suf am _' > 5.suf.exp
135 echo 'noext-wrapper sub/test am _' > sub/test.exp
137 st=0
138 for x in 1 2 3 4.c 5.suf sub/test; do
139 cat $x.log
140 diff $x.exp $x.log || st=1
141 done
143 exit $st