3 # For a specified tool and optional list of test variants, extract
4 # test results from one or more test summary (.sum) files and combine
5 # the results into a new test summary file, sent to the standard output.
6 # The resulting file can be used with test result comparison scripts for
7 # results from tests that were run in parallel. See usage() below.
9 # Copyright (C) 2008, 2009, 2010 Free Software Foundation
10 # Contributed by Janis Johnson <janis187@us.ibm.com>
12 # This file is part of GCC.
14 # GCC is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 3, or (at your option)
19 # GCC is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with GCC; see the file COPYING. If not, write to
26 # the Free Software Foundation, 51 Franklin Street, Fifth Floor,
27 # Boston, MA 02110-1301, USA.
29 PROGNAME
=dg-extract-results.sh
33 Usage: $PROGNAME [-t tool] [-l variant-list] [-L] sum-file ...
35 tool The tool (e.g. g++, libffi) for which to create a
36 new test summary file. If not specified then all
37 specified sum files must be for the same tool.
38 variant-list One or more test variant names. If the list is
39 not specified then one is constructed from all
40 variants in the files for <tool>.
41 sum-file A test summary file with the format of those
42 created by runtest from DejaGnu.
43 If -L is used, merge *.log files instead of *.sum. In this
44 mode the exact order of lines may not be preserved, just different
45 Running *.exp chunks should be in correct order.
49 # Write a message to the standard error.
55 # Parse the command-line options.
61 while getopts "l:t:L" ARG
; do
63 l
) VARIANTS
="${VARIANTS} ${OPTARG}";;
64 t
) test -z "$TOOL" ||
(msg
"${PROGNAME}: only one tool can be specified"; exit 1);
70 shift `expr ${OPTIND} - 1`
72 if test $# -lt 1 ; then
81 trap 'EXIT_STATUS=$?; rm -rf $TMP && exit $EXIT_STATUS' 0
82 # Create a (secure) tmp directory for tmp files.
84 TMP
=`(umask 077 && mktemp -d -q "${TMPDIR}/dg-combine-results-$$-XXXXXX") 2>/dev/null` &&
85 test -n "$TMP" && test -d "$TMP"
88 TMP
=${TMPDIR}/dg-combine-results-$$
-$RANDOM
89 (umask 077 && mkdir
$TMP)
92 msg
"${PROGNAME}: cannot create a temporary directory"
98 if test -z "$AWK" ; then
99 for AWK
in gawk nawk
awk
101 if type $AWK 2>&1 |
grep 'not found' > /dev
/null
2>&1 ; then
109 # Verify that the specified summary files exist.
112 for FILE
in $SUM_FILES
114 if ! test -f $FILE ; then
115 msg
"${PROGNAME}: file $FILE does not exist."
119 test $ERROR -eq 0 ||
exit 1
121 if [ -z "$TOOL" ]; then
122 # If no tool was specified, all specified summary files must be for
125 CNT
=`grep '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l`
126 if [ $CNT -eq 1 ]; then
127 TOOL
=`grep '=== .* tests ===' $FIRST_SUM | $AWK '{ print $2 }'`
129 msg
"${PROGNAME}: sum files are for multiple tools, specify a tool"
135 # Ignore the specified summary files that are not for this tool. This
136 # should keep the relevant files in the same order.
138 SUM_FILES
=`grep -l "=== $TOOL" $SUM_FILES`
139 if test -z "$SUM_FILES" ; then
140 msg
"${PROGNAME}: none of the specified files are results for $TOOL"
145 if [ "$TOOL" = acats
]; then
146 # Acats *.sum or *.log files aren't dejagnu generated, and they have
147 # somewhat different format.
148 ACATS_AWK
=${TMP}/acats.
awk
149 cat <<EOF > $ACATS_AWK
151 print_prologue=1; curfile=""; insummary=0
152 passcnt=0; failcnt=0; unsupcnt=0; failures=""
154 /^[ \t]*=== acats configuration ===/ {
156 if (print_prologue) print
159 /^[ \t]*=== acats tests ===/ {
160 if (print_prologue) print
164 /^Running chapter / {
165 if (curfile) close (curfile)
166 curfile="${TMP}/chapter-"\$3
170 /^[ \t]*=== acats Summary ===/ {
171 if (curfile) close (curfile)
176 /^# of expected passes/ { if (insummary == 1) passcnt += \$5; next; }
177 /^# of unexpected failures/ { if (insummary == 1) failcnt += \$5; next; }
178 /^# of unsupported tests/ { if (insummary == 1) unsupcnt += \$5; next; }
179 /^\*\*\* FAILURES: / {
180 if (insummary == 1) {
181 if (failures) sub(/^\*\*\* FAILURES:/,"")
182 failures=failures""\$0
186 if (print_prologue) { print; next }
187 if (curfile) print >> curfile
190 system ("cat ${TMP}/chapter-*")
191 print " === acats Summary ==="
192 print "# of expected passes " passcnt
193 print "# of unexpected failures " failcnt
194 if (unsupcnt) print "# of unsupported tests " unsupcnt
195 if (failures) print failures
199 rm -f ${TMP}/chapter-
*
200 $AWK -f $ACATS_AWK $SUM_FILES
204 # If no variants were specified, find all variants in the remaining
205 # summary files. Otherwise, ignore specified variants that aren't in
206 # any of those summary files.
208 if test -z "$VARIANTS" ; then
209 VAR_AWK
=${TMP}/variants.
awk
211 /^Schedule of variations:/ { in_vars=1; next }
213 /^Running target/ { exit }
214 { if (in_vars==1) print \$1; else next }
218 for FILE
in $SUM_FILES; do
219 $AWK -f $VAR_AWK $FILE >> ${TMP}/varlist
221 VARIANTS
="`sort -u ${TMP}/varlist`"
227 grep -q "Running target $VAR" $SUM_FILES && VARIANTS
="$VARIANTS $VAR"
231 # Find out if we have more than one variant, or any at all.
236 VARIANT_COUNT
=`expr $VARIANT_COUNT + 1`
239 if test $VARIANT_COUNT -eq 0 ; then
240 msg
"${PROGNAME}: no file for $TOOL has results for the specified variants"
245 |
$AWK '/^Running/ { if ($2 != "target" && $3 == "...") print "EXPFILE: "$2 } ' \
246 |
sort -u > ${TMP}/expfiles
248 # Write the begining of the combined summary file.
252 echo " === $TOOL tests ==="
254 echo "Schedule of variations:"
261 # For each test variant for the tool, copy test reports from each of the
262 # summary files. Set up two awk scripts from within the loop to
263 # initialize VAR and TOOL with the script, rather than assuming that the
264 # available version of awk can pass variables from the command line.
268 GUTS_AWK
=${TMP}/guts.
awk
269 cat << EOF > $GUTS_AWK
279 expfiles[expfileno] = \$2
280 expfilesr[\$2] = expfileno
281 expfileno = expfileno + 1
285 if (variant == curvar && firstvar == 1) { print; print_using=1; firstvar = 0 }
289 if (variant == curvar && print_using) { print; next }
293 if (variant == curvar) {
294 if (need_close) close(curfile)
295 curfile="${TMP}/list"expfilesr[\$2]
296 expfileseen[\$2]=expfileseen[\$2] + 1
302 /^\t\t=== .* ===$/ { curvar = ""; next }
303 /^(PASS|XPASS|FAIL|XFAIL|UNRESOLVED|WARNING|ERROR|UNSUPPORTED|UNTESTED|KFAIL):/ {
305 # Ugly hack for gfortran.dg/dg.exp
306 if ("$TOOL" == "gfortran" && testname ~ /^gfortran.dg\/g77\//)
309 /^$/ { if ("$MODE" == "sum") next }
310 { if (variant == curvar && curfile) {
311 if ("$MODE" == "sum") {
312 printf "%s %08d|", testname, cnt >> curfile
315 filewritten[curfile]=1
323 while (n < expfileno) {
324 if (expfileseen[expfiles[n]]) {
325 print "Running "expfiles[n]" ..."
326 if (filewritten["${TMP}/list"n]) {
327 if (expfileseen[expfiles[n]] == 1)
331 if ("$MODE" == "sum")
332 system (cmd" ${TMP}/list"n" | sed -n 's/^[^ ]* [^ |]*|//p'")
334 system ("cat ${TMP}/list"n)
342 SUMS_AWK
=${TMP}/sums.
awk
344 cat << EOF > $SUMS_AWK
348 passcnt=0; failcnt=0; untstcnt=0; xpasscnt=0; xfailcnt=0; unsupcnt=0; unrescnt=0;
349 curvar=""; insummary=0
351 /^Running target / { curvar = \$3; next }
352 /^# of / { if (variant == curvar) insummary = 1 }
353 /^# of expected passes/ { if (insummary == 1) passcnt += \$5; next; }
354 /^# of unexpected successes/ { if (insummary == 1) xpasscnt += \$5; next; }
355 /^# of unexpected failures/ { if (insummary == 1) failcnt += \$5; next; }
356 /^# of expected failures/ { if (insummary == 1) xfailcnt += \$5; next; }
357 /^# of untested testcases/ { if (insummary == 1) untstcnt += \$5; next; }
358 /^# of unresolved testcases/ { if (insummary == 1) unrescnt += \$5; next; }
359 /^# of unsupported tests/ { if (insummary == 1) unsupcnt += \$5; next; }
360 /^$/ { if (insummary == 1)
361 { insummary = 0; curvar = "" }
366 printf ("\t\t=== %s Summary for %s ===\n\n", tool, variant)
367 if (passcnt != 0) printf ("# of expected passes\t\t%d\n", passcnt)
368 if (failcnt != 0) printf ("# of unexpected failures\t%d\n", failcnt)
369 if (xpasscnt != 0) printf ("# of unexpected successes\t%d\n", xpasscnt)
370 if (xfailcnt != 0) printf ("# of expected failures\t\t%d\n", xfailcnt)
371 if (untstcnt != 0) printf ("# of untested testcases\t\t%d\n", untstcnt)
372 if (unrescnt != 0) printf ("# of unresolved testcases\t%d\n", unrescnt)
373 if (unsupcnt != 0) printf ("# of unsupported tests\t\t%d\n", unsupcnt)
377 PVAR
=`echo $VAR | sed 's,/,.,g'`
378 TMPFILE
=${TMP}/var-
$PVAR
381 cat ${TMP}/expfiles
$SUM_FILES |
$AWK -f $GUTS_AWK
382 cat $SUM_FILES |
$AWK -f $SUMS_AWK > $TMPFILE
383 # If there are multiple variants, output the counts for this one;
384 # otherwise there will just be the final counts at the end.
385 test $VARIANT_COUNT -eq 1 ||
cat $TMPFILE
388 # Set up an awk script to get the combined summary counts for the tool.
390 TOTAL_AWK
=${TMP}/total.
awk
391 cat << EOF > $TOTAL_AWK
394 passcnt=0; failcnt=0; untstcnt=0; xpasscnt=0; xfailcnt=0; unsupcnt=0; unrescnt=0
396 /^# of expected passes/ { passcnt += \$5 }
397 /^# of unexpected failures/ { failcnt += \$5 }
398 /^# of unexpected successes/ { xpasscnt += \$5 }
399 /^# of expected failures/ { xfailcnt += \$5 }
400 /^# of untested testcases/ { untstcnt += \$5 }
401 /^# of unresolved testcases/ { unrescnt += \$5 }
402 /^# of unsupported tests/ { unsupcnt += \$5 }
404 printf ("\n\t\t=== %s Summary ===\n\n", tool)
405 if (passcnt != 0) printf ("# of expected passes\t\t%d\n", passcnt)
406 if (failcnt != 0) printf ("# of unexpected failures\t%d\n", failcnt)
407 if (xpasscnt != 0) printf ("# of unexpected successes\t%d\n", xpasscnt)
408 if (xfailcnt != 0) printf ("# of expected failures\t\t%d\n", xfailcnt)
409 if (untstcnt != 0) printf ("# of untested testcases\t\t%d\n", untstcnt)
410 if (unrescnt != 0) printf ("# of unresolved testcases\t%d\n", unrescnt)
411 if (unsupcnt != 0) printf ("# of unsupported tests\t\t%d\n", unsupcnt)
415 # Find the total summaries for the tool and add to the end of the output.
416 cat ${TMP}/var-
* |
$AWK -f $TOTAL_AWK
418 # This is ugly, but if there's version output from the compiler under test
419 # at the end of the file, we want it. The other thing that might be there
420 # is the final summary counts.
421 tail -2 $FIRST_SUM |
grep -q '^#' ||
tail -2 $FIRST_SUM
This page took 0.038513 seconds and 4 git commands to generate.