public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][dejagnu] truncate absolute file path into relative for dg-output
@ 2014-11-11 16:58 Jiong Wang
  2014-11-11 19:06 ` Mike Stump
  2014-11-12 14:10 ` Marek Polacek
  0 siblings, 2 replies; 5+ messages in thread
From: Jiong Wang @ 2014-11-11 16:58 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2673 bytes --]

currently, if a testcase use dg-output, then absolute file path will occur
in the test summary reported by dejagnu which is bad. because the summary
should only contain the test name and it's better to exclude all local test
machine info from the report.

dg-output eventually calls dejagnu generic function "dg-test" in /usr/share/dejagnu/dg.exp,
which has the following code:

   fail "$name output pattern test, is ${output}, should match $texttmp"

the ${output} is the warning or error messages given by gcc which is in absolute path.
I noticed in asan's local test method "asan-gtest", ${output} has been removed.

to make sure all testcase invoking dg-output don't contain absolute path in their test
summary, we need to do some post processing of gcc's output.

patch attached truncate any testcase name from absolute path into relative path, and in the
following logical:

   1. if the testcase name is something like gcc-top/gcc/testcase/g++.dg/ubsan/k.c,
      then truncate into:

        g++.dg/ubsan/k.c  (gcc-top/gcc/testcase/ removed)

   2. if the testcase name is not in testcase subdirectory, for example

        gcc-top/gcc/libsanitizer/sanitizer_common/sanitizer_allocator.cc

      then truncate into:

        gcc/libsanitizer/sanitizer_common/sanitizer_allocator.cc (gcc-top/ removed)

