OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [contrib/] [dg-extract-results.sh] - Blame information for rev 740

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 723 jeremybenn
#! /bin/sh
2
 
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.
8
 
9
# Copyright (C) 2008, 2009, 2010 Free Software Foundation
10
# Contributed by Janis Johnson <janis187@us.ibm.com>
11
#
12
# This file is part of GCC.
13
#
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)
17
# any later version.
18
#
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.
23
#
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.
28
 
29
PROGNAME=dg-extract-results.sh
30
 
31
usage() {
32
  cat <<EOF >&2
33
Usage: $PROGNAME [-t tool] [-l variant-list] [-L] sum-file ...
34
 
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.
46
EOF
47
}
48
 
49
# Write a message to the standard error.
50
 
51
msg() {
52
  echo "$@" >&2
53
}
54
 
55
# Parse the command-line options.
56
 
57
VARIANTS=""
58
TOOL=""
59
MODE="sum"
60
 
61
while getopts "l:t:L" ARG; do
62
  case $ARG in
63
  l)  VARIANTS="${VARIANTS} ${OPTARG}";;
64
  t)  test -z "$TOOL" || (msg "${PROGNAME}: only one tool can be specified"; exit 1);
65
      TOOL="${OPTARG}";;
66
  L)  MODE="log";;
67
  \?) usage; exit 0;;
68
  esac
69
done
70
shift `expr ${OPTIND} - 1`
71
 
72
if test $# -lt 1 ; then
73
  usage
74
  exit 1
75
fi
76
 
77
TMPDIR=${TMPDIR-/tmp}
78
SUM_FILES="$@"
79
FIRST_SUM=$1
80
TMP=
81
trap 'EXIT_STATUS=$?; rm -rf $TMP && exit $EXIT_STATUS' 0
82
# Create a (secure) tmp directory for tmp files.
83
{
84
  TMP=`(umask 077 && mktemp -d -q "${TMPDIR}/dg-combine-results-$$-XXXXXX") 2>/dev/null` &&
85
  test -n "$TMP" && test -d "$TMP"
86
} ||
87
{
88
  TMP=${TMPDIR}/dg-combine-results-$$-$RANDOM
89
  (umask 077 && mkdir $TMP)
90
} ||
91
{
92
  msg "${PROGNAME}: cannot create a temporary directory"
93
  { (exit 1); exit 1; }
94
}
95
 
96
# Find a good awk.
97
 
98
if test -z "$AWK" ; then
99
  for AWK in gawk nawk awk
100
  do
101
    if type $AWK 2>&1 | grep 'not found' > /dev/null 2>&1 ; then
102
      :
103
    else
104
      break
105
    fi
106
  done
107
fi
108
 
109
# Verify that the specified summary files exist.
110
 
111
ERROR=0
112
for FILE in $SUM_FILES
113
do
114
  if ! test -f $FILE ; then
115
    msg "${PROGNAME}: file $FILE does not exist."
116
    ERROR=1
117
  fi
118
done
119
test $ERROR -eq 0 || exit 1
120
 
121
if [ -z "$TOOL" ]; then
122
  # If no tool was specified, all specified summary files must be for
123
  # the same tool.
124
 
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 }'`
128
  else
129
    msg "${PROGNAME}: sum files are for multiple tools, specify a tool"
130
    msg ""
131
    usage
132
    exit 1
133
  fi
134
else
135
  # Ignore the specified summary files that are not for this tool.  This
136
  # should keep the relevant files in the same order.
137
 
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"
141
    exit 1
142
  fi
143
fi
144
 
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
150
BEGIN {
151
  print_prologue=1; curfile=""; insummary=0
152
  passcnt=0; failcnt=0; unsupcnt=0; failures=""
153
}
154
/^[ \t]*=== acats configuration ===/ {
155
  insummary=0
156
  if (print_prologue) print
157
  next
158
}
159
/^[ \t]*=== acats tests ===/ {
160
  if (print_prologue) print
161
  print_prologue=0
162
  next
163
}
164
/^Running chapter / {
165
  if (curfile) close (curfile)
166
  curfile="${TMP}/chapter-"\$3
167
  print >> curfile
168
  next
169
}
170
/^[ \t]*=== acats Summary ===/ {
171
  if (curfile) close (curfile)
172
  curfile=""
173
  insummary=1
174
  next
175
}
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
183
  }
184
}
185
{
186
  if (print_prologue) { print; next }
187
  if (curfile) print >> curfile
188
}
189
END {
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
196
}
197
EOF
198
 
199
  rm -f ${TMP}/chapter-*
200
  $AWK -f $ACATS_AWK $SUM_FILES
201
  exit 0
202
fi
203
 
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.
207
 
208
if test -z "$VARIANTS" ; then
209
  VAR_AWK=${TMP}/variants.awk
210
  cat <<EOF > $VAR_AWK
211
/^Schedule of variations:/      { in_vars=1; next }
212
/^$/                            { in_vars=0 }
213
/^Running target/               { exit }
214
{ if (in_vars==1) print \$1; else next }
215
EOF
216
 
217
  touch ${TMP}/varlist
218
  for FILE in $SUM_FILES; do
219
    $AWK -f $VAR_AWK $FILE >> ${TMP}/varlist
220
  done
