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