4 # Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 # btest <options> <target> <source> <prefix> <state> <build>
23 add_passes_despite_regression
=0
27 # --add-passes-despite-regression:
28 # Add new "PASSes" despite there being some regressions.
30 # Pass '-j<n>' to make.
33 --add-passes-despite-regression)
34 add_passes_despite_regression
=1; shift;;
37 -*) echo "Invalid option: $1"; exit 2;;
40 # TARGET is the target triplet. It should be the same one as used in
41 # constructing PREFIX. Or it can be the keyword 'native', indicating
42 # a target of whatever platform the script is running on.
44 # SOURCE is the directory containing the toplevel configure.
47 # PREFIX is the directory for the --prefix option to configure.
48 # For cross compilers, it needs to contain header files,
49 # libraries, and binutils. PATH should probably include
52 # This script also needs to include the GDB testsuite in
53 # $PREFIX/share/gdb-testsuite.
54 GDB_TESTSUITE
=$PREFIX/share
/gdb-testsuite
56 # STATE is where the tester maintains its internal state,
60 # BUILD is a temporary directory that this script will
61 # delete and recreate, containing the build tree.
64 # you also probably need to set these variables:
65 # PATH: should contain a native gcc, and a cross gdb.
66 # DEJAGNU: should point to a site.exp suitable for testing
67 # the compiler and debugger.
70 # OUTPUT: in $RESULT, one of the following keywords:
71 # error the script failed due to
72 # a misconfiguration or resource limitation
73 # build the build failed
74 # regress-<n> the build succeeded, but there were <n>
75 # testsuite regressions, listed in $REGRESS
76 # pass build succeeded and there were no regressions
78 # in BUILD_LOG, the output of the build
79 BUILD_LOG
=$STATE/build_log
80 # in FAILED, a list of failing testcases
82 # in PASSES, the list of testcases we expect to pass
84 # in REGRESS, a list of testcases we expected to pass but that failed
85 REGRESS
=$STATE/regress
87 # Make sure various files exist.
88 [ -d $STATE ] || mkdir
$STATE
89 [ -f $PASSES ] ||
touch $PASSES
91 # These lines should stay in this order, because
92 # that way if something is badly wrong and $RESULT can't
93 # be modified then cron will mail the error message.
94 # The reverse order could lead to the testsuite claiming that
95 # everything always passes, without running any tests.
96 echo error
> $RESULT ||
exit 1
97 exec > $BUILD_LOG 2>&1 ||
exit 1
101 # Nuke $BUILD and recreate it.
102 rm -rf $BUILD $REGRESS $FAILED
103 mkdir
$BUILD ||
exit 1
106 H_BUILD
=`$SOURCE/config.guess || exit 1`
108 if [ $TARGET = native
] ; then
113 H_REAL_TARGET
=`$SOURCE/config.sub $H_TARGET || exit 1`
115 # TESTLOGS is the list of dejagnu .sum files that the tester should
117 TESTLOGS
="gcc/testsuite/gcc/gcc.sum
118 gcc/testsuite/g++/g++.sum
119 gcc/testsuite/objc/objc.sum"
123 if [ $H_HOST = $H_TARGET ] ; then
124 $SOURCE/configure
--prefix=$PREFIX --target=$H_TARGET ||
exit 1
125 if ! make $dashj bootstrap
; then
126 [ -s .bad_compare
] ||
exit 1
127 cat .bad_compare
>> $REGRESS ||
exit 1
128 make $dashj all ||
exit 1
131 withopt
="--with-gnu-ld --with-gnu-as"
134 *) withopt
="$withopt --with-newlib";;
136 $SOURCE/configure
--prefix=$PREFIX --target=$H_TARGET $withopt ||
exit 1
137 make $dashj ||
exit 1
139 echo error
> $RESULT ||
exit 1
141 # Test GCC against its internal testsuite.
144 if [ -f $BUILD/$H_TARGET/libstdc
++-v3/testsuite
/libstdc
++.
sum ] ; then
145 TESTLOGS
="$TESTLOGS $H_TARGET/libstdc++-v3/testsuite/libstdc++.sum"
148 if [ -f $BUILD/$H_TARGET/libffi
/testsuite
/libffi.
sum ] ; then
149 TESTLOGS
="$TESTLOGS $H_TARGET/libffi/testsuite/libffi.sum"
152 if [ -f $BUILD/$H_TARGET/libjava
/testsuite
/libjava.
sum ] ; then
153 TESTLOGS
="$TESTLOGS $H_TARGET/libjava/testsuite/libjava.sum"
156 # Test the just-built GCC with the GDB testsuite.
157 if [ -d $GDB_TESTSUITE ] ; then
158 mkdir test-gdb ||
exit 1
159 cd $GDB_TESTSUITE ||
exit 1
162 mkdir
$BUILD/test-gdb
/$i
165 cd $BUILD/test-gdb ||
exit 1
166 echo "set host_alias $H_HOST" > site.exp
167 echo "set host_triplet $H_HOST" >> site.exp
168 echo "set target_alias $H_TARGET" >> site.exp
169 echo "set target_triplet $H_REAL_TARGET" >> site.exp
170 echo "set build_alias $H_BUILD" >> site.exp
171 echo "set build_triplet $H_BUILD" >> site.exp
172 echo "set srcdir $GDB_TESTSUITE" >> site.exp
174 TESTLOGS
="$TESTLOGS test-gdb/gdb.sum"
177 # Sanity-check the testlogs. They should contain at least one PASS.
179 for LOG
in $TESTLOGS ; do
180 if ! grep ^PASS
: $LOG > /dev
/null
; then
186 # Work out what failed
187 for LOG
in $TESTLOGS ; do
189 awk '/^FAIL: / { print "'$L'",$2; }' $LOG ||
exit 1
190 done |
sort |
uniq > $FAILED ||
exit 1
191 comm -12 $FAILED $PASSES >> $REGRESS ||
exit 1
192 NUMREGRESS
=`wc -l < $REGRESS | tr -d ' '`
194 if [ $NUMREGRESS -eq 0 ] ||
[ $add_passes_despite_regression -ne 0 ] ; then
196 for LOG
in $TESTLOGS ; do
198 awk '/^PASS: / { print "'$L'",$2; }' $LOG ||
exit 1
199 done |
sort |
uniq |
comm -23 - $FAILED > ${PASSES}~ ||
exit 1
200 [ -s ${PASSES}~
] ||
exit 1
201 if [ $NUMREGRESS -ne 0 ] ; then
202 # The way we keep track of new PASSes when in "regress-N" for
203 # --add-passes-despite-regression, is to *add* them to previous
204 # PASSes. Just as without this option, we don't forget *any* PASS
205 # lines, because besides the ones in $REGRESS that we definitely
206 # don't want to lose, their removal or rename may have been a
207 # mistake (as in, the cause of the "regress-N" state). If they
208 # come back, we then know they're regressions.
209 cat ${PASSES}~ ${PASSES} | sort -u > ${PASSES}~~
210 mv ${PASSES}~~
${PASSES} ||
exit 1
211 rm ${PASSES}~ ||
exit 1
213 # In contrast to the merging for "regress-N", we just overwrite
214 # the known PASSes when in the "pass" state, so we get rid of
215 # stale PASS lines for removed, moved or otherwise changed tests
216 # which may be added back with a different meaning later on.
217 mv ${PASSES}~
${PASSES} ||
exit 1
221 if [ $NUMREGRESS -ne 0 ] ; then
222 echo regress-
$NUMREGRESS > $RESULT