This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, testsuite] Print pattern for scan-assembler-times like scan-assembler


For scan-assembler-times and some other asm-scanning functions the pattern is
printed unescaped in the full test name.  This causes strange multi-line
entries in the summary file.  Note that the two main functions scan-assembler
and scan-assembler-not don't suffer from this problem.  The patch fixes the
other ones.  E.g.:

-PASS: g++.dg/debug/dwarf2/imported-decl-1.C scan-assembler-times var2[^
-]*DW_AT_name 1
+PASS: g++.dg/debug/dwarf2/imported-decl-1.C scan-assembler-times var2[^\n\r]*DW_AT_name 1

Tested on x86_64-linux-gnu.  Also tested mips.exp for mips64octeon-linux-gnu.

OK to install?

Adam


	* lib/scanasm.exp (make_pattern_printable): New function.
	(dg-scan, scan-assembler-times, scan-assembler-dem,
	scan-assembler-dem-not): Use it.

Index: scanasm.exp
===================================================================
--- scanasm.exp	(revision 151703)
+++ scanasm.exp	(working copy)
@@ -19,6 +19,11 @@
 
 # Utility for scanning compiler result, invoked via dg-final.
 
+# Transform newline and similar characters into their escaped form.
+proc make_pattern_printable { pattern } {
+    return [string map {\t \\t \n \\n \r \\r \\ \\\\} $pattern]
+}
+
 # Scan the OUTPUT_FILE for a pattern.  If it is present and POSITIVE
 # is non-zero, or it is not present and POSITIVE is zero, the test
 # passes.  The ORIG_ARGS is the list of arguments provided by dg-final
@@ -52,7 +57,7 @@ proc dg-scan { name positive testcase ou
     close $fd
 
     set pattern [lindex $orig_args 0]
-    set printable_pattern [string map {\t \\t \n \\n \r \\r \\ \\\\} $pattern]
+    set printable_pattern [make_pattern_printable $pattern]
 
     set match [regexp -- $pattern $text]
     if { $match == $positive } {
@@ -181,10 +186,12 @@ proc scan-assembler-times { args } {
     set text [read $fd]
     close $fd
 
-    if { [llength [regexp -inline -all -- [lindex $args 0] $text]] == [lindex $args 1]} {
-	pass "$testcase scan-assembler-times [lindex $args 0] [lindex $args 1]"
+    set pattern [lindex $args 0]
+    set pp_pattern [make_pattern_printable $pattern]
+    if { [llength [regexp -inline -all -- $pattern $text]] == [lindex $args 1]} {
+	pass "$testcase scan-assembler-times $pp_pattern [lindex $args 1]"
     } else {
-	fail "$testcase scan-assembler-times [lindex $args 0] [lindex $args 1]"
+	fail "$testcase scan-assembler-times $pp_pattern [lindex $args 1]"
     }
 }
 
@@ -228,10 +235,12 @@ proc scan-assembler-dem { args } {
     set output [remote_exec host "$cxxfilt" "" "$output_file"]
     set text [lindex $output 1]
 
-    if [regexp -- [lindex $args 0] $text] {
-	pass "$testcase scan-assembler-dem [lindex $args 0]"
+    set pattern [lindex $args 0]
+    set pp_pattern [make_pattern_printable $pattern]
+    if [regexp -- $pattern $text] {
+	pass "$testcase scan-assembler-dem $pp_pattern"
     } else {
-	fail "$testcase scan-assembler-dem [lindex $args 0]"
+	fail "$testcase scan-assembler-dem $pp_pattern"
     }
 }
 
@@ -274,9 +283,11 @@ proc scan-assembler-dem-not { args } {
     set output [remote_exec host "$cxxfilt" "" "$output_file"]
     set text [lindex $output 1]
 
-    if ![regexp -- [lindex $args 0] $text] {
-	pass "$testcase scan-assembler-dem-not [lindex $args 0]"
+    set pattern [lindex $args 0]
+    set pp_pattern [make_pattern_printable $pattern]
+    if ![regexp -- $pattern $text] {
+	pass "$testcase scan-assembler-dem-not $pp_pattern"
     } else {
-	fail "$testcase scan-assembler-dem-not [lindex $args 0]"
+	fail "$testcase scan-assembler-dem-not $pp_pattern"
     }
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]