for example, the following test fail report:

   FAIL: c-c++-common/ubsan/float-cast-overflow-2.c   -O0
   output pattern test, is
   ^[[1m/work/Jiong/LOCAL-TEST/r217291/src/gcc/libsanitizer/ubsan/ubsan_handlers.cc:300:
   ^[[1m^[[31m runtime error: ^[[1m^[[0m^[[1mvalue 1.70141e+38 is outside the range
   of representable values of type '__int128'^[[1m^[[0m^M

will become:

   FAIL: c-c++-common/ubsan/float-cast-overflow-2.c   -O0
   output pattern test, is
   ^[[1mgcc/libsanitizer/ubsan/ubsan_handlers.cc:300:
   ^[[1m^[[31m runtime error: ^[[1m^[[0m^[[1mvalue 1.70141e+38 is outside the range
   of representable values of type '__int128'^[[1m^[[0m^M

The revision number contained in the file path in the old FAIL summary, the next day if
only the revision number changed, the diff script will think a new pattern failed.

I think remove those local info could keep the test info clean, and easier for post processing.

currently, only sanitizer tess (asan/tsan/ubsan) and a couple of fortran test will invoke dg-output.

pass x86-64 c/c++ regression.
pass aarch64-none-linux-gnu c/c++ regression.

ok for trunk?

Thanks.

gcc/testsuite/
   * lib/gcc-dg.exp (${tool}_load): Truncate gcc output.
   * lib/prune.exp (prune_gcc_output): New absolute path to relative path truncation pattern.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: deja-abs-to-rel.patch --]
[-- Type: text/x-patch; name=deja-abs-to-rel.patch, Size: 1529 bytes --]

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index a0d1e7d..8168a77 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -281,6 +281,8 @@ if { [info procs ${tool}_load] != [list] \
 	    }
 	    set result [list $status [lindex $result 1]]
 	}
+
+	set result [list [lindex $result 0] [prune_gcc_output [lindex $result 1]]]
 	return $result
     }
 }
diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
index 679d894..b8b4417 100644
--- a/gcc/testsuite/lib/prune.exp
+++ b/gcc/testsuite/lib/prune.exp
@@ -22,6 +22,8 @@ if ![info exists TEST_ALWAYS_FLAGS] {
 set TEST_ALWAYS_FLAGS "-fno-diagnostics-show-caret -fdiagnostics-color=never $TEST_ALWAYS_FLAGS"
 
 proc prune_gcc_output { text } {
+    global srcdir
+
     #send_user "Before:$text\n"
 
     regsub -all "(^|\n)(\[^\n\]*: )?In ((static member |lambda )?function|member|method|(copy )?constructor|destructor|instantiation|substitution|program|subroutine|block-data)\[^\n\]*" $text "" text
@@ -65,6 +67,11 @@ proc prune_gcc_output { text } {
     # Ignore harmless warnings from Xcode 4.0.
     regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact unwind for\[^\n\]*" $text "" text
 
+    # Truncate absolute file path into relative path.
+    set topdir "[file dirname [file dirname [file dirname $srcdir]]]"
+    regsub -all "$srcdir\/" $text "" text
+    regsub -all "$topdir\/" $text "" text
+
     #send_user "After:$text\n"
 
     return $text

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][dejagnu] truncate absolute file path into relative for dg-output
  2014-11-11 16:58 [PATCH][dejagnu] truncate absolute file path into relative for dg-output Jiong Wang
@ 2014-11-11 19:06 ` Mike Stump
  2014-11-12 14:10 ` Marek Polacek
  1 sibling, 0 replies; 5+ messages in thread
From: Mike Stump @ 2014-11-11 19:06 UTC (permalink / raw)
  To: Jiong Wang; +Cc: gcc-patches

On Nov 11, 2014, at 8:51 AM, Jiong Wang <jiong.wang@arm.com> wrote:
> currently, if a testcase use dg-output, then absolute file path will occur
> in the test summary reported by dejagnu which is bad.

> ok for trunk?

Ok.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][dejagnu] truncate absolute file path into relative for dg-output
  2014-11-11 16:58 [PATCH][dejagnu] truncate absolute file path into relative for dg-output Jiong Wang
  2014-11-11 19:06 ` Mike Stump
@ 2014-11-12 14:10 ` Marek Polacek
  2014-11-12 14:38   ` Jiong Wang
  2014-11-12 18:35   ` Mike Stump
  1 sibling, 2 replies; 5+ messages in thread
From: Marek Polacek @ 2014-11-12 14:10 UTC (permalink / raw)
  To: Jiong Wang, Mike Stump; +Cc: gcc-patches

On Tue, Nov 11, 2014 at 04:51:38PM +0000, Jiong Wang wrote:
> currently, only sanitizer tess (asan/tsan/ubsan) and a couple of fortran test will invoke dg-output.
> 
> pass x86-64 c/c++ regression.
> pass aarch64-none-linux-gnu c/c++ regression.

This patch broke a few tests in ubsan.exp.  The reason is that...

> diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
> index a0d1e7d..8168a77 100644
> --- a/gcc/testsuite/lib/gcc-dg.exp
> +++ b/gcc/testsuite/lib/gcc-dg.exp
> @@ -281,6 +281,8 @@ if { [info procs ${tool}_load] != [list] \
>  	    }
>  	    set result [list $status [lindex $result 1]]
>  	}
> +
> +	set result [list [lindex $result 0] [prune_gcc_output [lindex $result 1]]]

... prune_gcc_output prunes more than just absolute file paths, it
prunes even the "note: " messages.  And several ubsan tests have
/* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
but since the note's are already gone, the test fails.

The following patch moves the path prunning code into a separate
procedure and fixes the failures.

Ok for trunk?

2014-11-12  Marek Polacek  <polacek@redhat.com>

	* lib/gcc-dg.exp (${tool}_load): Call prune_file_path instead
	of prune_gcc_output.
	* lib/prune.exp (prune_file_path): New procedure.

diff --git gcc/testsuite/lib/gcc-dg.exp gcc/testsuite/lib/gcc-dg.exp
index 8168a77..6df8ae1 100644
--- gcc/testsuite/lib/gcc-dg.exp
+++ gcc/testsuite/lib/gcc-dg.exp
@@ -282,7 +282,7 @@ if { [info procs ${tool}_load] != [list] \
 	    set result [list $status [lindex $result 1]]
 	}
 
-	set result [list [lindex $result 0] [prune_gcc_output [lindex $result 1]]]
+	set result [list [lindex $result 0] [prune_file_path [lindex $result 1]]]
 	return $result
     }
 }
diff --git gcc/testsuite/lib/prune.exp gcc/testsuite/lib/prune.exp
index 65028c2..df0e053 100644
--- gcc/testsuite/lib/prune.exp
+++ gcc/testsuite/lib/prune.exp
@@ -68,13 +68,19 @@ proc prune_gcc_output { text } {
     # Ignore harmless warnings from Xcode 4.0.
     regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact unwind for\[^\n\]*" $text "" text
 
+    #send_user "After:$text\n"
+
+    return $text
+}
+
+proc prune_file_path { text } {
+    global srcdir
+
     # Truncate absolute file path into relative path.
     set topdir "[file dirname [file dirname [file dirname $srcdir]]]"
     regsub -all "$srcdir\/" $text "" text
     regsub -all "$topdir\/" $text "" text
 
-    #send_user "After:$text\n"
-
     return $text
 }
 
	Marek

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][dejagnu] truncate absolute file path into relative for dg-output
  2014-11-12 14:10 ` Marek Polacek
@ 2014-11-12 14:38   ` Jiong Wang
  2014-11-12 18:35   ` Mike Stump
  1 sibling, 0 replies; 5+ messages in thread
From: Jiong Wang @ 2014-11-12 14:38 UTC (permalink / raw)
  To: Marek Polacek, Mike Stump; +Cc: gcc-patches

On 12/11/14 14:09, Marek Polacek wrote:

>
> ... prune_gcc_output prunes more than just absolute file paths, it
> prunes even the "note: " messages.  And several ubsan tests have
> /* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
> but since the note's are already gone, the test fails.
>
> The following patch moves the path prunning code into a separate
> procedure and fixes the failures.

thanks, this make sense, and LGTM.

(my fault, my test diff base must be wrong...)

>
> Ok for trunk?
>
> 2014-11-12  Marek Polacek  <polacek@redhat.com>
>
> 	* lib/gcc-dg.exp (${tool}_load): Call prune_file_path instead
> 	of prune_gcc_output.
> 	* lib/prune.exp (prune_file_path): New procedure.
>
> diff --git gcc/testsuite/lib/gcc-dg.exp gcc/testsuite/lib/gcc-dg.exp
> index 8168a77..6df8ae1 100644
> --- gcc/testsuite/lib/gcc-dg.exp
> +++ gcc/testsuite/lib/gcc-dg.exp
> @@ -282,7 +282,7 @@ if { [info procs ${tool}_load] != [list] \
>   	    set result [list $status [lindex $result 1]]
>   	}
>   
> -	set result [list [lindex $result 0] [prune_gcc_output [lindex $result 1]]]
> +	set result [list [lindex $result 0] [prune_file_path [lindex $result 1]]]
>   	return $result
>       }
>   }
> diff --git gcc/testsuite/lib/prune.exp gcc/testsuite/lib/prune.exp
> index 65028c2..df0e053 100644
> --- gcc/testsuite/lib/prune.exp
> +++ gcc/testsuite/lib/prune.exp
> @@ -68,13 +68,19 @@ proc prune_gcc_output { text } {
>       # Ignore harmless warnings from Xcode 4.0.
>       regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact unwind for\[^\n\]*" $text "" text
>   
> +    #send_user "After:$text\n"
> +
> +    return $text
> +}
> +
> +proc prune_file_path { text } {
> +    global srcdir
> +
>       # Truncate absolute file path into relative path.
>       set topdir "[file dirname [file dirname [file dirname $srcdir]]]"
>       regsub -all "$srcdir\/" $text "" text
>       regsub -all "$topdir\/" $text "" text
>   
> -    #send_user "After:$text\n"
> -
>       return $text
>   }
>   
> 	Marek
>
>
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][dejagnu] truncate absolute file path into relative for dg-output
  2014-11-12 14:10 ` Marek Polacek
  2014-11-12 14:38   ` Jiong Wang
@ 2014-11-12 18:35   ` Mike Stump
  1 sibling, 0 replies; 5+ messages in thread
From: Mike Stump @ 2014-11-12 18:35 UTC (permalink / raw)
  To: Marek Polacek; +Cc: Jiong Wang, gcc-patches

On Nov 12, 2014, at 6:09 AM, Marek Polacek <polacek@redhat.com> wrote:
> The following patch moves the path prunning code into a separate
> procedure and fixes the failures.
> 
> Ok for trunk?

Ok.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-12 18:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-11 16:58 [PATCH][dejagnu] truncate absolute file path into relative for dg-output Jiong Wang
2014-11-11 19:06 ` Mike Stump
2014-11-12 14:10 ` Marek Polacek
2014-11-12 14:38   ` Jiong Wang
2014-11-12 18:35   ` Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).