1#! /bin/sh
2# Copyright (C) 2008-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 @substituted@ TESTS, some of which are also PROGRAMS.
18# See also sister test 'check-subst.sh'.
19
20# For gen-testsuite-part: ==> try-with-serial-tests <==
21required='cc native'
22. test-init.sh
23
24cat >> configure.ac << 'END'
25AC_PROG_CC
26AC_SUBST([script_tests],
27         ['subst-pass-script.test subst-xfail-script.test'])
28AC_SUBST([prog_tests],
29         ['subst-pass-prog.test$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
30AC_SUBST([xfail_tests],
31         ['xfail-script.test subst-xfail-script.test]dnl
32         [ xfail-prog$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
33AC_OUTPUT
34END
35
36cat > Makefile.am << 'END'
37TESTS = pass-script.test xfail-script.test @script_tests@ $(check_PROGRAMS)
38XFAIL_TESTS = @xfail_tests@
39check_PROGRAMS = pass-prog xfail-prog @prog_tests@
40EXTRA_PROGRAMS = subst-pass-prog.test subst-xfail-prog.test
41END
42
43cat > pass-script.test <<'END'
44#! /bin/sh
45exit 0
46END
47cat > xfail-script.test <<'END'
48#! /bin/sh
49exit 1
50END
51chmod a+x pass-script.test xfail-script.test
52cp pass-script.test subst-pass-script.test
53cp xfail-script.test subst-xfail-script.test
54
55cat > pass-prog.c <<'END'
56int main (void) { return 0; }
57END
58cat > xfail-prog.c <<'END'
59#include <stdlib.h>
60int main (void) { return EXIT_FAILURE; }
61END
62# The .test extension is removed for the default source file name:
63cp pass-prog.c subst-pass-prog.c
64cp xfail-prog.c subst-xfail-prog.c
65
66$ACLOCAL
67$AUTOCONF
68$AUTOMAKE -a
69
70./configure
71$MAKE all
72$MAKE check
73$MAKE distclean
74
75mkdir build
76cd build
77../configure
78$MAKE all
79$MAKE check
80$MAKE distclean
81
82:
83