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-2014 Free Software Foundation, Inc.
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 this program. If not, see <http://www.gnu.org/licenses/>.
27 PROGNAME
=dg-extract-results.sh
29 # Try to use the python version if possible, since it tends to be faster.
30 PYTHON_VER
=`echo "$0" | sed 's/sh$/py/'`
31 if test "$PYTHON_VER" != "$0" &&
32 test -f "$PYTHON_VER" &&
33 python
-c 'import sys; sys.exit (0 if sys.version_info >= (2, 6) else 1)' \
34 > /dev
/null
2> /dev
/null
; then
35 exec python
$PYTHON_VER "$@"
40 Usage: $PROGNAME [-t tool] [-l variant-list] [-L] sum-file ...
42 tool The tool (e.g. g++, libffi) for which to create a
43 new test summary file. If not specified then all
44 specified sum files must be for the same tool.
45 variant-list One or more test variant names. If the list is
46 not specified then one is constructed from all
47 variants in the files for <tool>.
48 sum-file A test summary file with the format of those
49 created by runtest from DejaGnu.
50 If -L is used, merge *.log files instead of *.sum. In this
51 mode the exact order of lines may not be preserved, just different
52 Running *.exp chunks should be in correct order.
56 # Write a message to the standard error.
62 # Parse the command-line options.
68 while getopts "l:t:L" ARG
; do
70 l
) VARIANTS
="${VARIANTS} ${OPTARG}";;
71 t
) test -z "$TOOL" ||
(msg
"${PROGNAME}: only one tool can be specified"; exit 1);
77 shift `expr ${OPTIND} - 1`
79 if test $# -lt 1 ; then
88 trap 'EXIT_STATUS=$?; rm -rf $TMP && exit $EXIT_STATUS' 0
89 # Create a (secure) tmp directory for tmp files.
91 TMP
=`(umask 077 && mktemp -d -q "${TMPDIR}/dg-combine-results-$$-XXXXXX") 2>/dev/null` &&
92 test -n "$TMP" && test -d "$TMP"
95 TMP
=${TMPDIR}/dg-combine-results-$$
-$RANDOM
96 (umask 077 && mkdir
$TMP)
99 msg
"${PROGNAME}: cannot create a temporary directory"
100 { (exit 1); exit 1; }
105 if test -z "$AWK" ; then
106 for AWK
in gawk nawk
awk
108 if type $AWK 2>&1 |
grep 'not found' > /dev
/null
2>&1 ; then
116 # Verify that the specified summary files exist.
119 for FILE
in $SUM_FILES
121 if ! test -f $FILE ; then
122 msg
"${PROGNAME}: file $FILE does not exist."
126 test $ERROR -eq 0 ||
exit 1
128 if [ -z "$TOOL" ]; then
129 # If no tool was specified, all specified summary files must be for
132 CNT
=`grep '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l`
133 if [ $CNT -eq 1 ]; then
134 TOOL
=`grep '=== .* tests ===' $FIRST_SUM | $AWK '{ print $2 }'`
136 msg
"${PROGNAME}: sum files are for multiple tools, specify a tool"
142 # Ignore the specified summary files that are not for this tool. This
143 # should keep the relevant files in the same order.
145 SUM_FILES
=`grep -l "=== $TOOL" $SUM_FILES`
146 if test -z "$SUM_FILES" ; then
147 msg
"${PROGNAME}: none of the specified files are results for $TOOL"
152 if [ "$TOOL" = acats
]; then
153 # Acats *.sum or *.log files aren't dejagnu generated, and they have
154 # somewhat different format.
155 ACATS_AWK
=${TMP}/acats.
awk
156 cat <<EOF > $ACATS_AWK
158 print_prologue=1; curfile=""; insummary=0
159 passcnt=0; failcnt=0; unsupcnt=0; failures=""
161 /^[ \t]*=== acats configuration ===/ {
163 if (print_prologue) print
166 /^[ \t]*=== acats tests ===/ {
167 if (print_prologue) print
171 /^Running chapter / {
172 if (curfile) close (curfile)
173 curfile="${TMP}/chapter-"\$3
177 /^[ \t]*=== acats Summary ===/ {
178 if (curfile) close (curfile)
183 /^# of expected passes/ { if (insummary == 1) passcnt += \$5; next; }
184 /^# of unexpected failures/ { if (insummary == 1) failcnt += \$5; next; }
185 /^# of unsupported tests/ { if (insummary == 1) unsupcnt += \$5; next; }
186 /^\*\*\* FAILURES: / {
187 if (insummary == 1) {
188 if (failures) sub(/^\*\*\* FAILURES:/,"")
189 failures=failures""\$0
193 if (print_prologue) { print; next }
194 if (curfile) print >> curfile
197 system ("cat ${TMP}/chapter-*")
198 print " === acats Summary ==="
199 print "# of expected passes " passcnt
200 print "# of unexpected failures " failcnt
201 if (unsupcnt) print "# of unsupported tests " unsupcnt
202 if (failures) print failures
206 rm -f ${TMP}/chapter-
*
207 $AWK -f $ACATS_AWK $SUM_FILES
211 # If no variants were specified, find all variants in the remaining
212 # summary files. Otherwise, ignore specified variants that aren't in
213 # any of those summary files.
215 if test -z "$VARIANTS" ; then
216 VAR_AWK
=${TMP}/variants.
awk
218 /^Schedule of variations:/ { in_vars=1; next }
220 /^Running target/ { exit }
221 { if (in_vars==1) print \$1; else next }
225 for FILE
in $SUM_FILES; do
226 $AWK -f $VAR_AWK $FILE >> ${TMP}/varlist
228 VARIANTS
="`sort -u ${TMP}/varlist`"
234 grep "Running target $VAR" $SUM_FILES > /dev
/null
&& VARIANTS
="$VARIANTS $VAR"
238 # Find out if we have more than one variant, or any at all.
243 VARIANT_COUNT
=`expr $VARIANT_COUNT + 1`
246 if test $VARIANT_COUNT -eq 0 ; then
247 msg
"${PROGNAME}: no file for $TOOL has results for the specified variants"
252 |
$AWK '/^Running/ { if ($2 != "target" && $3 == "...") print "EXPFILE: "$2 } ' \
253 |
sort -u > ${TMP}/expfiles
255 # Write the begining of the combined summary file.
259 echo " === $TOOL tests ==="
261 echo "Schedule of variations:"
268 # For each test variant for the tool, copy test reports from each of the
269 # summary files. Set up two awk scripts from within the loop to
270 # initialize VAR and TOOL with the script, rather than assuming that the
271 # available version of awk can pass variables from the command line.
275 GUTS_AWK
=${TMP}/guts.
awk
276 cat << EOF > $GUTS_AWK
286 expfiles[expfileno] = \$2
287 expfilesr[\$2] = expfileno
288 expfileno = expfileno + 1
292 if (variant == curvar && firstvar == 1) { print; print_using=1; firstvar = 0 }
296 if (variant == curvar && print_using) { print; next }
298 /^Running .*\\.exp \\.\\.\\./ {
300 if (variant == curvar) {
301 if (need_close) close(curfile)
302 curfile="${TMP}/list"expfilesr[\$2]
303 expfileseen[\$2]=expfileseen[\$2] + 1
309 /^\t\t=== .* ===$/ { curvar = ""; next }
310 /^(PASS|XPASS|FAIL|XFAIL|UNRESOLVED|WARNING|ERROR|UNSUPPORTED|UNTESTED|KFAIL):/ {
312 # Ugly hack for gfortran.dg/dg.exp
313 if ("$TOOL" == "gfortran" && testname ~ /^gfortran.dg\/g77\//)
316 /^$/ { if ("$MODE" == "sum") next }
317 { if (variant == curvar && curfile) {
318 if ("$MODE" == "sum") {
319 printf "%s %08d|", testname, cnt >> curfile
322 filewritten[curfile]=1
330 while (n < expfileno) {
331 if (expfileseen[expfiles[n]]) {
332 print "Running "expfiles[n]" ..."
333 if (filewritten["${TMP}/list"n]) {
334 if (expfileseen[expfiles[n]] == 1)
338 if ("$MODE" == "sum")
339 system (cmd" ${TMP}/list"n" | sed -n 's/^[^ ]* [^ |]*|//p'")
341 system ("cat ${TMP}/list"n)
349 SUMS_AWK
=${TMP}/sums.
awk
351 cat << EOF > $SUMS_AWK
355 passcnt=0; failcnt=0; untstcnt=0; xpasscnt=0; xfailcnt=0; kpasscnt=0; kfailcnt=0; unsupcnt=0; unrescnt=0;
356 curvar=""; insummary=0
358 /^Running target / { curvar = \$3; next }
359 /^# of / { if (variant == curvar) insummary = 1 }
360 /^# of expected passes/ { if (insummary == 1) passcnt += \$5; next; }
361 /^# of unexpected successes/ { if (insummary == 1) xpasscnt += \$5; next; }
362 /^# of unexpected failures/ { if (insummary == 1) failcnt += \$5; next; }
363 /^# of expected failures/ { if (insummary == 1) xfailcnt += \$5; next; }
364 /^# of unknown successes/ { if (insummary == 1) kpasscnt += \$5; next; }
365 /^# of known failures/ { if (insummary == 1) kfailcnt += \$5; next; }
366 /^# of untested testcases/ { if (insummary == 1) untstcnt += \$5; next; }
367 /^# of unresolved testcases/ { if (insummary == 1) unrescnt += \$5; next; }
368 /^# of unsupported tests/ { if (insummary == 1) unsupcnt += \$5; next; }
369 /^$/ { if (insummary == 1)
370 { insummary = 0; curvar = "" }
375 printf ("\t\t=== %s Summary for %s ===\n\n", tool, variant)
376 if (passcnt != 0) printf ("# of expected passes\t\t%d\n", passcnt)
377 if (failcnt != 0) printf ("# of unexpected failures\t%d\n", failcnt)
378 if (xpasscnt != 0) printf ("# of unexpected successes\t%d\n", xpasscnt)
379 if (xfailcnt != 0) printf ("# of expected failures\t\t%d\n", xfailcnt)
380 if (kpasscnt != 0) printf ("# of unknown successes\t\t%d\n", kpasscnt)
381 if (kfailcnt != 0) printf ("# of known failures\t\t%d\n", kfailcnt)
382 if (untstcnt != 0) printf ("# of untested testcases\t\t%d\n", untstcnt)
383 if (unrescnt != 0) printf ("# of unresolved testcases\t%d\n", unrescnt)
384 if (unsupcnt != 0) printf ("# of unsupported tests\t\t%d\n", unsupcnt)
388 PVAR
=`echo $VAR | sed 's,/,.,g'`
389 TMPFILE
=${TMP}/var-
$PVAR
392 cat ${TMP}/expfiles
$SUM_FILES |
$AWK -f $GUTS_AWK
393 cat $SUM_FILES |
$AWK -f $SUMS_AWK > $TMPFILE
394 # If there are multiple variants, output the counts for this one;
395 # otherwise there will just be the final counts at the end.
396 test $VARIANT_COUNT -eq 1 ||
cat $TMPFILE
399 # Set up an awk script to get the combined summary counts for the tool.
401 TOTAL_AWK
=${TMP}/total.
awk
402 cat << EOF > $TOTAL_AWK
405 passcnt=0; failcnt=0; untstcnt=0; xpasscnt=0; xfailcnt=0; kfailcnt=0; unsupcnt=0; unrescnt=0
407 /^# of expected passes/ { passcnt += \$5 }
408 /^# of unexpected failures/ { failcnt += \$5 }
409 /^# of unexpected successes/ { xpasscnt += \$5 }
410 /^# of expected failures/ { xfailcnt += \$5 }
411 /^# of unknown successes/ { kpasscnt += \$5 }
412 /^# of known failures/ { kfailcnt += \$5 }
413 /^# of untested testcases/ { untstcnt += \$5 }
414 /^# of unresolved testcases/ { unrescnt += \$5 }
415 /^# of unsupported tests/ { unsupcnt += \$5 }
417 printf ("\n\t\t=== %s Summary ===\n\n", tool)
418 if (passcnt != 0) printf ("# of expected passes\t\t%d\n", passcnt)
419 if (failcnt != 0) printf ("# of unexpected failures\t%d\n", failcnt)
420 if (xpasscnt != 0) printf ("# of unexpected successes\t%d\n", xpasscnt)
421 if (xfailcnt != 0) printf ("# of expected failures\t\t%d\n", xfailcnt)
422 if (kpasscnt != 0) printf ("# of unknown successes\t\t%d\n", kpasscnt)
423 if (kfailcnt != 0) printf ("# of known failures\t\t%d\n", kfailcnt)
424 if (untstcnt != 0) printf ("# of untested testcases\t\t%d\n", untstcnt)
425 if (unrescnt != 0) printf ("# of unresolved testcases\t%d\n", unrescnt)
426 if (unsupcnt != 0) printf ("# of unsupported tests\t\t%d\n", unsupcnt)
430 # Find the total summaries for the tool and add to the end of the output.
431 cat ${TMP}/var-
* |
$AWK -f $TOTAL_AWK
433 # This is ugly, but if there's version output from the compiler under test
434 # at the end of the file, we want it. The other thing that might be there
435 # is the final summary counts.
436 tail -2 $FIRST_SUM |
grep '^#' > /dev
/null ||
tail -2 $FIRST_SUM
This page took 0.038681 seconds and 4 git commands to generate.