221
  VARIANTS="`sort -u ${TMP}/varlist`"
222
else
223
  VARS="$VARIANTS"
224
  VARIANTS=""
225
  for VAR in $VARS
226
  do
227
    grep "Running target $VAR" $SUM_FILES > /dev/null && VARIANTS="$VARIANTS $VAR"
228
  done
229
fi
230
 
231
# Find out if we have more than one variant, or any at all.
232
 
233
VARIANT_COUNT=0
234
for VAR in $VARIANTS
235
do
236
  VARIANT_COUNT=`expr $VARIANT_COUNT + 1`
237
done
238
 
239
if test $VARIANT_COUNT -eq 0 ; then
240
  msg "${PROGNAME}: no file for $TOOL has results for the specified variants"
241
  exit 1
242
fi
243
 
244
cat $SUM_FILES \
245
  | $AWK '/^Running/ { if ($2 != "target" && $3 == "...") print "EXPFILE: "$2 } ' \
246
  | sort -u > ${TMP}/expfiles
247
 
248
# Write the begining of the combined summary file.
249
 
250
head -n 2 $FIRST_SUM
251
echo
252
echo "          === $TOOL tests ==="
253
echo
254
echo "Schedule of variations:"
255
for VAR in $VARIANTS
256
do
257
  echo "    $VAR"
258
done
259
echo
260
 
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.
265
 
266
for VAR in $VARIANTS
267
do
268
  GUTS_AWK=${TMP}/guts.awk
269
  cat << EOF > $GUTS_AWK
270
BEGIN {
271
  variant="$VAR"
272
  firstvar=1
273
  expfileno=1
274
  cnt=0
275
  print_using=0
276
  need_close=0
277
}
278
/^EXPFILE: / {
279
  expfiles[expfileno] = \$2
280
  expfilesr[\$2] = expfileno
281
  expfileno = expfileno + 1
282
}
283
/^Running target / {
284
  curvar = \$3
285
  if (variant == curvar && firstvar == 1) { print; print_using=1; firstvar = 0 }
286
  next
287
}
288
/^Using / {
289
  if (variant == curvar && print_using) { print; next }
290
}
291
/^Running / {
292
  print_using=0
293
  if (variant == curvar) {
294
    if (need_close) close(curfile)
295
    curfile="${TMP}/list"expfilesr[\$2]
296
    expfileseen[\$2]=expfileseen[\$2] + 1
297
    need_close=0
298
    testname="00"
299
    next
300
  }
301
}
302
/^\t\t=== .* ===$/ { curvar = ""; next }
303
/^(PASS|XPASS|FAIL|XFAIL|UNRESOLVED|WARNING|ERROR|UNSUPPORTED|UNTESTED|KFAIL):/ {
304
  testname=\$2
305
  # Ugly hack for gfortran.dg/dg.exp
306
  if ("$TOOL" == "gfortran" && testname ~ /^gfortran.dg\/g77\//)
307
    testname="h"testname
308
}
309
/^$/ { if ("$MODE" == "sum") next }
310
{ if (variant == curvar && curfile) {
311
    if ("$MODE" == "sum") {
312
      printf "%s %08d|", testname, cnt >> curfile
313
      cnt = cnt + 1
314
    }
315
    filewritten[curfile]=1
316
    need_close=1
317
    print >> curfile
318
  } else
319
    next
320
}
321
END {
322
  n=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)
328
          cmd="cat"
329
        else
330
          cmd="LC_ALL=C sort"
331
        if ("$MODE" == "sum")
332
          system (cmd" ${TMP}/list"n" | sed -n 's/^[^ ]* [^ |]*|//p'")
333
        else
334
          system ("cat ${TMP}/list"n)
335
      }
336
    }
337
    n = n + 1
338
  }
339
}
340
EOF
341
 
342
  SUMS_AWK=${TMP}/sums.awk
343
  rm -f $SUMS_AWK
344
  cat << EOF > $SUMS_AWK
345
BEGIN {
346
  variant="$VAR"
347
  tool="$TOOL"
348
  passcnt=0; failcnt=0; untstcnt=0; xpasscnt=0; xfailcnt=0; unsupcnt=0; unrescnt=0;
349
  curvar=""; insummary=0
350
}
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 = "" }
362
                                  next
363
                                }
364
{ next }
365
END {
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)
374
}
375
EOF
376
 
377
  PVAR=`echo $VAR | sed 's,/,.,g'`
378
  TMPFILE=${TMP}/var-$PVAR
379
  rm -f $TMPFILE
380
  rm -f ${TMP}/list*
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
386
done
387
 
388
# Set up an awk script to get the combined summary counts for the tool.
389
 
390
TOTAL_AWK=${TMP}/total.awk
391
cat << EOF > $TOTAL_AWK
392
BEGIN {
393
  tool="$TOOL"
394
  passcnt=0; failcnt=0; untstcnt=0; xpasscnt=0; xfailcnt=0; unsupcnt=0; unrescnt=0
395
}
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 }
403
END {
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)
412
}
413
EOF
414
 
415
# Find the total summaries for the tool and add to the end of the output.
416
cat ${TMP}/var-* | $AWK -f $TOTAL_AWK
417
 
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 '^#' > /dev/null || tail -2 $FIRST_SUM
422
 
423
exit 0

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.