tests: fix a timestamp-related spurious failures
[automake.git] / tests / cond5.test
blob50101a6fe59e97fbf759912ecd83b20e1055616d
1 #! /bin/sh
2 # Copyright (C) 1998, 1999, 2001, 2002, 2010 Free Software Foundation,
3 # Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Yet another sources-in-conditional test. Report from Tim Goodwin.
20 . ./defs || Exit 1
22 set -e
24 cat >> configure.in << 'END'
25 AC_PROG_CC
26 AM_CONDITIONAL([ONE], [true])
27 AM_CONDITIONAL([TWO], [false])
28 AC_OUTPUT
29 END
31 cat > Makefile.am << 'END'
32 bin_PROGRAMS = targ
34 if ONE
35 OPT_SRC = one.c
36 endif
38 if TWO
39 OPT_SRC = $(OPT_SRC) two.c
40 endif
42 targ_SOURCES = main.c $(OPT_SRC)
43 END
45 # The bug is that automake hangs. So we give it an appropriate grace
46 # time, then kill it if necessary.
47 $ACLOCAL
48 $AUTOMAKE 2>stderr &
49 pid=$!
51 # MSYS bash seems to have a bug in kill, so don't try to kill too soon;
52 # and avoid maintainer-check test.
53 sleep '2'
55 # Make at most 30 tries, one every 10 seconds (= 300 seconds = 5 min).
56 try=1
57 while test $try -le 30; do
58 if kill -0 $pid; then
59 : process $pid is still alive, wait and retry
60 sleep '10'
61 try=`expr $try + 1`
62 else
63 cat stderr >&2
64 # Automake must fail with a proper error message.
65 grep 'variable.*OPT_SRC.*recursively defined' stderr
66 Exit 0
68 done
69 # The automake process probably hung. Kill it, and exit with failure.
70 echo "$me: automake process $pid hung"
71 kill $pid
72 Exit 1