2 # Copyright (C) 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)
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 that the parallel-tests harness does not hit errors due to
18 # an exceeded command line length when there are many tests.
19 # For automake bug#7868. This test is currently expected to fail.
24 cat >> configure.ac << 'END'
28 cat > Makefile.am <<'END'
29 # Sanity check that the $(TESTS) is going to exceed the system
30 # command line length.
31 # Extra quoting and indirections below are required to ensure the
32 # various make implementations (e.g, GNU make or Sun Distributed Make)
33 # will truly spawn a shell to execute this command, instead of relying
34 # on optimizations that might mask the "Argument list too long" error
37 @":" && ":" $(TEST_LOGS)
38 TEST_LOG_COMPILER = true
39 include list-of-tests.am
40 # So that we won't have to create a ton of dummy test cases.
44 # The real instance will be dynamically created later.
45 echo TESTS = foo.test > list-of-tests.am
47 $ACLOCAL && $AUTOCONF && $AUTOMAKE -a \
48 || framework_failure_ "unexpected autotools failure"
50 || framework_failure_ "unexpected configure failure"
52 # We want to hit the system command-line length limit without hitting
53 # the filename length limit or the PATHMAX limit; so we use longish
54 # (but not too long) names for the testcase, and place them in a nested
55 # (but not too deeply) directory.
56 # We also prefer to use the minimal(ish) number of test cases that can
57 # make us hit the command-line length limit, since the more the test
58 # cases are, the more time "automake" and "make check" will take to run
59 # (especially on Cygwin and MinGW/MSYS).
61 tname="wow-this-is-a-very-long-name-for-a-simple-dummy-test-case"
62 dname="and-this-too-is-a-very-long-name-for-a-dummy-directory"
66 for i in 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 29 21 22 23 24; do
67 new_deepdir=$deepdir/$dname.d$i
68 mkdir $new_deepdir || break
69 tmpfile=$new_deepdir/$tname-some-more-chars-for-good-measure
70 if touch $tmpfile; then
71 rm -f $tmpfile || Exit 99
73 rmdir $new_deepdir || Exit 99
76 unset tmpfile new_deepdir
81 *********************************************************************
82 Our tests will be in the following directory (depth = $depth)
83 *********************************************************************
85 *********************************************************************
90 # Use perl, not awk, to avoid errors like "awk: string too long"
91 # (seen e.g. with Solaris 10 /usr/bin/awk).
92 count=$count deepdir=$deepdir tname=$tname $PERL -e '
93 use warnings FATAL => "all";
99 print " $ENV{deepdir}/$ENV{tname}-$i.test";
100 if ($i >= $ENV{count})
110 ' > list-of-tests.am || Exit 99
111 sed 20q list-of-tests.am || Exit 99 # For debugging.
113 || framework_failure_ "unexpected automake failure"
114 ./config.status Makefile \
115 || framework_failure_ "unexpected config.status failure"
118 for count in 1 2 4 8 12 16 20 24 28 32 48 64 96 128 E_HUGE; do
119 test $count = E_HUGE && break
120 count=`expr $count '*' 100` || Exit 99
122 if $MAKE this-will-fail; then
125 # We have managed to find a number of test cases large enough to
126 # hit the system command-line limits; we can stop. But first, for
127 # good measure, increase the number of tests of some 20%, to be
128 # "even more sure" of really tickling command line length limits.
129 count=`expr '(' $count '*' 12 ')' / 10` || Exit 99
135 if test $count = E_HUGE; then
136 framework_failure_ "system has a too-high limit on command line length"
139 *********************************************************************
140 Number of tests we will use: $count
141 *********************************************************************
145 env TESTS=$deepdir/$tname-1.test $MAKE -e check \
146 && test -f $deepdir/$tname-1.log \
147 || framework_failure_ "\"make check\" with one single tests"
149 rm -f $deepdir/* || Exit 99
151 $MAKE check > stdout || { cat stdout; Exit 1; }
154 grep "^# TOTAL: $count$" stdout
155 grep "^# PASS: $count$" stdout
157 grep "^PASS: .*$tname-[0-9][0-9]*\.test" stdout > grp
158 ls -1 $deepdir | grep '\.log$' > lst
160 sed 20q lst # For debugging.
161 sed 20q grp # Likewise.
163 test `cat <grp | wc -l` -eq $count
164 test `cat <lst | wc -l` -eq $count
166 # We need to simulate a failure of two tests.
168 env TESTS="$deepdir/$tname-1.test $deepdir/$tname-2.test" \
169 TEST_LOG_COMPILER=false $MAKE -e check > stdout && st=1
171 test `grep -c '^FAIL:' stdout` -eq 2 || st=1
172 test $st -eq 0 || fatal_ "couldn't simulate failure of two tests"
175 $MAKE recheck > stdout || { cat stdout; Exit 1; }
177 grep "^PASS: .*$tname-1\.test" stdout
178 grep "^PASS: .*$tname-2\.test" stdout
179 test `LC_ALL=C grep -c "^[A-Z][A-Z]*:" stdout` -eq 2
180 grep "^# TOTAL: 2$" stdout
181 grep "^# PASS: 2$" stdout
183 # "make clean" might ignore some failures, so we prefer to also grep its
184 # output to ensure that no "Argument list too long" error was encountered.
185 $MAKE clean >output 2>&1 || { cat output; Exit 1; }
187 grep -i 'list.* too long' output && Exit 1
188 ls $deepdir | grep '\.log$' && Exit 1