diff mbox series

Fix up dg-extract-results.sh

Message ID 20190417155915.GW21066@tucnak
State New
Headers show
Series Fix up dg-extract-results.sh | expand

Commit Message

Jakub Jelinek April 17, 2019, 3:59 p.m. UTC
Hi!

On Tue, Apr 16, 2019 at 09:26:46PM +0200, Christophe Lyon wrote:
> > Actually, I managed to reproduce in a Fedora 31 chroot, in which I don't
> > have /usr/bin/python installed (I think in Fedora 30+ there is
> > /usr/bin/python2 and /usr/bin/python3 but not /usr/bin/python, at least not
> > in the default buildroot).

So, I've grabbed 11 *.log and 11 *.sum files from testsuite/gcc*/, injected
a couple of
-PASS: gcc.c-torture/execute/20001009-2.c   -O1  execution test
+WARNING: program timed out.
+FAIL: gcc.c-torture/execute/20001009-2.c   -O1  execution test
changes into them (both to *.log and *.sum) and tested, each time
with dg-extract-results.sh -L *.log > logN and dg-extract-results.sh *.sum > sumN
The tested versions were:
1) gcc-8
2) current trunk
3) current trunk with this patch
(all of them with /usr/bin/python available, so effectively using the python
version) and
4) gcc-8
5) current trunk
6) current trunk with this patch
contrib/dg-extract-results.sh copied to /tmp/dg-extract-results.sh so that
it doesn't find the python version and thus uses awk.  I found a couple of
issues in the patch I've sent earlier, so this contains fixes.
973bf331c5f223a08a4724289635fe43  log1
973bf331c5f223a08a4724289635fe43  log2
973bf331c5f223a08a4724289635fe43  log3
b7fde321188f9d60265c2801fb8e81e9  log4
26e7dc514ab063b99d2929759826814b  log5
b7fde321188f9d60265c2801fb8e81e9  log6
d6a24e581653e284d9db118cca48f72c  sum1
ca25461808ea1f9b061409fe096f286f  sum2
ca25461808ea1f9b061409fe096f286f  sum3
33e194e093632290a5d5bd16cb15ca10  sum4
f82f4a60a095655d7359700b7bf688e1  sum5
f82f4a60a095655d7359700b7bf688e1  sum6

Thus, there is no change in -L log mode generation between any of those 3 python
versions (note, the patch just changes a comment typo in the *.py, so 2 and
3 are expected to be identical with -L), and appart from the broken trunk
handling of -L gcc 8 as well as trunk with this patch generate the same
logfile too (though, not identical to python).
As for the sum mode, gcc 8 generated with both python and sh/awk different
results from trunk and trunk with patch, with the WARNING: program timed out.
lines sorted together at one spot, while trunk and trunk with patch emit
identical result (though, again, python generates different ordering from
sh/awk).  So, I believe with this patch the results are exactly as I expect
them, the *.sum WARNING: thing is improved as Christophe wanted, while
*.log files which are broken on current trunk totally when not using python
are fixed again.

The incremental fixes from previous patch are using correct operator for
$0 matching and also, as we use timeout_cnt value of 0 with the meaning that
no timeout message needs to be handled, but in theory
WARNING: program timed out. could appear also with cnt == 0, I've made
that var contain otherwise cnt + 1 and subtract 1 again when printing it.

Ok for trunk?

2019-04-17  Jakub Jelinek  <jakub@redhat.com>

	* dg-extract-results.sh: Only handle WARNING: program timed out
	lines specially in "$MODE" == "sum".  Restore previous behavior
	for "$MODE" != "sum".  Clear has_timeout and timeout_cnt if in
	a different variant or curfile is empty.
	* dg-extract-results.py: Fix a typo.



	Jakub

Comments

Mike Stump April 17, 2019, 4:44 p.m. UTC | #1
On Apr 17, 2019, at 8:59 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Ok for trunk?

Ok.
Christophe Lyon April 17, 2019, 8:36 p.m. UTC | #2
On Wed, 17 Apr 2019 at 18:44, Mike Stump <mikestump@comcast.net> wrote:
>
> On Apr 17, 2019, at 8:59 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > Ok for trunk?
>
> Ok.

Thanks!
diff mbox series

Patch

--- contrib/dg-extract-results.sh.jj	2019-03-05 21:49:34.471573434 +0100
+++ contrib/dg-extract-results.sh	2019-04-17 17:35:53.718285283 +0200
@@ -331,13 +331,15 @@  BEGIN {
   # Ugly hack for gfortran.dg/dg.exp
   if ("$TOOL" == "gfortran" && testname ~ /^gfortran.dg\/g77\//)
     testname="h"testname
-  if (\$1 == "WARNING:" && \$2 == "program" && \$3 == "timed" && (\$4 == "out" || \$4 == "out.")) {
-        has_timeout=1
-        timeout_cnt=cnt
-  } else {
-  # Prepare timeout replacement message in case it's needed
-    timeout_msg=\$0
-    sub(\$1, "WARNING:", timeout_msg)
+  if ("$MODE" == "sum") {
+    if (\$0 ~ /^WARNING: program timed out/) {
+      has_timeout=1
+      timeout_cnt=cnt+1
+    } else {
+      # Prepare timeout replacement message in case it's needed
+      timeout_msg=\$0
+      sub(\$1, "WARNING:", timeout_msg)
+    }
   }
 }
 /^$/ { if ("$MODE" == "sum") next }
@@ -345,25 +347,30 @@  BEGIN {
     if ("$MODE" == "sum") {
       # Do not print anything if the current line is a timeout
       if (has_timeout == 0) {
-        # If the previous line was a timeout,
-        # insert the full current message without keyword
-        if (timeout_cnt != 0) {
-          printf "%s %08d|%s program timed out.\n", testname, timeout_cnt, timeout_msg >> curfile
-          timeout_cnt = 0
-          cnt = cnt + 1
-        }
-        printf "%s %08d|", testname, cnt >> curfile
-        cnt = cnt + 1
-        filewritten[curfile]=1
-        need_close=1
-        if (timeout_cnt == 0)
-          print >> curfile
+	# If the previous line was a timeout,
+	# insert the full current message without keyword
+	if (timeout_cnt != 0) {
+	  printf "%s %08d|%s program timed out.\n", testname, timeout_cnt-1, timeout_msg >> curfile
+	  timeout_cnt = 0
+	  cnt = cnt + 1
+	}
+	printf "%s %08d|", testname, cnt >> curfile
+	cnt = cnt + 1
+	filewritten[curfile]=1
+	need_close=1
+	print >> curfile
       }
-
       has_timeout=0
+    } else {
+      filewritten[curfile]=1
+      need_close=1
+      print >> curfile
     }
-  } else
+  } else {
+    has_timeout=0
+    timeout_cnt=0
     next
+  }
 }
 END {
   n=1
--- contrib/dg-extract-results.py.jj	2019-03-05 21:49:34.471573434 +0100
+++ contrib/dg-extract-results.py	2019-04-16 17:14:54.447248209 +0200
@@ -296,7 +296,7 @@  class Prog:
                 # If we have a time out warning, make sure it appears
                 # before the following testcase diagnostic: we insert
                 # the testname before 'program' so that sort faces a
-                # list of testhanes.
+                # list of testnames.
                 if line.startswith ('WARNING: program timed out'):
                   has_warning = 1
                 else: