tests: expose automake bug#14560
[platform/upstream/automake.git] / t / check-subst-prog.sh
1 #! /bin/sh
2 # Copyright (C) 2008-2013 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
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 <==
21 required='cc native'
22 . test-init.sh
23
24 cat >> configure.ac << 'END'
25 AC_PROG_CC
26 AC_SUBST([script_tests],
27          ['subst-pass-script.test subst-xfail-script.test'])
28 AC_SUBST([prog_tests],
29          ['subst-pass-prog.test$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
30 AC_SUBST([xfail_tests],
31          ['xfail-script.test subst-xfail-script.test]dnl
32          [ xfail-prog$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
33 AC_OUTPUT
34 END
35
36 cat > Makefile.am << 'END'
37 TESTS = pass-script.test xfail-script.test @script_tests@ $(check_PROGRAMS)
38 XFAIL_TESTS = @xfail_tests@
39 check_PROGRAMS = pass-prog xfail-prog @prog_tests@
40 EXTRA_PROGRAMS = subst-pass-prog.test subst-xfail-prog.test
41 END
42
43 cat > pass-script.test <<'END'
44 #! /bin/sh
45 exit 0
46 END
47 cat > xfail-script.test <<'END'
48 #! /bin/sh
49 exit 1
50 END
51 chmod a+x pass-script.test xfail-script.test
52 cp pass-script.test subst-pass-script.test
53 cp xfail-script.test subst-xfail-script.test
54
55 cat > pass-prog.c <<'END'
56 int main (void) { return 0; }
57 END
58 cat > xfail-prog.c <<'END'
59 #include <stdlib.h>
60 int main (void) { return EXIT_FAILURE; }
61 END
62 # The .test extension is removed for the default source file name:
63 cp pass-prog.c subst-pass-prog.c
64 cp 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
75 mkdir build
76 cd build
77 ../configure
78 $MAKE all
79 $MAKE check
80 $MAKE distclean
81
82 :