Mercurial > hg > CbC > CbC_gcc
comparison contrib/dg-extract-results.sh @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
4 # test results from one or more test summary (.sum) files and combine | 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. | 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 | 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. | 7 # results from tests that were run in parallel. See usage() below. |
8 | 8 |
9 # Copyright (C) 2008, 2009, 2010 Free Software Foundation | 9 # Copyright (C) 2008, 2009, 2010, 2012 Free Software Foundation |
10 # Contributed by Janis Johnson <janis187@us.ibm.com> | 10 # Contributed by Janis Johnson <janis187@us.ibm.com> |
11 # | 11 # |
12 # This file is part of GCC. | 12 # This file is part of GCC. |
13 # | 13 # |
14 # GCC is free software; you can redistribute it and/or modify | 14 # GCC is free software; you can redistribute it and/or modify |
26 # the Free Software Foundation, 51 Franklin Street, Fifth Floor, | 26 # the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
27 # Boston, MA 02110-1301, USA. | 27 # Boston, MA 02110-1301, USA. |
28 | 28 |
29 PROGNAME=dg-extract-results.sh | 29 PROGNAME=dg-extract-results.sh |
30 | 30 |
31 # Try to use the python version if possible, since it tends to be faster. | |
32 PYTHON_VER=`echo "$0" | sed 's/sh$/py/'` | |
33 if test "$PYTHON_VER" != "$0" && | |
34 test -f "$PYTHON_VER" && | |
35 python -c 'import sys, getopt, re, io, datetime, operator; sys.exit (0 if sys.version_info >= (2, 6) else 1)' \ | |
36 > /dev/null 2> /dev/null; then | |
37 exec python $PYTHON_VER "$@" | |
38 fi | |
39 | |
31 usage() { | 40 usage() { |
32 cat <<EOF >&2 | 41 cat <<EOF >&2 |
33 Usage: $PROGNAME [-t tool] [-l variant-list] [-L] sum-file ... | 42 Usage: $PROGNAME [-t tool] [-l variant-list] [-L] sum-file ... |
34 | 43 |
35 tool The tool (e.g. g++, libffi) for which to create a | 44 tool The tool (e.g. g++, libffi) for which to create a |
116 ERROR=1 | 125 ERROR=1 |
117 fi | 126 fi |
118 done | 127 done |
119 test $ERROR -eq 0 || exit 1 | 128 test $ERROR -eq 0 || exit 1 |
120 | 129 |
130 # Test if grep supports the '--text' option | |
131 | |
132 GREP=grep | |
133 | |
134 if echo -e '\x00foo\x00' | $GREP --text foo > /dev/null 2>&1 ; then | |
135 GREP="grep --text" | |
136 else | |
137 # Our grep does not recognize the '--text' option. We have to | |
138 # treat our files in order to remove any non-printable character. | |
139 for file in $SUM_FILES ; do | |
140 mv $file ${file}.orig | |
141 cat -v ${file}.orig > $file | |
142 done | |
143 fi | |
144 | |
121 if [ -z "$TOOL" ]; then | 145 if [ -z "$TOOL" ]; then |
122 # If no tool was specified, all specified summary files must be for | 146 # If no tool was specified, all specified summary files must be for |
123 # the same tool. | 147 # the same tool. |
124 | 148 |
125 CNT=`grep '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l` | 149 CNT=`$GREP '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l` |
126 if [ $CNT -eq 1 ]; then | 150 if [ $CNT -eq 1 ]; then |
127 TOOL=`grep '=== .* tests ===' $FIRST_SUM | $AWK '{ print $2 }'` | 151 TOOL=`$GREP '=== .* tests ===' $FIRST_SUM | $AWK '{ print $2 }'` |
128 else | 152 else |
129 msg "${PROGNAME}: sum files are for multiple tools, specify a tool" | 153 msg "${PROGNAME}: sum files are for multiple tools, specify a tool" |
130 msg "" | 154 msg "" |
131 usage | 155 usage |
132 exit 1 | 156 exit 1 |
133 fi | 157 fi |
134 else | 158 else |
135 # Ignore the specified summary files that are not for this tool. This | 159 # Ignore the specified summary files that are not for this tool. This |
136 # should keep the relevant files in the same order. | 160 # should keep the relevant files in the same order. |
137 | 161 |
138 SUM_FILES=`grep -l "=== $TOOL" $SUM_FILES` | 162 SUM_FILES=`$GREP -l "=== $TOOL" $SUM_FILES` |
139 if test -z "$SUM_FILES" ; then | 163 if test -z "$SUM_FILES" ; then |
140 msg "${PROGNAME}: none of the specified files are results for $TOOL" | 164 msg "${PROGNAME}: none of the specified files are results for $TOOL" |
141 exit 1 | 165 exit 1 |
142 fi | 166 fi |
143 fi | 167 fi |
222 else | 246 else |
223 VARS="$VARIANTS" | 247 VARS="$VARIANTS" |
224 VARIANTS="" | 248 VARIANTS="" |
225 for VAR in $VARS | 249 for VAR in $VARS |
226 do | 250 do |
227 grep "Running target $VAR" $SUM_FILES > /dev/null && VARIANTS="$VARIANTS $VAR" | 251 $GREP "Running target $VAR" $SUM_FILES > /dev/null && VARIANTS="$VARIANTS $VAR" |
228 done | 252 done |
229 fi | 253 fi |
230 | 254 |
231 # Find out if we have more than one variant, or any at all. | 255 # Find out if we have more than one variant, or any at all. |
232 | 256 |
286 next | 310 next |
287 } | 311 } |
288 /^Using / { | 312 /^Using / { |
289 if (variant == curvar && print_using) { print; next } | 313 if (variant == curvar && print_using) { print; next } |
290 } | 314 } |
291 /^Running / { | 315 /^Running .*\\.exp \\.\\.\\./ { |
292 print_using=0 | 316 print_using=0 |
293 if (variant == curvar) { | 317 if (variant == curvar) { |
294 if (need_close) close(curfile) | 318 if (need_close) close(curfile) |
295 curfile="${TMP}/list"expfilesr[\$2] | 319 curfile="${TMP}/list"expfilesr[\$2] |
296 expfileseen[\$2]=expfileseen[\$2] + 1 | 320 expfileseen[\$2]=expfileseen[\$2] + 1 |
343 rm -f $SUMS_AWK | 367 rm -f $SUMS_AWK |
344 cat << EOF > $SUMS_AWK | 368 cat << EOF > $SUMS_AWK |
345 BEGIN { | 369 BEGIN { |
346 variant="$VAR" | 370 variant="$VAR" |
347 tool="$TOOL" | 371 tool="$TOOL" |
348 passcnt=0; failcnt=0; untstcnt=0; xpasscnt=0; xfailcnt=0; unsupcnt=0; unrescnt=0; | 372 passcnt=0; failcnt=0; untstcnt=0; xpasscnt=0; xfailcnt=0; kpasscnt=0; kfailcnt=0; unsupcnt=0; unrescnt=0; dgerrorcnt=0; |
349 curvar=""; insummary=0 | 373 curvar=""; insummary=0 |
350 } | 374 } |
351 /^Running target / { curvar = \$3; next } | 375 /^Running target / { curvar = \$3; next } |
376 /^ERROR: \(DejaGnu\)/ { if (variant == curvar) dgerrorcnt += 1 } | |
352 /^# of / { if (variant == curvar) insummary = 1 } | 377 /^# of / { if (variant == curvar) insummary = 1 } |
353 /^# of expected passes/ { if (insummary == 1) passcnt += \$5; next; } | 378 /^# of expected passes/ { if (insummary == 1) passcnt += \$5; next; } |
354 /^# of unexpected successes/ { if (insummary == 1) xpasscnt += \$5; next; } | 379 /^# of unexpected successes/ { if (insummary == 1) xpasscnt += \$5; next; } |
355 /^# of unexpected failures/ { if (insummary == 1) failcnt += \$5; next; } | 380 /^# of unexpected failures/ { if (insummary == 1) failcnt += \$5; next; } |
356 /^# of expected failures/ { if (insummary == 1) xfailcnt += \$5; next; } | 381 /^# of expected failures/ { if (insummary == 1) xfailcnt += \$5; next; } |
382 /^# of unknown successes/ { if (insummary == 1) kpasscnt += \$5; next; } | |
383 /^# of known failures/ { if (insummary == 1) kfailcnt += \$5; next; } | |
357 /^# of untested testcases/ { if (insummary == 1) untstcnt += \$5; next; } | 384 /^# of untested testcases/ { if (insummary == 1) untstcnt += \$5; next; } |
358 /^# of unresolved testcases/ { if (insummary == 1) unrescnt += \$5; next; } | 385 /^# of unresolved testcases/ { if (insummary == 1) unrescnt += \$5; next; } |
359 /^# of unsupported tests/ { if (insummary == 1) unsupcnt += \$5; next; } | 386 /^# of unsupported tests/ { if (insummary == 1) unsupcnt += \$5; next; } |
360 /^$/ { if (insummary == 1) | 387 /^$/ { if (insummary == 1) |
361 { insummary = 0; curvar = "" } | 388 { insummary = 0; curvar = "" } |
362 next | 389 next |
363 } | 390 } |
364 { next } | 391 { next } |
365 END { | 392 END { |
366 printf ("\t\t=== %s Summary for %s ===\n\n", tool, variant) | 393 printf ("\t\t=== %s Summary for %s ===\n\n", tool, variant) |
394 if (dgerrorcnt != 0) printf ("# of DejaGnu errors\t\t%d\n", dgerrorcnt) | |
367 if (passcnt != 0) printf ("# of expected passes\t\t%d\n", passcnt) | 395 if (passcnt != 0) printf ("# of expected passes\t\t%d\n", passcnt) |
368 if (failcnt != 0) printf ("# of unexpected failures\t%d\n", failcnt) | 396 if (failcnt != 0) printf ("# of unexpected failures\t%d\n", failcnt) |
369 if (xpasscnt != 0) printf ("# of unexpected successes\t%d\n", xpasscnt) | 397 if (xpasscnt != 0) printf ("# of unexpected successes\t%d\n", xpasscnt) |
370 if (xfailcnt != 0) printf ("# of expected failures\t\t%d\n", xfailcnt) | 398 if (xfailcnt != 0) printf ("# of expected failures\t\t%d\n", xfailcnt) |
399 if (kpasscnt != 0) printf ("# of unknown successes\t\t%d\n", kpasscnt) | |
400 if (kfailcnt != 0) printf ("# of known failures\t\t%d\n", kfailcnt) | |
371 if (untstcnt != 0) printf ("# of untested testcases\t\t%d\n", untstcnt) | 401 if (untstcnt != 0) printf ("# of untested testcases\t\t%d\n", untstcnt) |
372 if (unrescnt != 0) printf ("# of unresolved testcases\t%d\n", unrescnt) | 402 if (unrescnt != 0) printf ("# of unresolved testcases\t%d\n", unrescnt) |
373 if (unsupcnt != 0) printf ("# of unsupported tests\t\t%d\n", unsupcnt) | 403 if (unsupcnt != 0) printf ("# of unsupported tests\t\t%d\n", unsupcnt) |
374 } | 404 } |
375 EOF | 405 EOF |
389 | 419 |
390 TOTAL_AWK=${TMP}/total.awk | 420 TOTAL_AWK=${TMP}/total.awk |
391 cat << EOF > $TOTAL_AWK | 421 cat << EOF > $TOTAL_AWK |
392 BEGIN { | 422 BEGIN { |
393 tool="$TOOL" | 423 tool="$TOOL" |
394 passcnt=0; failcnt=0; untstcnt=0; xpasscnt=0; xfailcnt=0; unsupcnt=0; unrescnt=0 | 424 passcnt=0; failcnt=0; untstcnt=0; xpasscnt=0; xfailcnt=0; kfailcnt=0; unsupcnt=0; unrescnt=0; dgerrorcnt=0 |
395 } | 425 } |
426 /^# of DejaGnu errors/ { dgerrorcnt += \$5 } | |
396 /^# of expected passes/ { passcnt += \$5 } | 427 /^# of expected passes/ { passcnt += \$5 } |
397 /^# of unexpected failures/ { failcnt += \$5 } | 428 /^# of unexpected failures/ { failcnt += \$5 } |
398 /^# of unexpected successes/ { xpasscnt += \$5 } | 429 /^# of unexpected successes/ { xpasscnt += \$5 } |
399 /^# of expected failures/ { xfailcnt += \$5 } | 430 /^# of expected failures/ { xfailcnt += \$5 } |
431 /^# of unknown successes/ { kpasscnt += \$5 } | |
432 /^# of known failures/ { kfailcnt += \$5 } | |
400 /^# of untested testcases/ { untstcnt += \$5 } | 433 /^# of untested testcases/ { untstcnt += \$5 } |
401 /^# of unresolved testcases/ { unrescnt += \$5 } | 434 /^# of unresolved testcases/ { unrescnt += \$5 } |
402 /^# of unsupported tests/ { unsupcnt += \$5 } | 435 /^# of unsupported tests/ { unsupcnt += \$5 } |
403 END { | 436 END { |
404 printf ("\n\t\t=== %s Summary ===\n\n", tool) | 437 printf ("\n\t\t=== %s Summary ===\n\n", tool) |
438 if (dgerrorcnt != 0) printf ("# of DejaGnu errors\t\t%d\n", dgerrorcnt) | |
405 if (passcnt != 0) printf ("# of expected passes\t\t%d\n", passcnt) | 439 if (passcnt != 0) printf ("# of expected passes\t\t%d\n", passcnt) |
406 if (failcnt != 0) printf ("# of unexpected failures\t%d\n", failcnt) | 440 if (failcnt != 0) printf ("# of unexpected failures\t%d\n", failcnt) |
407 if (xpasscnt != 0) printf ("# of unexpected successes\t%d\n", xpasscnt) | 441 if (xpasscnt != 0) printf ("# of unexpected successes\t%d\n", xpasscnt) |
408 if (xfailcnt != 0) printf ("# of expected failures\t\t%d\n", xfailcnt) | 442 if (xfailcnt != 0) printf ("# of expected failures\t\t%d\n", xfailcnt) |
443 if (kpasscnt != 0) printf ("# of unknown successes\t\t%d\n", kpasscnt) | |
444 if (kfailcnt != 0) printf ("# of known failures\t\t%d\n", kfailcnt) | |
409 if (untstcnt != 0) printf ("# of untested testcases\t\t%d\n", untstcnt) | 445 if (untstcnt != 0) printf ("# of untested testcases\t\t%d\n", untstcnt) |
410 if (unrescnt != 0) printf ("# of unresolved testcases\t%d\n", unrescnt) | 446 if (unrescnt != 0) printf ("# of unresolved testcases\t%d\n", unrescnt) |
411 if (unsupcnt != 0) printf ("# of unsupported tests\t\t%d\n", unsupcnt) | 447 if (unsupcnt != 0) printf ("# of unsupported tests\t\t%d\n", unsupcnt) |
412 } | 448 } |
413 EOF | 449 EOF |
416 cat ${TMP}/var-* | $AWK -f $TOTAL_AWK | 452 cat ${TMP}/var-* | $AWK -f $TOTAL_AWK |
417 | 453 |
418 # This is ugly, but if there's version output from the compiler under test | 454 # 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 | 455 # at the end of the file, we want it. The other thing that might be there |
420 # is the final summary counts. | 456 # is the final summary counts. |
421 tail -2 $FIRST_SUM | grep '^#' > /dev/null || tail -2 $FIRST_SUM | 457 tail -2 $FIRST_SUM | $GREP '^#' > /dev/null || tail -2 $FIRST_SUM |
422 | 458 |
423 exit 0 | 459 exit 0 |