Merge branch 'msvc'
[platform/upstream/automake.git] / tests / parallel-am.test
1 #! /bin/sh
2 # Copyright (C) 2008, 2009  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 # Test parallel automake execution.
18
19 # There are several hypotheses to be tested:  Independently of the number
20 # of threads used by automake,
21 # 0) the generated Makefile.in files must be identical without --add-missing,
22 # 1) the Makefile.in that distributes auxiliary files must be generated
23 #    after all other ones, so all installed aux files are caught,
24 # 2) normal automake output should have identical content and be ordered
25 #    in the same way, when --add-missing is not passed, or when
26 #    --add-missing is passed but there are no concurrent file requirements
27 #    (i.e., two Makefile.am files call for the same needed aux file)
28 # 3) normal automake output should be identical and ordered in the same way
29 #    with --add-missing, even with concurrent file requirements, and the
30 #    installation of aux files should be race-free,
31 # 4) warning and normal error output should be identical, in that duplicate
32 #    warnings should be omitted in the same way as without threads,
33 # 5) fatal error and debug messages could be identical.  This is not
34 #    intended, though.
35 #
36 # This test checks (0), (1), and (2).  See sister tests for further coverage.
37
38 required=perl-threads
39 . ./defs || Exit 1
40
41 set -e
42
43 cat > configure.in << 'END'
44 AC_INIT([parallel-am], [1.0])
45 AC_CONFIG_AUX_DIR([build-aux])
46 AM_INIT_AUTOMAKE
47 AC_PROG_CC
48 AM_PATH_LISPDIR
49 AM_PATH_PYTHON
50 AC_CONFIG_FILES([Makefile])
51 END
52
53 cat > Makefile.am << 'END'
54 SUBDIRS =
55 END
56
57 list='1 2 3 4 5 6 7 8 9'
58 for i in $list; do
59   echo "AC_CONFIG_FILES([sub$i/Makefile])" >> configure.in
60   echo "SUBDIRS += sub$i" >> Makefile.am
61   mkdir sub$i
62   echo > sub$i/Makefile.am
63 done
64 # Use an include chain to cause a nontrivial location object to be
65 # serialized through a thread queue.
66 echo 'include foo.am' >> sub7/Makefile.am
67 echo 'include bar.am' > sub7/foo.am
68 echo 'python_PYTHON = foo.py' > sub7/bar.am
69 echo 'lisp_LISP = foo.el' >> sub8/Makefile.am
70 echo 'bin_PROGRAMS = p' >> sub9/Makefile.am
71
72 rm -f install-sh missing depcomp
73 mkdir build-aux
74
75 $ACLOCAL
76
77 # This test may have to be run several times in order to expose the
78 # race that, when the last Makefile.in (the toplevel one) is created
79 # before the other ones have finished, not all auxiliary files may
80 # be installed yet, thus some may not be distributed.
81 #
82 # Further, automake output should be stable.
83
84 # Generate expected output using the non-threaded code.
85 unset AUTOMAKE_JOBS || :
86 AUTOMAKE_run 0 --add-missing
87 mv stderr expected
88 Makefile_ins=`find . -name Makefile.in`
89 for file in $Makefile_ins; do
90   mv $file $file.exp
91 done
92
93 AUTOMAKE_JOBS=5
94 export AUTOMAKE_JOBS
95
96 for run in 1 2 3 4 5 6 7; do
97   rm -f build-aux/* sub*/Makefile.in
98   AUTOMAKE_run 0 --add-missing
99   diff stderr expected
100   for file in $Makefile_ins; do
101     diff $file $file.exp
102   done
103 done
104
105 :