1 |
12 |
jlechner |
#!/bin/sh
|
2 |
|
|
|
3 |
|
|
# Test GCC.
|
4 |
|
|
# Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
|
5 |
|
|
|
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.
|
10 |
|
|
|
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.
|
15 |
|
|
|
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
|
19 |
|
|
|
20 |
|
|
# INPUT:
|
21 |
|
|
# btest <options> <target> <source> <prefix> <state> <build>
|
22 |
|
|
|
23 |
|
|
add_passes_despite_regression=0
|
24 |
|
|
|
25 |
|
|
# <options> can be
|
26 |
|
|
# --add-passes-despite-regression:
|
27 |
|
|
# Add new "PASSes" despite there being some regressions.
|
28 |
|
|
|
29 |
|
|
case "$1" in
|
30 |
|
|
--add-passes-despite-regression)
|
31 |
|
|
add_passes_despite_regression=1; shift;;
|
32 |
|
|
--*) echo "Invalid option: $1"; exit 2;;
|
33 |
|
|
esac
|
34 |
|
|
|
35 |
|
|
# TARGET is the target triplet. It should be the same one as used in
|
36 |
|
|
# constructing PREFIX. Or it can be the keyword 'native', indicating
|
37 |
|
|
# a target of whatever platform the script is running on.
|
38 |
|
|
TARGET=$1
|
39 |
|
|
# SOURCE is the directory containing the toplevel configure.
|
40 |
|
|
SOURCE=$2
|
41 |
|
|
|
42 |
|
|
# PREFIX is the directory for the --prefix option to configure.
|
43 |
|
|
# For cross compilers, it needs to contain header files,
|
44 |
|
|
# libraries, and binutils. PATH should probably include
|
45 |
|
|
# $PREFIX/bin.
|
46 |
|
|
PREFIX=$3
|
47 |
|
|
# This script also needs to include the GDB testsuite in
|
48 |
|
|
# $PREFIX/share/gdb-testsuite.
|
49 |
|
|
GDB_TESTSUITE=$PREFIX/share/gdb-testsuite
|
50 |
|
|
|
51 |
|
|
# STATE is where the tester maintains its internal state,
|
52 |
|
|
# described below.
|
53 |
|
|
STATE=$4
|
54 |
|
|
|
55 |
|
|
# BUILD is a temporary directory that this script will
|
56 |
|
|
# delete and recreate, containing the build tree.
|
57 |
|
|
BUILD=$5
|
58 |
|
|
|
59 |
|
|
# you also probably need to set these variables:
|
60 |
|
|
# PATH: should contain a native gcc, and a cross gdb.
|
61 |
|
|
# DEJAGNU: should point to a site.exp suitable for testing
|
62 |
|
|
# the compiler and debugger.
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
# OUTPUT: in $RESULT, one of the following keywords:
|
66 |
|
|
# error the script failed due to
|
67 |
|
|
# a misconfiguration or resource limitation
|
68 |
|
|
# build the build failed
|
69 |
|
|
# regress-<n> the build succeeded, but there were <n>
|
70 |
|
|
# testsuite regressions, listed in $REGRESS
|
71 |
|
|
# pass build succeeded and there were no regressions
|
72 |
|
|
RESULT=$STATE/RESULT
|
73 |
|
|
# in BUILD_LOG, the output of the build
|
74 |
|
|
BUILD_LOG=$STATE/build_log
|
75 |
|
|
# in FAILED, a list of failing testcases
|
76 |
|
|
FAILED=$STATE/failed
|
77 |
|
|
# in PASSES, the list of testcases we expect to pass
|
78 |
|
|
PASSES=$STATE/passes
|
79 |
|
|
# in REGRESS, a list of testcases we expected to pass but that failed
|
80 |
|
|
REGRESS=$STATE/regress
|
81 |
|
|
|
82 |
|
|
# Make sure various files exist.
|
83 |
|
|
[ -d $STATE ] || mkdir $STATE
|
84 |
|
|
[ -f $PASSES ] || touch $PASSES
|
85 |
|
|
|
86 |
|
|
# These lines should stay in this order, because
|
87 |
|
|
# that way if something is badly wrong and $RESULT can't
|
88 |
|
|
# be modified then cron will mail the error message.
|
89 |
|
|
# The reverse order could lead to the testsuite claiming that
|
90 |
|
|
# everything always passes, without running any tests.
|
91 |
|
|
echo error > $RESULT || exit 1
|
92 |
|
|
exec > $BUILD_LOG 2>&1 || exit 1
|
93 |
|
|
|
94 |
|
|
set -x
|
95 |
|
|
|
96 |
|
|
# Nuke $BUILD and recreate it.
|
97 |
|
|
rm -rf $BUILD $REGRESS $FAILED
|
98 |
|
|
mkdir $BUILD || exit 1
|
99 |
|
|
cd $BUILD || exit 1
|
100 |
|
|
|
101 |
|
|
H_BUILD=`$SOURCE/config.guess || exit 1`
|
102 |
|
|
H_HOST=$H_BUILD
|
103 |
|
|
if [ $TARGET = native ] ; then
|
104 |
|
|
H_TARGET=$H_HOST
|
105 |
|
|
else
|
106 |
|
|
H_TARGET=$TARGET
|
107 |
|
|
fi
|
108 |
|
|
H_REAL_TARGET=`$SOURCE/config.sub $H_TARGET || exit 1`
|
109 |
|
|
|
110 |
|
|
# TESTLOGS is the list of dejagnu .sum files that the tester should
|
111 |
|
|
# look at.
|
112 |
|
|
TESTLOGS="gcc/testsuite/gcc/gcc.sum
|
113 |
|
|
gcc/testsuite/g++/g++.sum
|
114 |
|
|
gcc/testsuite/objc/objc.sum"
|
115 |
|
|
|
116 |
|
|
# Build.
|
117 |
|
|
echo build > $RESULT
|
118 |
|
|
if [ $H_HOST = $H_TARGET ] ; then
|
119 |
|
|
$SOURCE/configure --prefix=$PREFIX --target=$H_TARGET || exit 1
|
120 |
|
|
if ! make bootstrap ; then
|
121 |
|
|
[ -s gcc/.bad_compare ] || exit 1
|
122 |
|
|
cat gcc/.bad_compare >> $REGRESS || exit 1
|
123 |
|
|
make all || exit 1
|
124 |
|
|
fi
|
125 |
|
|
else
|
126 |
|
|
withopt="--with-gnu-ld --with-gnu-as"
|
127 |
|
|
case "$H_TARGET" in
|
128 |
|
|
*-linux*) ;;
|
129 |
|
|
*) withopt="$withopt --with-newlib";;
|
130 |
|
|
esac
|
131 |
|
|
$SOURCE/configure --prefix=$PREFIX --target=$H_TARGET $withopt || exit 1
|
132 |
|
|
make || exit 1
|
133 |
|
|
fi
|
134 |
|
|
echo error > $RESULT || exit 1
|
135 |
|
|
|
136 |
|
|
# Test GCC against its internal testsuite.
|
137 |
|
|
make -k check-gcc
|
138 |
|
|
|
139 |
|
|
# Test libstd++-v3
|
140 |
|
|
make check-target-libstdc++-v3
|
141 |
|
|
if [ -f $BUILD/$H_TARGET/libstdc++-v3/testsuite/libstdc++.sum ] ; then
|
142 |
|
|
TESTLOGS="$TESTLOGS $H_TARGET/libstdc++-v3/testsuite/libstdc++.sum"
|
143 |
|
|
fi
|
144 |
|
|
|
145 |
|
|
# Test libffi
|
146 |
|
|
make check-target-libffi
|
147 |
|
|
if [ -f $BUILD/$H_TARGET/libffi/testsuite/libffi.sum ] ; then
|
148 |
|
|
TESTLOGS="$TESTLOGS $H_TARGET/libffi/testsuite/libffi.sum"
|
149 |
|
|
fi
|
150 |
|
|
|
151 |
|
|
# Test libjava
|
152 |
|
|
make check-target-libjava
|
153 |
|
|
if [ -f $BUILD/$H_TARGET/libjava/testsuite/libjava.sum ] ; then
|
154 |
|
|
TESTLOGS="$TESTLOGS $H_TARGET/libjava/testsuite/libjava.sum"
|
155 |
|
|
fi
|
156 |
|
|
|
157 |
|
|
# Test the just-built GCC with the GDB testsuite.
|
158 |
|
|
if [ -d $GDB_TESTSUITE ] ; then
|
159 |
|
|
mkdir test-gdb || exit 1
|
160 |
|
|
cd $GDB_TESTSUITE || exit 1
|
161 |
|
|
for i in gdb.* ; do
|
162 |
|
|
if [ -d $i ] ; then
|
163 |
|
|
mkdir $BUILD/test-gdb/$i
|
164 |
|
|
fi
|
165 |
|
|
done
|
166 |
|
|
cd $BUILD/test-gdb || exit 1
|
167 |
|
|
echo "set host_alias $H_HOST" > site.exp
|
168 |
|
|
echo "set host_triplet $H_HOST" >> site.exp
|
169 |
|
|
echo "set target_alias $H_TARGET" >> site.exp
|
170 |
|
|
echo "set target_triplet $H_REAL_TARGET" >> site.exp
|
171 |
|
|
echo "set build_alias $H_BUILD" >> site.exp
|
172 |
|
|
echo "set build_triplet $H_BUILD" >> site.exp
|
173 |
|
|
echo "set srcdir $GDB_TESTSUITE" >> site.exp
|
174 |
|
|
runtest --tool gdb
|
175 |
|
|
TESTLOGS="$TESTLOGS test-gdb/gdb.sum"
|
176 |
|
|
fi
|
177 |
|
|
|
178 |
|
|
# Sanity-check the testlogs. They should contain at least one PASS.
|
179 |
|
|
cd $BUILD || exit 1
|
180 |
|
|
for LOG in $TESTLOGS ; do
|
181 |
|
|
if ! grep ^PASS: $LOG > /dev/null ; then
|
182 |
|
|
echo build > $RESULT
|
183 |
|
|
exit 1
|
184 |
|
|
fi
|
185 |
|
|
done
|
186 |
|
|
|
187 |
|
|
# Work out what failed
|
188 |
|
|
for LOG in $TESTLOGS ; do
|
189 |
|
|
L=`basename $LOG`
|
190 |
|
|
awk '/^FAIL: / { print "'$L'",$2; }' $LOG || exit 1
|
191 |
|
|
done | sort | uniq > $FAILED || exit 1
|
192 |
|
|
comm -12 $FAILED $PASSES >> $REGRESS || exit 1
|
193 |
|
|
NUMREGRESS=`wc -l < $REGRESS | tr -d ' '`
|
194 |
|
|
|
195 |
|
|
if [ $NUMREGRESS -eq 0 ] || [ $add_passes_despite_regression -ne 0 ] ; then
|
196 |
|
|
# Update the state.
|
197 |
|
|
for LOG in $TESTLOGS ; do
|
198 |
|
|
L=`basename $LOG`
|
199 |
|
|
awk '/^PASS: / { print "'$L'",$2; }' $LOG || exit 1
|
200 |
|
|
done | sort | uniq | comm -23 - $FAILED > ${PASSES}~ || exit 1
|
201 |
|
|
[ -s ${PASSES}~ ] || exit 1
|
202 |
|
|
if [ $NUMREGRESS -ne 0 ] ; then
|
203 |
|
|
# The way we keep track of new PASSes when in "regress-N" for
|
204 |
|
|
# --add-passes-despite-regression, is to *add* them to previous
|
205 |
|
|
# PASSes. Just as without this option, we don't forget *any* PASS
|
206 |
|
|
# lines, because besides the ones in $REGRESS that we definitely
|
207 |
|
|
# don't want to lose, their removal or rename may have been a
|
208 |
|
|
# mistake (as in, the cause of the "regress-N" state). If they
|
209 |
|
|
# come back, we then know they're regressions.
|
210 |
|
|
cat ${PASSES}~ ${PASSES} | sort -u > ${PASSES}~~
|
211 |
|
|
mv ${PASSES}~~ ${PASSES} || exit 1
|
212 |
|
|
rm ${PASSES}~ || exit 1
|
213 |
|
|
else
|
214 |
|
|
# In contrast to the merging for "regress-N", we just overwrite
|
215 |
|
|
# the known PASSes when in the "pass" state, so we get rid of
|
216 |
|
|
# stale PASS lines for removed, moved or otherwise changed tests
|
217 |
|
|
# which may be added back with a different meaning later on.
|
218 |
|
|
mv ${PASSES}~ ${PASSES} || exit 1
|
219 |
|
|
fi
|
220 |
|
|
fi
|
221 |
|
|
|
222 |
|
|
if [ $NUMREGRESS -ne 0 ] ; then
|
223 |
|
|
echo regress-$NUMREGRESS > $RESULT
|
224 |
|
|
exit 1
|
225 |
|
|
fi
|
226 |
|
|
|
227 |
|
|
echo pass > $RESULT
|
228 |
|
|
exit 0
|