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