diff options
author | Andrew Burgess <aburgess@redhat.com> | 2023-03-30 13:26:25 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2023-04-27 13:56:37 +0100 |
commit | e2f620135d92f7cd670af4e524fffec7ac307666 (patch) | |
tree | 806c567979eb14373f6bd639bc9600e9a54b0818 /gdb/testsuite/gdb.base | |
parent | c5a5f322a4e50fbfb303874671ab541757a941cf (diff) | |
download | gdb-e2f620135d92f7cd670af4e524fffec7ac307666.zip gdb-e2f620135d92f7cd670af4e524fffec7ac307666.tar.gz gdb-e2f620135d92f7cd670af4e524fffec7ac307666.tar.bz2 |
gdb/testsuite: change newline patterns used in gdb_test
This commit makes two changes to how we match newline characters in
the gdb_test proc.
First, for the newline pattern between the command output and the
prompt, I propose changing from '[\r\n]+' to an explicit '\r\n'.
The old pattern would spot multiple newlines, and so there are a few
places where, as part of this commit, I've needed to add an extra
trailing '\r\n' to the pattern in the main test file, where GDB's
output actually includes a blank line.
But I think this is a good thing. If a command produces a blank line
then we should be checking for it, the current gdb_test doesn't do
that. But also, with the current gdb_test, if a blank line suddenly
appears in the output, this is going to be silently ignored, and I
think this is wrong, the test should fail in that case.
Additionally, the existing pattern will happily match a partial
newline. There are a strangely large number of tests that end with a
random '.' character. Not matching a literal period, but matching any
single character, this is then matching half of the trailing newline
sequence, while the \[\r\n\]+ in gdb_test is matching the other half
of the sequence. I can think of no reason why this would be
intentional, I suspect that the expected output at one time included a
period, which has since been remove, but I haven't bothered to check
on this. In this commit I've removed all these unneeded trailing '.'
characters.
The basic rule of gdb_test after this is that the expected pattern
needs to match everything up to, but not including the newline
sequence immediately before the GDB prompt. This is generally how the
proc is used anyway, so in almost all cases, this commit represents no
significant change.
Second, while I was cleaning up newline matching in gdb_test, I've
also removed the '[\r\n]*' that was added to the start of the pattern
passed to gdb_test_multiple.
The addition of this pattern adds no value. If the user pattern
matches at the start of a line then this would match against the
newline sequence. But, due to the '*', if the user pattern doesn't
match at the start of a line then this group doesn't care, it'll
happily match nothing.
As such, there's no value to it, it just adds more complexity for no
gain, so I'm removing it. No tests will need updating as a
consequence of this part of the patch.
Reviewed-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r-- | gdb/testsuite/gdb.base/call-rt-st.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/charset.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/default.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/display.exp | 10 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/foll-fork.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/info-macros.exp | 12 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/pc-fp.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/pending.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/rtld-step.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/setshow.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/until.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/watch-bitfields.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/wrong_frame_bt_full.exp | 4 |
13 files changed, 27 insertions, 29 deletions
diff --git a/gdb/testsuite/gdb.base/call-rt-st.exp b/gdb/testsuite/gdb.base/call-rt-st.exp index 63db4c5..d9c9abe 100644 --- a/gdb/testsuite/gdb.base/call-rt-st.exp +++ b/gdb/testsuite/gdb.base/call-rt-st.exp @@ -56,7 +56,7 @@ gdb_test "break loop_count" \ "breakpoint loop_count" gdb_test "continue" \ - "Continuing\\..*Breakpoint.*loop_count \\(\\) at.*call-rt-st.c:$stop_line\[ \t\r\n\]+$stop_line\[\t \]+for \\(index=0; index.4; index..\\);.*\[\r\n \]+" \ + "Continuing\\..*Breakpoint.*loop_count \\(\\) at.*call-rt-st.c:$stop_line\[ \t\r\n\]+$stop_line\[\t \]+for \\(index=0; index.4; index..\\);.*" \ "continue to loop_count" gdb_test_multiple "finish" "finish out from loop count" { diff --git a/gdb/testsuite/gdb.base/charset.exp b/gdb/testsuite/gdb.base/charset.exp index 1387e17..34b4c71 100644 --- a/gdb/testsuite/gdb.base/charset.exp +++ b/gdb/testsuite/gdb.base/charset.exp @@ -496,8 +496,8 @@ gdb_test_no_output "set target-charset UTF-8" gdb_test "print \"\\242\"" " = \"\\\\242\"" \ "non-representable target character" -gdb_test "print '\\x'" "\\\\x escape without a following hex digit." -gdb_test "print '\\u'" "\\\\u escape without a following hex digit." +gdb_test "print '\\x'" "\\\\x escape without a following hex digit" +gdb_test "print '\\u'" "\\\\u escape without a following hex digit" gdb_test "print '\\9'" " = \[0-9\]+ '9'" # An octal escape can only be 3 digits. diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp index 7e73db0..3c5e8b7 100644 --- a/gdb/testsuite/gdb.base/default.exp +++ b/gdb/testsuite/gdb.base/default.exp @@ -386,8 +386,8 @@ gdb_test "overlay list" "No sections are mapped." gdb_test "overlay map" "Overlay debugging not enabled.*" "overlay map #1" gdb_test "overlay unmap" "Overlay debugging not enabled.*" "overlay unmap #1" gdb_test_no_output "overlay manual" "overlay manual #2" -gdb_test "overlay map" "Argument required: name of an overlay section." "overlay map #2" -gdb_test "overlay unmap" "Argument required: name of an overlay section." "overlay unmap #2" +gdb_test "overlay map" "Argument required: name of an overlay section" "overlay map #2" +gdb_test "overlay unmap" "Argument required: name of an overlay section" "overlay unmap #2" #test print "p" abbreviation gdb_test "p" "The history is empty." "print \"p\" abbreviation" diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp index 79ef4d8..6978aed 100644 --- a/gdb/testsuite/gdb.base/display.exp +++ b/gdb/testsuite/gdb.base/display.exp @@ -191,11 +191,11 @@ gdb_test "printf \"%p\\n\", 1" "0x1" # play with "print", too # gdb_test "print/k j" ".*Undefined output format.*" -gdb_test "print/d j" " = 0\[\\r\\n\]+" "debug test output 1" -gdb_test "print/r j" " = 0\[\\r\\n\]+" "debug test output 1a" -gdb_test "print/x j" " = 0x0\[\\r\\n\]+" "debug test output 2" -gdb_test "print/r j" " = 0x0\[\\r\\n\]+" "debug test output 2a" -gdb_test "print j" " = 0\[\\r\\n\]+" "debug test output 3" +gdb_test "print/d j" " = 0" "debug test output 1" +gdb_test "print/r j" " = 0" "debug test output 1a" +gdb_test "print/x j" " = 0x0" "debug test output 2" +gdb_test "print/r j" " = 0x0" "debug test output 2a" +gdb_test "print j" " = 0" "debug test output 3" # x/0 j doesn't produce any output and terminates PA64 process when testing gdb_test_no_output "x/0 j" diff --git a/gdb/testsuite/gdb.base/foll-fork.exp b/gdb/testsuite/gdb.base/foll-fork.exp index df5dab0..b0ba156 100644 --- a/gdb/testsuite/gdb.base/foll-fork.exp +++ b/gdb/testsuite/gdb.base/foll-fork.exp @@ -234,7 +234,7 @@ proc_with_prefix catch_fork_child_follow {second_inferior} { # Verify that the catchpoint is mentioned in an "info breakpoints", # and further that the catchpoint mentions no process id. gdb_test "info breakpoints" \ - ".*catchpoint.*keep y.*fork\[\r\n\]+" \ + ".*catchpoint.*keep y.*fork" \ "info breakpoints before fork" gdb_test "continue" \ diff --git a/gdb/testsuite/gdb.base/info-macros.exp b/gdb/testsuite/gdb.base/info-macros.exp index 38eb35f..fd4a99c 100644 --- a/gdb/testsuite/gdb.base/info-macros.exp +++ b/gdb/testsuite/gdb.base/info-macros.exp @@ -33,22 +33,22 @@ gdb_test "info macro -- -all" \ "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" gdb_test "info macro -all --" \ - "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" + "You must follow.*with the name.*you want to see.*\[^\r\n\]*" gdb_test "info macro -all --" \ - "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" + "You must follow.*with the name.*you want to see.*\[^\r\n\]*" gdb_test "info macro -all --" \ - "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" + "You must follow.*with the name.*you want to see.*\[^\r\n\]*" gdb_test "info macro --" \ - "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" + "You must follow.*with the name.*you want to see.*\[^\r\n\]*" gdb_test "info macro -- " \ - "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ + "You must follow.*with the name.*you want to see.*\[^\r\n\]*" \ "info macro -- <EOL>" gdb_test "info macro -- " \ - "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ + "You must follow.*with the name.*you want to see.*\[^\r\n\]*" \ "info macro -- <EOL>" gdb_test "info macro -invalid-option" \ diff --git a/gdb/testsuite/gdb.base/pc-fp.exp b/gdb/testsuite/gdb.base/pc-fp.exp index e7ebd38..466a6d6 100644 --- a/gdb/testsuite/gdb.base/pc-fp.exp +++ b/gdb/testsuite/gdb.base/pc-fp.exp @@ -53,4 +53,4 @@ gdb_test "info register \$fp" "${valueof_fp}.*" # Regression test for # http://sourceware.org/bugzilla/show_bug.cgi?id=12659 gdb_test "info register pc fp" \ - "pc +${valueof_pc}\[ \t\]+${valueof_pc} <.*>\[\r\n\]+fp +${valueof_fp}\[ \t\]+${valueof_fp}\[\r\n\]+" + "pc +${valueof_pc}\[ \t\]+${valueof_pc} <.*>\[\r\n\]+fp +${valueof_fp}\[ \t\]+${valueof_fp}" diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp index be54fb1..d7d3735 100644 --- a/gdb/testsuite/gdb.base/pending.exp +++ b/gdb/testsuite/gdb.base/pending.exp @@ -225,7 +225,7 @@ gdb_test "continue" \ gdb_test "continue" \ ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.* -\[$\]1 = 1." \ +\\\$1 = 1" \ "continue to resolved breakpoint 1" # diff --git a/gdb/testsuite/gdb.base/rtld-step.exp b/gdb/testsuite/gdb.base/rtld-step.exp index f2cf0b1..9a6c76d 100644 --- a/gdb/testsuite/gdb.base/rtld-step.exp +++ b/gdb/testsuite/gdb.base/rtld-step.exp @@ -140,7 +140,7 @@ gdb_test "step" {baz \(.*?\);} "step into foo 1" gdb_test "finish" {Run till exit.*bar \(\).*baz.*} "finish out of foo 1" gdb_test "next" {foo \(2\);} "next over baz in bar" gdb_test "step" {baz \(.*?\);} "step into foo 2" -gdb_test "next" "\}\[\r\n\]+" "next over baz in foo" -gdb_test "step" "bar \\(\\).*}\[\r\n\]+.*" "step out of foo back into bar" +gdb_test "next" "\}" "next over baz in foo" +gdb_test "step" "bar \\(\\).*}" "step out of foo back into bar" gdb_continue_to_end diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp index 86821ca..8c160aa 100644 --- a/gdb/testsuite/gdb.base/setshow.exp +++ b/gdb/testsuite/gdb.base/setshow.exp @@ -297,10 +297,10 @@ proc_with_prefix test_setshow_history {} { "The filename in which to record the command history is \"[string_to_regexp $HOME]/foobar.baz\"..*" \ "show history filename (~/foobar.baz)" gdb_test "p \$_gdb_setting(\"history filename\")" \ - " = \"[string_to_regexp $HOME]/foobar.baz\"..*" \ + " = \"[string_to_regexp $HOME]/foobar.baz\"" \ "_gdb_setting history filename" gdb_test "p \$_gdb_setting_str(\"history filename\")" \ - " = \"[string_to_regexp $HOME]/foobar.baz\"..*" \ + " = \"[string_to_regexp $HOME]/foobar.baz\"" \ "_gdb_setting_str history filename" #get current working directory diff --git a/gdb/testsuite/gdb.base/until.exp b/gdb/testsuite/gdb.base/until.exp index e1a1765..4a1a07d 100644 --- a/gdb/testsuite/gdb.base/until.exp +++ b/gdb/testsuite/gdb.base/until.exp @@ -39,7 +39,7 @@ gdb_test "until $bp_location1" \ # Verify that a malformed "advance" is gracefully caught. # gdb_test "until 80 then stop" \ - "malformed linespec error: unexpected string, \"then stop\"." \ + "malformed linespec error: unexpected string, \"then stop\"" \ "malformed until" # Rerun up to factorial, outer invocation diff --git a/gdb/testsuite/gdb.base/watch-bitfields.exp b/gdb/testsuite/gdb.base/watch-bitfields.exp index ce2aee2..95573ca 100644 --- a/gdb/testsuite/gdb.base/watch-bitfields.exp +++ b/gdb/testsuite/gdb.base/watch-bitfields.exp @@ -44,9 +44,9 @@ proc watch { expr } { proc expect_watchpoint { expr old new } { with_test_prefix "$expr: $old->$new" { set expr_re [string_to_regexp $expr] - gdb_test "print $expr" "\\$\\d+ = $old\\s" "print expression before" + gdb_test "print $expr" "\\$\\d+ = $old" "print expression before" gdb_test "continue" "$expr_re\\s.*Old value = $old\\s+New value = $new\\s.*" - gdb_test "print $expr" "\\$\\d+ = $new\\s" "print expression after" + gdb_test "print $expr" "\\$\\d+ = $new" "print expression after" } } diff --git a/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp b/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp index 2ab0133..5321cdc 100644 --- a/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp +++ b/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp @@ -51,6 +51,4 @@ if ![runto opaque_routine] { # correctly when frame #0 (the frame which does not have any debugging # info) is the selected frame. -gdb_test "bt full" \ - ".*\[\r\n\]+ *my_table = \\{0, 1, 2\\}\[\r\n\]+.*" - +gdb_test "bt full" ".*\[\r\n\]+ *my_table = \\{0, 1, 2\\}" |