From 4851726d28a60d59345e8a8ab06575885d98e74f Mon Sep 17 00:00:00 2001 From: Adam Nemet Date: Thu, 24 Sep 2009 18:27:31 +0000 Subject: [PATCH] scanasm.exp (make_pattern_printable): New function. * lib/scanasm.exp (make_pattern_printable): New function. (dg-scan, scan-assembler-times, scan-assembler-dem, scan-assembler-dem-not): Use it. From-SVN: r152136 --- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/lib/scanasm.exp | 31 +++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8e5395f..51993a1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2009-09-24 Adam Nemet + + * lib/scanasm.exp (make_pattern_printable): New function. + (dg-scan, scan-assembler-times, scan-assembler-dem, + scan-assembler-dem-not): Use it. + 2009-09-24 H.J. Lu * gcc.target/i386/pr12329.c (dg-do): Changed to run. diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp index 24de187..abc01b7 100644 --- a/gcc/testsuite/lib/scanasm.exp +++ b/gcc/testsuite/lib/scanasm.exp @@ -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 output_file orig_args } { 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" } } -- 2.7.4