2 # Copyright (C) 2006, 2008 Free Software Foundation
4 # Analyze changes in GCC DejaGNU test logs for binutils, gcc, gdb, etc.
5 # Original version written in 2005 by James Lemke <jwlemke@wasabisystems.com>.
12 dg-cmp-results.sh [-v] [-v] [-v] <variant-name> <old-file> <new-file>
13 <variant-name> names the desired variant, "/" must be written as "\/".
14 Use the empty string ("") for the first variant in each file.
16 Non-verbose output is degradation info like PASS->FAIL.
17 -v adds improvement info like FAIL->PASS.
18 -v -v adds info like tests that are no longer run.
19 -v -v -v adds info for tests that have not changed status.
20 -v -v -v -v is used for debugging.
25 while test "$1" = "-v"; do
26 verbose
=`expr $verbose + 1`
30 if test $# -ne 3 ; then
35 if test ! -f "$2"; then
36 echo "unable to open $2" >&2
40 if test ! -f "$3"; then
41 echo "unable to open $3" >&2
45 # Command differences for various platforms.
55 # sections are identified by separator lines beginning with '\t\t==='.
56 # section 0 identifies run date, target, and host.
57 # section 1 and subsequent contain test data for a target variant.
58 # -skip to /^Running target/ and use that line to identify the variant.
59 # -subsequent lines contain the result data. They begin with:
60 # '(PASS|FAIL|XFAIL|XPASS|UNTESTED|UNSUPPORTED|UNRESOLVED):'
67 echo "dg-cmp-results.sh: Verbosity is ${verbose}, Variant is \"${VARIANT}\""
70 header
="^Running target $VARIANT"
72 temp
=`grep "$header" $OFILE`
73 if test -z "$temp"; then
74 echo "Error: variant \"$VARIANT\" not found in $OFILE."
77 temp
=`grep "$header" $NFILE`
78 if test -z "$temp"; then
79 echo "Error: variant \"$VARIANT\" not found in $NFILE."
84 # Copy out the old file's section 0.
85 echo "Older log file: $OFILE"
86 sed $E -e '/^[[:space:]]+===/,$d' $OFILE
88 # Copy out the new file's section 0.
89 echo "Newer log file: $NFILE"
90 sed $E -e '/^[[:space:]]+===/,$d' $NFILE
92 # Create a temporary file from the old file's interesting section.
93 sed $E -e "/$header/,/^[[:space:]]+===.*Summary ===/!d" \
95 -e '/^(WARNING|ERROR):/d' \
99 sort -s -t : -k 3b
- \
102 # Create a temporary file from the new file's interesting section.
103 sed $E -e "/$header/,/^[[:space:]]+===.*Summary ===/!d" \
105 -e '/^(WARNING|ERROR):/d' \
109 sort -s -t : -k 3b
- \
112 # Merge the two files, then compare adjacent lines.
113 # Comparison is complicated by tests that may be run multiple times.
114 # If that case, we assume that the order is the same in both files.
115 cat <<EOF >compare-$$.awk
118 queue1 = 1; queueN = 0; status[queue1] = ""; name[queue1] = ""
119 verbose = verbose + 0 # Make sure it's defined.
122 # FIFO circular queue
123 function push(st, nm) {
124 queueN += 1; status[queueN] = st; name[queueN] = nm
128 if (queueN >= queue1) result = queue1
133 if (queue1 > queueN) { queue1 = 1; queueN = 0; }
136 function compare(st, nm) {
139 # This new test wasn't run last time.
140 if (verbose >= 2) printf("NA->%s:%s\n", st, nm)
143 # Compare this new test to the first queued old one.
145 printf("Comparing two lines:\n O:%s:%s\n N:%s:%s\n",
146 status[old], name[old], st, nm)
148 if (name[old] != nm) {
149 # The old test wasn't run this time and
150 # the new test wasn't run last time.
152 printf("%s->NA:%s\n", status[old], name[old])
153 if (nm != "") printf("NA->%s:%s\n", st, nm)
159 if (status[old] == st) {
160 # Status of this test has not changed.
161 if (verbose >= 3) printf("%s:%s\n", st, nm)
163 else if(status[old] == "PASS" && st == "XFAIL") {
164 if (verbose >= 1) notable = 1
166 else if(status[old] == "PASS" || st == "FAIL") {
167 # Test did pass but doesn't now
168 # or didn't fail but does now.
171 else if(st == "PASS") {
172 # Test didn't pass but does now.
173 if (verbose >= 1) notable = 1
175 else if(verbose >= 2) {
176 # Miscellaneous status change.
179 if (notable > 0) printf("%s->%s:%s\n", status[old], st, nm)
186 while (old = peek()) {
187 if (name[old] == \$3) break;
188 # The queued test is no longer run.
191 # Save this test for later comparison.
200 while (old = peek()) compare("", "")
203 sort -m -s -t : -k 3b
/tmp
/o$$
-$OBASE /tmp
/n$$
-$NBASE |
204 awk -v verbose
=$verbose -f compare-$$.
awk /dev
/stdin
206 # Delete the temporary files.
207 rm -f compare-$$.
awk /tmp
/o$$
-$OBASE /tmp
/n$$
-$NBASE