diff options
author | Andrew Burgess <aburgess@redhat.com> | 2023-05-02 10:56:55 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2023-05-05 17:59:21 +0100 |
commit | a5d3f94c271dde580980d82c2a8420bf6612e58c (patch) | |
tree | 3a70d7d66cd65ebf14526dab7f70d6efc8b05efc | |
parent | c5ba639d1b5ed9fe7ec8046e770e54679541f0e4 (diff) | |
download | binutils-a5d3f94c271dde580980d82c2a8420bf6612e58c.zip binutils-a5d3f94c271dde580980d82c2a8420bf6612e58c.tar.gz binutils-a5d3f94c271dde580980d82c2a8420bf6612e58c.tar.bz2 |
gdb/testsuite: more newline pattern cleanup
After this commit:
commit e2f620135d92f7cd670af4e524fffec7ac307666
Date: Thu Mar 30 13:26:25 2023 +0100
gdb/testsuite: change newline patterns used in gdb_test
It was pointed out in PR gdb/30403 that the same patterns can be found
in other lib/gdb.exp procs and that it would probably be a good idea
if these procs remained in sync with gdb_test. Actually, the bug
specifically calls out gdb_test_multiple when using with '-wrap', but
I found a couple of other locations in gdb_continue_to_breakpoint,
gdb_test_multiline, get_valueof, and get_local_valueof.
In all these locations one or both of the following issues are
addressed:
1. A leading pattern of '[\r\n]*' is pointless. If there is a
newline it will be matched, but if there is not then the testsuite
doesn't care. Also, as expect is happy to skip non-matched output
at the start of a pattern, if there is a newline expect is happy to
skip over it before matching the rest. As such, this leading
pattern is removed.
2. Using '\[\r\n\]*$gdb_prompt' means that we will swallow
unexpected blank lines at the end of a command's output, but also,
if the pattern from the test script ends with a '\r', '\n', or '.'
then these will partially match the trailing newline, with the
remainder of the newline matched by the pattern from gdb.exp. This
split matching doesn't add any value, it's just something that has
appeared as a consequence of how gdb.exp was originally written. In
this case the '\[\r\n\]*' is replaced with '\r\n'.
I've rerun the testsuite and fixed the regressions that I saw, these
were places where GDB emits a blank line at the end of the command
output, which we now need to explicitly match in the test script, this
was for:
gdb.dwarf2/dw2-out-of-range-end-of-seq.exp
gdb.guile/guile.exp
gdb.python/python.exp
Or a location where the test script was matching part of the newline
sequence, while gdb.exp was previously matching the remainder of the
newline sequence. Now we rely on gdb.exp to match the complete
newline sequence, this was for:
gdb.base/commands.exp
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30403
-rw-r--r-- | gdb/testsuite/gdb.base/commands.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.guile/guile.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/python.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 10 |
5 files changed, 9 insertions, 9 deletions
diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp index ec2015e..36918ed 100644 --- a/gdb/testsuite/gdb.base/commands.exp +++ b/gdb/testsuite/gdb.base/commands.exp @@ -725,7 +725,7 @@ maintenance deprecate set qqq_aaa" proc_with_prefix deprecated_command_alias_help_test {} { gdb_test_multiline "define real_command" \ - "define real_command" "End with a line saying just \"end\".." \ + "define real_command" "End with a line saying just \"end\"\\." \ "print 1" "" \ "end" "" diff --git a/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp b/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp index bd3ea5b..d2c28a8 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp @@ -88,7 +88,7 @@ gdb_test_multiple "maint info line-table $srcfile$" $test { -re -wrap "END *0x0*1 *$hex *Y *\r\n.*" { fail $gdb_test_name } - -re -wrap "END *$hex *$hex *Y *" { + -re -wrap "END *$hex *$hex *Y *\r\n" { pass $gdb_test_name } } diff --git a/gdb/testsuite/gdb.guile/guile.exp b/gdb/testsuite/gdb.guile/guile.exp index 7d0c063..ee8b271 100644 --- a/gdb/testsuite/gdb.guile/guile.exp +++ b/gdb/testsuite/gdb.guile/guile.exp @@ -63,7 +63,7 @@ gdb_test_multiline "show guile command" \ "(print 23)" "" \ "end" "" \ "end" "" \ - "show user zzq" "User command \"zzq\":.* guile.*\\(print 23\\).* end" + "show user zzq" "User command \"zzq\":.* guile.*\\(print 23\\).* end\r\n" gdb_test "source $host_source2_scm" "yes" "source source2.scm" diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index 7e9ddaa..584e52c 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -80,7 +80,7 @@ gdb_test_multiline "show python command" \ "print (23)" "" \ "end" "" \ "end" "" \ - "show user zzq" "User command \"zzq\":.* python.*print \\(23\\).* end" + "show user zzq" "User command \"zzq\":.* python.*print \\(23\\).* end\r\n" gdb_test_multiline "indented multi-line python command" \ "python" "" \ diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index aed7e2d..50c1033 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -818,7 +818,7 @@ proc gdb_continue_to_breakpoint {name {location_pattern .*}} { -re "(?:Breakpoint|Temporary breakpoint) .* (at|in) $location_pattern\r\n$gdb_prompt $" { pass $full_name } - -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { + -re "(?:$kfail_pattern)\r\n$gdb_prompt $" { kfail "gdb/25038" $full_name } } @@ -1126,7 +1126,7 @@ proc gdb_test_multiple { command message args } { if { $wrap_pattern } { # Wrap subst_item as is done for the gdb_test PATTERN argument. lappend $current_list \ - "\[\r\n\]*(?:$subst_item)\[\r\n\]+$prompt_regexp" + "(?:$subst_item)\r\n$prompt_regexp" set wrap_pattern 0 } else { lappend $current_list $subst_item @@ -1384,7 +1384,7 @@ proc gdb_test_multiline { name args } { foreach {input result} $args { incr inputnr if {[gdb_test_multiple $input "$name: input $inputnr: $input" { - -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { + -re "($result)\r\n($gdb_prompt | *>)$" { pass $gdb_test_name } }]} { @@ -7746,7 +7746,7 @@ proc get_valueof { fmt exp default {test ""} } { set val ${default} gdb_test_multiple "print${fmt} ${exp}" "$test" { - -re "\\$\[0-9\]* = (\[^\r\n\]*)\[\r\n\]*$gdb_prompt $" { + -re "\\$\[0-9\]* = (\[^\r\n\]*)\r\n$gdb_prompt $" { set val $expect_out(1,string) pass "$test" } @@ -7770,7 +7770,7 @@ proc get_local_valueof { exp default {test ""} } { set val ${default} gdb_test_multiple "info locals ${exp}" "$test" { - -re "$exp = (\[^\r\n\]*)\[\r\n\]*$gdb_prompt $" { + -re "$exp = (\[^\r\n\]*)\r\n$gdb_prompt $" { set val $expect_out(1,string) pass "$test" } |