dg-extract-results.sh revision 1.1.1.5 1 1.1 mrg #! /bin/sh
2 1.1 mrg
3 1.1 mrg # For a specified tool and optional list of test variants, extract
4 1.1 mrg # test results from one or more test summary (.sum) files and combine
5 1.1 mrg # the results into a new test summary file, sent to the standard output.
6 1.1 mrg # The resulting file can be used with test result comparison scripts for
7 1.1 mrg # results from tests that were run in parallel. See usage() below.
8 1.1 mrg
9 1.1.1.2 mrg # Copyright (C) 2008, 2009, 2010, 2012 Free Software Foundation
10 1.1 mrg # Contributed by Janis Johnson <janis187 (at] us.ibm.com>
11 1.1 mrg #
12 1.1 mrg # This file is part of GCC.
13 1.1 mrg #
14 1.1 mrg # GCC is free software; you can redistribute it and/or modify
15 1.1 mrg # it under the terms of the GNU General Public License as published by
16 1.1 mrg # the Free Software Foundation; either version 3, or (at your option)
17 1.1 mrg # any later version.
18 1.1 mrg #
19 1.1 mrg # GCC is distributed in the hope that it will be useful,
20 1.1 mrg # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 1.1 mrg # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 1.1 mrg # GNU General Public License for more details.
23 1.1 mrg #
24 1.1 mrg # You should have received a copy of the GNU General Public License
25 1.1 mrg # along with GCC; see the file COPYING. If not, write to
26 1.1 mrg # the Free Software Foundation, 51 Franklin Street, Fifth Floor,
27 1.1 mrg # Boston, MA 02110-1301, USA.
28 1.1 mrg
29 1.1 mrg PROGNAME=dg-extract-results.sh
30 1.1 mrg
31 1.1.1.3 mrg # Try to use the python version if possible, since it tends to be faster.
32 1.1.1.3 mrg PYTHON_VER=`echo "$0" | sed 's/sh$/py/'`
33 1.1.1.3 mrg if test "$PYTHON_VER" != "$0" &&
34 1.1.1.3 mrg test -f "$PYTHON_VER" &&
35 1.1.1.3 mrg python -c 'import sys, getopt, re, io, datetime, operator; sys.exit (0 if sys.version_info >= (2, 6) else 1)' \
36 1.1.1.3 mrg > /dev/null 2> /dev/null; then
37 1.1.1.3 mrg exec python $PYTHON_VER "$@"
38 1.1.1.3 mrg fi
39 1.1.1.3 mrg
40 1.1 mrg usage() {
41 1.1 mrg cat <<EOF >&2
42 1.1 mrg Usage: $PROGNAME [-t tool] [-l variant-list] [-L] sum-file ...
43 1.1 mrg
44 1.1 mrg tool The tool (e.g. g++, libffi) for which to create a
45 1.1 mrg new test summary file. If not specified then all
46 1.1 mrg specified sum files must be for the same tool.
47 1.1 mrg variant-list One or more test variant names. If the list is
48 1.1 mrg not specified then one is constructed from all
49 1.1 mrg variants in the files for <tool>.
50 1.1 mrg sum-file A test summary file with the format of those
51 1.1 mrg created by runtest from DejaGnu.
52 1.1 mrg If -L is used, merge *.log files instead of *.sum. In this
53 1.1 mrg mode the exact order of lines may not be preserved, just different
54 1.1 mrg Running *.exp chunks should be in correct order.
55 1.1 mrg EOF
56 1.1 mrg }
57 1.1 mrg
58 1.1 mrg # Write a message to the standard error.
59 1.1 mrg
60 1.1 mrg msg() {
61 1.1 mrg echo "$@" >&2
62 1.1 mrg }
63 1.1 mrg
64 1.1 mrg # Parse the command-line options.
65 1.1 mrg
66 1.1 mrg VARIANTS=""
67 1.1 mrg TOOL=""
68 1.1 mrg MODE="sum"
69 1.1 mrg
70 1.1 mrg while getopts "l:t:L" ARG; do
71 1.1 mrg case $ARG in
72 1.1 mrg l) VARIANTS="${VARIANTS} ${OPTARG}";;
73 1.1 mrg t) test -z "$TOOL" || (msg "${PROGNAME}: only one tool can be specified"; exit 1);
74 1.1 mrg TOOL="${OPTARG}";;
75 1.1 mrg L) MODE="log";;
76 1.1 mrg \?) usage; exit 0;;
77 1.1 mrg esac
78 1.1 mrg done
79 1.1 mrg shift `expr ${OPTIND} - 1`
80 1.1 mrg
81 1.1 mrg if test $# -lt 1 ; then
82 1.1 mrg usage
83 1.1 mrg exit 1
84 1.1 mrg fi
85 1.1 mrg
86 1.1 mrg TMPDIR=${TMPDIR-/tmp}
87 1.1 mrg SUM_FILES="$@"
88 1.1 mrg FIRST_SUM=$1
89 1.1 mrg TMP=
90 1.1 mrg trap 'EXIT_STATUS=$?; rm -rf $TMP && exit $EXIT_STATUS' 0
91 1.1 mrg # Create a (secure) tmp directory for tmp files.
92 1.1 mrg {
93 1.1 mrg TMP=`(umask 077 && mktemp -d -q "${TMPDIR}/dg-combine-results-$$-XXXXXX") 2>/dev/null` &&
94 1.1 mrg test -n "$TMP" && test -d "$TMP"
95 1.1 mrg } ||
96 1.1 mrg {
97 1.1 mrg TMP=${TMPDIR}/dg-combine-results-$$-$RANDOM
98 1.1 mrg (umask 077 && mkdir $TMP)
99 1.1 mrg } ||
100 1.1 mrg {
101 1.1 mrg msg "${PROGNAME}: cannot create a temporary directory"
102 1.1 mrg { (exit 1); exit 1; }
103 1.1 mrg }
104 1.1 mrg
105 1.1 mrg # Find a good awk.
106 1.1 mrg
107 1.1 mrg if test -z "$AWK" ; then
108 1.1 mrg for AWK in gawk nawk awk
109 1.1 mrg do
110 1.1 mrg if type $AWK 2>&1 | grep 'not found' > /dev/null 2>&1 ; then
111 1.1 mrg :
112 1.1 mrg else
113 1.1 mrg break
114 1.1 mrg fi
115 1.1 mrg done
116 1.1 mrg fi
117 1.1 mrg
118 1.1 mrg # Verify that the specified summary files exist.
119 1.1 mrg
120 1.1 mrg ERROR=0
121 1.1 mrg for FILE in $SUM_FILES
122 1.1 mrg do
123 1.1 mrg if ! test -f $FILE ; then
124 1.1 mrg msg "${PROGNAME}: file $FILE does not exist."
125 1.1 mrg ERROR=1
126 1.1 mrg fi
127 1.1 mrg done
128 1.1 mrg test $ERROR -eq 0 || exit 1
129 1.1 mrg
130 1.1.1.3 mrg # Test if grep supports the '--text' option
131 1.1.1.3 mrg
132 1.1.1.3 mrg GREP=grep
133 1.1.1.3 mrg
134 1.1.1.3 mrg if echo -e '\x00foo\x00' | $GREP --text foo > /dev/null 2>&1 ; then
135 1.1.1.3 mrg GREP="grep --text"
136 1.1.1.3 mrg else
137 1.1.1.3 mrg # Our grep does not recognize the '--text' option. We have to
138 1.1.1.3 mrg # treat our files in order to remove any non-printable character.
139 1.1.1.3 mrg for file in $SUM_FILES ; do
140 1.1.1.3 mrg mv $file ${file}.orig
141 1.1.1.3 mrg cat -v ${file}.orig > $file
142 1.1.1.3 mrg done
143 1.1.1.3 mrg fi
144 1.1.1.3 mrg
145 1.1 mrg if [ -z "$TOOL" ]; then
146 1.1 mrg # If no tool was specified, all specified summary files must be for
147 1.1 mrg # the same tool.
148 1.1 mrg
149 1.1.1.3 mrg CNT=`$GREP '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l`
150 1.1 mrg if [ $CNT -eq 1 ]; then
151 1.1.1.3 mrg TOOL=`$GREP '=== .* tests ===' $FIRST_SUM | $AWK '{ print $2 }'`
152 1.1 mrg else
153 1.1 mrg msg "${PROGNAME}: sum files are for multiple tools, specify a tool"
154 1.1 mrg msg ""
155 1.1 mrg usage
156 1.1 mrg exit 1
157 1.1 mrg fi
158 1.1 mrg else
159 1.1 mrg # Ignore the specified summary files that are not for this tool. This
160 1.1 mrg # should keep the relevant files in the same order.
161 1.1 mrg
162 1.1.1.3 mrg SUM_FILES=`$GREP -l "=== $TOOL" $SUM_FILES`
163 1.1 mrg if test -z "$SUM_FILES" ; then
164 1.1 mrg msg "${PROGNAME}: none of the specified files are results for $TOOL"
165 1.1 mrg exit 1
166 1.1 mrg fi
167 1.1 mrg fi
168 1.1 mrg
169 1.1 mrg if [ "$TOOL" = acats ]; then
170 1.1 mrg # Acats *.sum or *.log files aren't dejagnu generated, and they have
171 1.1 mrg # somewhat different format.
172 1.1 mrg ACATS_AWK=${TMP}/acats.awk
173 1.1 mrg cat <<EOF > $ACATS_AWK
174 1.1 mrg BEGIN {
175 1.1 mrg print_prologue=1; curfile=""; insummary=0
176 1.1 mrg passcnt=0; failcnt=0; unsupcnt=0; failures=""
177 1.1 mrg }
178 1.1 mrg /^[ \t]*=== acats configuration ===/ {
179 1.1 mrg insummary=0
180 1.1 mrg if (print_prologue) print
181 1.1 mrg next
182 1.1 mrg }
183 1.1 mrg /^[ \t]*=== acats tests ===/ {
184 1.1 mrg if (print_prologue) print
185 1.1 mrg print_prologue=0
186 1.1 mrg next
187 1.1 mrg }
188 1.1 mrg /^Running chapter / {
189 1.1 mrg if (curfile) close (curfile)
190 1.1 mrg curfile="${TMP}/chapter-"\$3
191 1.1 mrg print >> curfile
192 1.1 mrg next
193 1.1 mrg }
194 1.1 mrg /^[ \t]*=== acats Summary ===/ {
195 1.1 mrg if (curfile) close (curfile)
196 1.1 mrg curfile=""
197 1.1 mrg insummary=1
198 1.1 mrg next
199 1.1 mrg }
200 1.1 mrg /^# of expected passes/ { if (insummary == 1) passcnt += \$5; next; }
201 1.1 mrg /^# of unexpected failures/ { if (insummary == 1) failcnt += \$5; next; }
202 1.1 mrg /^# of unsupported tests/ { if (insummary == 1) unsupcnt += \$5; next; }
203 1.1 mrg /^\*\*\* FAILURES: / {
204 1.1 mrg if (insummary == 1) {
205 1.1 mrg if (failures) sub(/^\*\*\* FAILURES:/,"")
206 1.1 mrg failures=failures""\$0
207 1.1 mrg }
208 1.1 mrg }
209 1.1 mrg {
210 1.1 mrg if (print_prologue) { print; next }
211 1.1 mrg if (curfile) print >> curfile
212 1.1 mrg }
213 1.1 mrg END {
214 1.1 mrg system ("cat ${TMP}/chapter-*")
215 1.1 mrg print " === acats Summary ==="
216 1.1 mrg print "# of expected passes " passcnt
217 1.1 mrg print "# of unexpected failures " failcnt
218 1.1 mrg if (unsupcnt) print "# of unsupported tests " unsupcnt
219 1.1 mrg if (failures) print failures
220 1.1 mrg }
221 1.1 mrg EOF
222 1.1 mrg
223 1.1 mrg rm -f ${TMP}/chapter-*
224 1.1 mrg $AWK -f $ACATS_AWK $SUM_FILES
225 1.1 mrg exit 0
226 1.1 mrg fi
227 1.1 mrg
228 1.1 mrg # If no variants were specified, find all variants in the remaining
229 1.1 mrg # summary files. Otherwise, ignore specified variants that aren't in
230 1.1 mrg # any of those summary files.
231 1.1 mrg
232 1.1 mrg if test -z "$VARIANTS" ; then
233 1.1 mrg VAR_AWK=${TMP}/variants.awk
234 1.1 mrg cat <<EOF > $VAR_AWK
235 1.1 mrg /^Schedule of variations:/ { in_vars=1; next }
236 1.1 mrg /^$/ { in_vars=0 }
237 1.1 mrg /^Running target/ { exit }
238 1.1 mrg { if (in_vars==1) print \$1; else next }
239 1.1 mrg EOF
240 1.1 mrg
241 1.1 mrg touch ${TMP}/varlist
242 1.1 mrg for FILE in $SUM_FILES; do
243 1.1 mrg $AWK -f $VAR_AWK $FILE >> ${TMP}/varlist
244 1.1 mrg done
245 1.1 mrg VARIANTS="`sort -u ${TMP}/varlist`"
246 1.1 mrg else
247 1.1 mrg VARS="$VARIANTS"
248 1.1 mrg VARIANTS=""
249 1.1 mrg for VAR in $VARS
250 1.1 mrg do
251 1.1.1.3 mrg $GREP "Running target $VAR" $SUM_FILES > /dev/null && VARIANTS="$VARIANTS $VAR"
252 1.1 mrg done
253 1.1 mrg fi
254 1.1 mrg
255 1.1 mrg # Find out if we have more than one variant, or any at all.
256 1.1 mrg
257 1.1 mrg VARIANT_COUNT=0
258 1.1 mrg for VAR in $VARIANTS
259 1.1 mrg do
260 1.1 mrg VARIANT_COUNT=`expr $VARIANT_COUNT + 1`
261 1.1 mrg done
262 1.1 mrg
263 1.1 mrg if test $VARIANT_COUNT -eq 0 ; then
264 1.1 mrg msg "${PROGNAME}: no file for $TOOL has results for the specified variants"
265 1.1 mrg exit 1
266 1.1 mrg fi
267 1.1 mrg
268 1.1 mrg cat $SUM_FILES \
269 1.1 mrg | $AWK '/^Running/ { if ($2 != "target" && $3 == "...") print "EXPFILE: "$2 } ' \
270 1.1 mrg | sort -u > ${TMP}/expfiles
271 1.1 mrg
272 1.1 mrg # Write the begining of the combined summary file.
273 1.1 mrg
274 1.1 mrg head -n 2 $FIRST_SUM
275 1.1 mrg echo
276 1.1 mrg echo " === $TOOL tests ==="
277 1.1 mrg echo
278 1.1 mrg echo "Schedule of variations:"
279 1.1 mrg for VAR in $VARIANTS
280 1.1 mrg do
281 1.1 mrg echo " $VAR"
282 1.1 mrg done
283 1.1 mrg echo
284 1.1 mrg
285 1.1 mrg # For each test variant for the tool, copy test reports from each of the
286 1.1 mrg # summary files. Set up two awk scripts from within the loop to
287 1.1 mrg # initialize VAR and TOOL with the script, rather than assuming that the
288 1.1 mrg # available version of awk can pass variables from the command line.
289 1.1 mrg
290 1.1 mrg for VAR in $VARIANTS
291 1.1 mrg do
292 1.1 mrg GUTS_AWK=${TMP}/guts.awk
293 1.1 mrg cat << EOF > $GUTS_AWK
294 1.1 mrg BEGIN {
295 1.1 mrg variant="$VAR"
296 1.1 mrg firstvar=1
297 1.1 mrg expfileno=1
298 1.1 mrg cnt=0
299 1.1 mrg print_using=0
300 1.1 mrg need_close=0
301 1.1.1.5 mrg has_timeout=0
302 1.1.1.5 mrg timeout_cnt=0
303 1.1 mrg }
304 1.1 mrg /^EXPFILE: / {
305 1.1 mrg expfiles[expfileno] = \$2
306 1.1 mrg expfilesr[\$2] = expfileno
307 1.1 mrg expfileno = expfileno + 1
308 1.1 mrg }
309 1.1 mrg /^Running target / {
310 1.1 mrg curvar = \$3
311 1.1 mrg if (variant == curvar && firstvar == 1) { print; print_using=1; firstvar = 0 }
312 1.1 mrg next
313 1.1 mrg }
314 1.1 mrg /^Using / {
315 1.1 mrg if (variant == curvar && print_using) { print; next }
316 1.1 mrg }
317 1.1.1.2 mrg /^Running .*\\.exp \\.\\.\\./ {
318 1.1 mrg print_using=0
319 1.1 mrg if (variant == curvar) {
320 1.1 mrg if (need_close) close(curfile)
321 1.1 mrg curfile="${TMP}/list"expfilesr[\$2]
322 1.1 mrg expfileseen[\$2]=expfileseen[\$2] + 1
323 1.1 mrg need_close=0
324 1.1 mrg testname="00"
325 1.1 mrg next
326 1.1 mrg }
327 1.1 mrg }
328 1.1 mrg /^\t\t=== .* ===$/ { curvar = ""; next }
329 1.1 mrg /^(PASS|XPASS|FAIL|XFAIL|UNRESOLVED|WARNING|ERROR|UNSUPPORTED|UNTESTED|KFAIL):/ {
330 1.1 mrg testname=\$2
331 1.1 mrg # Ugly hack for gfortran.dg/dg.exp
332 1.1 mrg if ("$TOOL" == "gfortran" && testname ~ /^gfortran.dg\/g77\//)
333 1.1 mrg testname="h"testname
334 1.1.1.5 mrg if ("$MODE" == "sum") {
335 1.1.1.5 mrg if (\$0 ~ /^WARNING: program timed out/) {
336 1.1.1.5 mrg has_timeout=1
337 1.1.1.5 mrg timeout_cnt=cnt+1
338 1.1.1.5 mrg } else {
339 1.1.1.5 mrg # Prepare timeout replacement message in case it's needed
340 1.1.1.5 mrg timeout_msg=\$0
341 1.1.1.5 mrg sub(\$1, "WARNING:", timeout_msg)
342 1.1.1.5 mrg }
343 1.1.1.5 mrg }
344 1.1 mrg }
345 1.1 mrg /^$/ { if ("$MODE" == "sum") next }
346 1.1 mrg { if (variant == curvar && curfile) {
347 1.1 mrg if ("$MODE" == "sum") {
348 1.1.1.5 mrg # Do not print anything if the current line is a timeout
349 1.1.1.5 mrg if (has_timeout == 0) {
350 1.1.1.5 mrg # If the previous line was a timeout,
351 1.1.1.5 mrg # insert the full current message without keyword
352 1.1.1.5 mrg if (timeout_cnt != 0) {
353 1.1.1.5 mrg printf "%s %08d|%s program timed out.\n", testname, timeout_cnt-1, timeout_msg >> curfile
354 1.1.1.5 mrg timeout_cnt = 0
355 1.1.1.5 mrg cnt = cnt + 1
356 1.1.1.5 mrg }
357 1.1.1.5 mrg printf "%s %08d|", testname, cnt >> curfile
358 1.1.1.5 mrg cnt = cnt + 1
359 1.1.1.5 mrg filewritten[curfile]=1
360 1.1.1.5 mrg need_close=1
361 1.1.1.5 mrg print >> curfile
362 1.1.1.5 mrg }
363 1.1.1.5 mrg has_timeout=0
364 1.1.1.5 mrg } else {
365 1.1.1.5 mrg filewritten[curfile]=1
366 1.1.1.5 mrg need_close=1
367 1.1.1.5 mrg print >> curfile
368 1.1 mrg }
369 1.1.1.5 mrg } else {
370 1.1.1.5 mrg has_timeout=0
371 1.1.1.5 mrg timeout_cnt=0
372 1.1 mrg next
373 1.1.1.5 mrg }
374 1.1 mrg }
375 1.1 mrg END {
376 1.1 mrg n=1
377 1.1 mrg while (n < expfileno) {
378 1.1 mrg if (expfileseen[expfiles[n]]) {
379 1.1 mrg print "Running "expfiles[n]" ..."
380 1.1 mrg if (filewritten["${TMP}/list"n]) {
381 1.1 mrg if (expfileseen[expfiles[n]] == 1)
382 1.1 mrg cmd="cat"
383 1.1 mrg else
384 1.1 mrg cmd="LC_ALL=C sort"
385 1.1 mrg if ("$MODE" == "sum")
386 1.1 mrg system (cmd" ${TMP}/list"n" | sed -n 's/^[^ ]* [^ |]*|//p'")
387 1.1 mrg else
388 1.1 mrg system ("cat ${TMP}/list"n)
389 1.1 mrg }
390 1.1 mrg }
391 1.1 mrg n = n + 1
392 1.1 mrg }
393 1.1 mrg }
394 1.1 mrg EOF
395 1.1 mrg
396 1.1 mrg SUMS_AWK=${TMP}/sums.awk
397 1.1 mrg rm -f $SUMS_AWK
398 1.1 mrg cat << EOF > $SUMS_AWK
399 1.1 mrg BEGIN {
400 1.1 mrg variant="$VAR"
401 1.1 mrg tool="$TOOL"
402 1.1.1.4 mrg passcnt=0; failcnt=0; untstcnt=0; xpasscnt=0; xfailcnt=0; kpasscnt=0; kfailcnt=0; unsupcnt=0; unrescnt=0; dgerrorcnt=0;
403 1.1 mrg curvar=""; insummary=0
404 1.1 mrg }
405 1.1 mrg /^Running target / { curvar = \$3; next }
406 1.1.1.4 mrg /^ERROR: \(DejaGnu\)/ { if (variant == curvar) dgerrorcnt += 1 }
407 1.1 mrg /^# of / { if (variant == curvar) insummary = 1 }
408 1.1 mrg /^# of expected passes/ { if (insummary == 1) passcnt += \$5; next; }
409 1.1 mrg /^# of unexpected successes/ { if (insummary == 1) xpasscnt += \$5; next; }
410 1.1 mrg /^# of unexpected failures/ { if (insummary == 1) failcnt += \$5; next; }
411 1.1 mrg /^# of expected failures/ { if (insummary == 1) xfailcnt += \$5; next; }
412 1.1.1.2 mrg /^# of unknown successes/ { if (insummary == 1) kpasscnt += \$5; next; }
413 1.1.1.2 mrg /^# of known failures/ { if (insummary == 1) kfailcnt += \$5; next; }
414 1.1 mrg /^# of untested testcases/ { if (insummary == 1) untstcnt += \$5; next; }
415 1.1 mrg /^# of unresolved testcases/ { if (insummary == 1) unrescnt += \$5; next; }
416 1.1 mrg /^# of unsupported tests/ { if (insummary == 1) unsupcnt += \$5; next; }
417 1.1 mrg /^$/ { if (insummary == 1)
418 1.1 mrg { insummary = 0; curvar = "" }
419 1.1 mrg next
420 1.1 mrg }
421 1.1 mrg { next }
422 1.1 mrg END {
423 1.1 mrg printf ("\t\t=== %s Summary for %s ===\n\n", tool, variant)
424 1.1.1.4 mrg if (dgerrorcnt != 0) printf ("# of DejaGnu errors\t\t%d\n", dgerrorcnt)
425 1.1 mrg if (passcnt != 0) printf ("# of expected passes\t\t%d\n", passcnt)
426 1.1 mrg if (failcnt != 0) printf ("# of unexpected failures\t%d\n", failcnt)
427 1.1 mrg if (xpasscnt != 0) printf ("# of unexpected successes\t%d\n", xpasscnt)
428 1.1 mrg if (xfailcnt != 0) printf ("# of expected failures\t\t%d\n", xfailcnt)
429 1.1.1.2 mrg if (kpasscnt != 0) printf ("# of unknown successes\t\t%d\n", kpasscnt)
430 1.1.1.2 mrg if (kfailcnt != 0) printf ("# of known failures\t\t%d\n", kfailcnt)
431 1.1 mrg if (untstcnt != 0) printf ("# of untested testcases\t\t%d\n", untstcnt)
432 1.1 mrg if (unrescnt != 0) printf ("# of unresolved testcases\t%d\n", unrescnt)
433 1.1 mrg if (unsupcnt != 0) printf ("# of unsupported tests\t\t%d\n", unsupcnt)
434 1.1 mrg }
435 1.1 mrg EOF
436 1.1 mrg
437 1.1 mrg PVAR=`echo $VAR | sed 's,/,.,g'`
438 1.1 mrg TMPFILE=${TMP}/var-$PVAR
439 1.1 mrg rm -f $TMPFILE
440 1.1 mrg rm -f ${TMP}/list*
441 1.1 mrg cat ${TMP}/expfiles $SUM_FILES | $AWK -f $GUTS_AWK
442 1.1 mrg cat $SUM_FILES | $AWK -f $SUMS_AWK > $TMPFILE
443 1.1 mrg # If there are multiple variants, output the counts for this one;
444 1.1 mrg # otherwise there will just be the final counts at the end.
445 1.1 mrg test $VARIANT_COUNT -eq 1 || cat $TMPFILE
446 1.1 mrg done
447 1.1 mrg
448 1.1 mrg # Set up an awk script to get the combined summary counts for the tool.
449 1.1 mrg
450 1.1 mrg TOTAL_AWK=${TMP}/total.awk
451 1.1 mrg cat << EOF > $TOTAL_AWK
452 1.1 mrg BEGIN {
453 1.1 mrg tool="$TOOL"
454 1.1.1.4 mrg passcnt=0; failcnt=0; untstcnt=0; xpasscnt=0; xfailcnt=0; kfailcnt=0; unsupcnt=0; unrescnt=0; dgerrorcnt=0
455 1.1 mrg }
456 1.1.1.4 mrg /^# of DejaGnu errors/ { dgerrorcnt += \$5 }
457 1.1 mrg /^# of expected passes/ { passcnt += \$5 }
458 1.1 mrg /^# of unexpected failures/ { failcnt += \$5 }
459 1.1 mrg /^# of unexpected successes/ { xpasscnt += \$5 }
460 1.1 mrg /^# of expected failures/ { xfailcnt += \$5 }
461 1.1.1.2 mrg /^# of unknown successes/ { kpasscnt += \$5 }
462 1.1.1.2 mrg /^# of known failures/ { kfailcnt += \$5 }
463 1.1 mrg /^# of untested testcases/ { untstcnt += \$5 }
464 1.1 mrg /^# of unresolved testcases/ { unrescnt += \$5 }
465 1.1 mrg /^# of unsupported tests/ { unsupcnt += \$5 }
466 1.1 mrg END {
467 1.1 mrg printf ("\n\t\t=== %s Summary ===\n\n", tool)
468 1.1.1.4 mrg if (dgerrorcnt != 0) printf ("# of DejaGnu errors\t\t%d\n", dgerrorcnt)
469 1.1 mrg if (passcnt != 0) printf ("# of expected passes\t\t%d\n", passcnt)
470 1.1 mrg if (failcnt != 0) printf ("# of unexpected failures\t%d\n", failcnt)
471 1.1 mrg if (xpasscnt != 0) printf ("# of unexpected successes\t%d\n", xpasscnt)
472 1.1 mrg if (xfailcnt != 0) printf ("# of expected failures\t\t%d\n", xfailcnt)
473 1.1.1.2 mrg if (kpasscnt != 0) printf ("# of unknown successes\t\t%d\n", kpasscnt)
474 1.1.1.2 mrg if (kfailcnt != 0) printf ("# of known failures\t\t%d\n", kfailcnt)
475 1.1 mrg if (untstcnt != 0) printf ("# of untested testcases\t\t%d\n", untstcnt)
476 1.1 mrg if (unrescnt != 0) printf ("# of unresolved testcases\t%d\n", unrescnt)
477 1.1 mrg if (unsupcnt != 0) printf ("# of unsupported tests\t\t%d\n", unsupcnt)
478 1.1 mrg }
479 1.1 mrg EOF
480 1.1 mrg
481 1.1 mrg # Find the total summaries for the tool and add to the end of the output.
482 1.1 mrg cat ${TMP}/var-* | $AWK -f $TOTAL_AWK
483 1.1 mrg
484 1.1 mrg # This is ugly, but if there's version output from the compiler under test
485 1.1 mrg # at the end of the file, we want it. The other thing that might be there
486 1.1 mrg # is the final summary counts.
487 1.1.1.3 mrg tail -2 $FIRST_SUM | $GREP '^#' > /dev/null || tail -2 $FIRST_SUM
488 1.1 mrg
489 1.1 mrg exit 0
490