news: update w.r.t. recent depcomp changes
[automake.git] / t / parallel-tests-concurrency.sh
blob702572d9d1a864a66ef42497c223a436213fe0c2
1 #! /bin/sh
2 # Copyright (C) 2009-2012 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 <http://www.gnu.org/licenses/>.
17 # Check parallel-tests features:
18 # - concurrent parallel execution
20 . test-init.sh
22 case $MAKE in
23 *\ -j*) skip_ "\$MAKE contains '-j'";;
24 esac
26 if using_gmake; then
27 j=-j
28 else
29 unindent > Makefile <<END
30 all: one two
31 one:
32 $sleep && test -f two
33 two:
34 echo ok > \$@
35 END
36 for j in "-j" "-j " NONE; do
37 if test x"$j" = xNONE; then
38 skip_ "can't run make in parallel mode"
40 $MAKE ${j}2 all >output 2>&1 || continue
41 $EGREP -i "(warning|error):|-j[\"\'\` ]" output && continue
42 break
43 done
44 rm -f one output Makefile
47 cat >> configure.ac << 'END'
48 AC_OUTPUT
49 END
51 cat > Makefile.am << 'END'
52 TESTS =
53 END
55 cat > x <<'END'
56 #! /bin/sh
57 echo "this is $0"
58 # Creative quoting below to please maintainer-check.
59 sleep '1'
60 exit 0
61 END
62 chmod a+x ./x
64 mkdir sub
65 for i in 1 2 3; do
66 echo "TESTS += foo$i.test" >> Makefile.am
67 cp x foo$i.test
68 echo "TESTS += zap$i" >> Makefile.am
69 cp x zap$i
70 echo "TESTS += sub/bar$i.test" >> Makefile.am
71 cp x sub/bar$i.test
72 echo "TESTS += sub/mu$i" >> Makefile.am
73 cp x sub/mu$i
74 done
76 $ACLOCAL
77 $AUTOCONF
78 $AUTOMAKE -a
80 for build in serial parallel; do
81 mkdir $build
82 cd $build
83 ../configure
84 $MAKE
85 cd ..
86 done
88 cd serial
89 $MAKE ${j}1 check &
90 cd ../parallel
91 $sleep
92 # Use append mode here to avoid dropping output. See automake bug#11413.
93 : > stdout
94 $MAKE ${j}4 check >> stdout
95 cd ..
96 # Ensure the tests are really being run in parallel mode: if this is
97 # the case, the serial run of the dummy testsuite started above should
98 # still be ongoing when the parallel one has terminated.
99 kill -0 $!
100 cat parallel/stdout
101 test $(grep -c '^PASS:' parallel/stdout) -eq 12
103 # Wait long enough so that there are no open files any more when the
104 # post-test cleanup runs. But exit after we've waited for two minutes
105 # or more, to avoid testsuite hangs in unusual situations (this has
106 # already happened).
108 while test ! -f serial/test-suite.log && test $i -le 120; do
109 i=$(($i + 1))
110 sleep '1' # Extra quoting to please maintainer-check.
111 done
112 $sleep