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.reverse | |
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.reverse')
-rw-r--r-- | gdb/testsuite/gdb.reverse/machinestate-precsave.exp | 60 | ||||
-rw-r--r-- | gdb/testsuite/gdb.reverse/machinestate.exp | 60 |
2 files changed, 60 insertions, 60 deletions
diff --git a/gdb/testsuite/gdb.reverse/machinestate-precsave.exp b/gdb/testsuite/gdb.reverse/machinestate-precsave.exp index fd53806..5c95380 100644 --- a/gdb/testsuite/gdb.reverse/machinestate-precsave.exp +++ b/gdb/testsuite/gdb.reverse/machinestate-precsave.exp @@ -105,11 +105,11 @@ with_test_prefix "module global variable, reverse" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc" - gdb_test "print aglobal" " = 0$newline" "module global reverse-breakpoint" + gdb_test "print aglobal" " = 0" "module global reverse-breakpoint" gdb_test "step" " module global post-change .*" - gdb_test "print aglobal" " = 1$newline" "module global forward past bp" + gdb_test "print aglobal" " = 1" "module global forward past bp" gdb_test "reverse-step" "$newline$breakloc.*" - gdb_test "print aglobal" " = 0$newline" "module global reverse-step to bp" + gdb_test "print aglobal" " = 0" "module global reverse-step to bp" } # Module static variable, reverse @@ -120,11 +120,11 @@ with_test_prefix "module static variable, reverse" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc" - gdb_test "print astatic" " = 0$newline" "module static reverse-breakpoint" + gdb_test "print astatic" " = 0" "module static reverse-breakpoint" gdb_test "step" " module static post-change .*" - gdb_test "print astatic" " = 1$newline" "module static forward" + gdb_test "print astatic" " = 1" "module static forward" gdb_test "reverse-step" "$newline$breakloc.*" - gdb_test "print astatic" " = 0$newline" "module static reverse-step" + gdb_test "print astatic" " = 0" "module static reverse-step" } # Function static variable, reverse @@ -135,11 +135,11 @@ with_test_prefix "function static variable, reverse" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc" - gdb_test "print a" " = 0$newline" "function static reverse-breakpoint" + gdb_test "print a" " = 0" "function static reverse-breakpoint" gdb_test "step" " function static post-change .*" - gdb_test "print a" " = 1$newline" "function static forward" + gdb_test "print a" " = 1" "function static forward" gdb_test "reverse-step" "$newline$breakloc.*" - gdb_test "print a" " = 0$newline" "function static reverse-step" + gdb_test "print a" " = 0" "function static reverse-step" } # Auto variable, reverse @@ -150,11 +150,11 @@ with_test_prefix "auto variable, reverse" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc" - gdb_test "print a" " = 0$newline" "auto var reverse-breakpoint" + gdb_test "print a" " = 0" "auto var reverse-breakpoint" gdb_test "step" " auto post-change .*" - gdb_test "print a" " = 1$newline" "auto var forward" + gdb_test "print a" " = 1" "auto var forward" gdb_test "reverse-step" "$newline$breakloc.*" - gdb_test "print a" " = 0$newline" "auto var reverse-step" + gdb_test "print a" " = 0" "auto var reverse-step" } # Register variable, reverse @@ -165,12 +165,12 @@ with_test_prefix "register variable, reverse" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc" - gdb_test "print a" " = 0$newline" "register var reverse-breakpoint" + gdb_test "print a" " = 0" "register var reverse-breakpoint" gdb_test "step" " register post-change .*" - gdb_test "print a" " = 1$newline" \ + gdb_test "print a" " = 1" \ "register var step post-change, first time" gdb_test "reverse-step" "$newline$breakloc.*" - gdb_test "print a" " = 0$newline" "register var reverse step-to" + gdb_test "print a" " = 0" "register var reverse step-to" } # Proceed to beginning of main @@ -189,12 +189,12 @@ with_test_prefix "register variable, forward" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "continue" "$srcfile:$breakloc.*" "forward to $breakloc" - gdb_test "print a" " = 0$newline" "register var forward-breakpoint" + gdb_test "print a" " = 0" "register var forward-breakpoint" gdb_test "reverse-step" "hide.*" gdb_test "step" "$newline$breakloc.*" "step, 1" - gdb_test "print a" " = 0$newline" "register var forward step-to" + gdb_test "print a" " = 0" "register var forward step-to" gdb_test "step" " register post-change .*" "step, 2" - gdb_test "print a" " = 1$newline" \ + gdb_test "print a" " = 1" \ "register var step post-change, second time" } @@ -206,12 +206,12 @@ with_test_prefix "auto variable, forward" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "continue" "$srcfile:$breakloc.*" "forward to $breakloc" - gdb_test "print a" " = 0$newline" "auto var forward-breakpoint" + gdb_test "print a" " = 0" "auto var forward-breakpoint" gdb_test "reverse-step" "hide.*" gdb_test "step" "$newline$breakloc.*" "step, 1" - gdb_test "print a" " = 0$newline" "auto var forward step-to" + gdb_test "print a" " = 0" "auto var forward step-to" gdb_test "step" " auto post-change .*" "step, 2" - gdb_test "print a" " = 1$newline" "auto var step post-change" + gdb_test "print a" " = 1" "auto var step post-change" } # Function static variable, forward @@ -222,12 +222,12 @@ with_test_prefix "function static variable, forward" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "continue" "$srcfile:$breakloc.*" "forward to $breakloc" - gdb_test "print a" " = 0$newline" "function static forward-breakpoint" + gdb_test "print a" " = 0" "function static forward-breakpoint" gdb_test "reverse-step" "hide.*" gdb_test "step" "$newline$breakloc.*" "step, 1" - gdb_test "print a" " = 0$newline" "function static forward step-to" + gdb_test "print a" " = 0" "function static forward step-to" gdb_test "step" " function static post-change .*" "step, 2" - gdb_test "print a" " = 1$newline" "function static step post-change" + gdb_test "print a" " = 1" "function static step post-change" } # Module static variable, forward @@ -238,12 +238,12 @@ with_test_prefix "module static variable, forward" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "continue" "$srcfile:$breakloc.*" "forward to $breakloc" - gdb_test "print astatic" " = 0$newline" "module static forward-breakpoint" + gdb_test "print astatic" " = 0" "module static forward-breakpoint" gdb_test "reverse-step" "hide.*" gdb_test "step" "$newline$breakloc.*" "step, 1" - gdb_test "print astatic" " = 0$newline" "module static forward step-to" + gdb_test "print astatic" " = 0" "module static forward step-to" gdb_test "step" " module static post-change .*" "step, 2" - gdb_test "print astatic" " = 1$newline" "module static step post-change" + gdb_test "print astatic" " = 1" "module static step post-change" } # Module global variable, forward @@ -254,11 +254,11 @@ with_test_prefix "module global variable, forward" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "continue" "$srcfile:$breakloc.*" "forward to $breakloc" - gdb_test "print aglobal" " = 0$newline" "module global forward-breakpoint" + gdb_test "print aglobal" " = 0" "module global forward-breakpoint" gdb_test "reverse-step" "hide.*" gdb_test "step" "$newline$breakloc.*" "step, 1" - gdb_test "print aglobal" " = 0$newline" "module global forward step-to" + gdb_test "print aglobal" " = 0" "module global forward step-to" gdb_test "step" " module global post-change .*" "step, 2" - gdb_test "print aglobal" " = 1$newline" "module global step post-change" + gdb_test "print aglobal" " = 1" "module global step post-change" } diff --git a/gdb/testsuite/gdb.reverse/machinestate.exp b/gdb/testsuite/gdb.reverse/machinestate.exp index 68412b4..60d8f33 100644 --- a/gdb/testsuite/gdb.reverse/machinestate.exp +++ b/gdb/testsuite/gdb.reverse/machinestate.exp @@ -80,11 +80,11 @@ with_test_prefix "module global variable, reverse" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc" - gdb_test "print aglobal" " = 0$newline" "module global reverse-breakpoint" + gdb_test "print aglobal" " = 0" "module global reverse-breakpoint" gdb_test "step" " module global post-change .*" - gdb_test "print aglobal" " = 1$newline" "module global forward past bp" + gdb_test "print aglobal" " = 1" "module global forward past bp" gdb_test "reverse-step" "$newline$breakloc.*" - gdb_test "print aglobal" " = 0$newline" "module global reverse-step to bp" + gdb_test "print aglobal" " = 0" "module global reverse-step to bp" } # Module static variable, reverse @@ -95,11 +95,11 @@ with_test_prefix "module static variable, reverse" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc" - gdb_test "print astatic" " = 0$newline" "module static reverse-breakpoint" + gdb_test "print astatic" " = 0" "module static reverse-breakpoint" gdb_test "step" " module static post-change .*" - gdb_test "print astatic" " = 1$newline" "module static forward" + gdb_test "print astatic" " = 1" "module static forward" gdb_test "reverse-step" "$newline$breakloc.*" - gdb_test "print astatic" " = 0$newline" "module static reverse-step" + gdb_test "print astatic" " = 0" "module static reverse-step" } # Function static variable, reverse @@ -110,11 +110,11 @@ with_test_prefix "function static variable, reverse" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc" - gdb_test "print a" " = 0$newline" "function static reverse-breakpoint" + gdb_test "print a" " = 0" "function static reverse-breakpoint" gdb_test "step" " function static post-change .*" - gdb_test "print a" " = 1$newline" "function static forward" + gdb_test "print a" " = 1" "function static forward" gdb_test "reverse-step" "$newline$breakloc.*" - gdb_test "print a" " = 0$newline" "function static reverse-step" + gdb_test "print a" " = 0" "function static reverse-step" } # Auto variable, reverse @@ -125,11 +125,11 @@ with_test_prefix "auto variable, reverse" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc" - gdb_test "print a" " = 0$newline" "auto var reverse-breakpoint" + gdb_test "print a" " = 0" "auto var reverse-breakpoint" gdb_test "step" " auto post-change .*" - gdb_test "print a" " = 1$newline" "auto var forward" + gdb_test "print a" " = 1" "auto var forward" gdb_test "reverse-step" "$newline$breakloc.*" - gdb_test "print a" " = 0$newline" "auto var reverse-step" + gdb_test "print a" " = 0" "auto var reverse-step" } # Register variable, reverse @@ -140,11 +140,11 @@ with_test_prefix "register variable, reverse" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "reverse-continue" "$srcfile:$breakloc.*" "reverse to $breakloc" - gdb_test "print a" " = 0$newline" "register var reverse-breakpoint" + gdb_test "print a" " = 0" "register var reverse-breakpoint" gdb_test "step" " register post-change .*" - gdb_test "print a" " = 1$newline" "register var step post-change" + gdb_test "print a" " = 1" "register var step post-change" gdb_test "reverse-step" "$newline$breakloc.*" - gdb_test "print a" " = 0$newline" \ + gdb_test "print a" " = 0" \ "register var reverse step-to, first time" } @@ -164,12 +164,12 @@ with_test_prefix "register variable, forward" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "continue" "$srcfile:$breakloc.*" "forward to $breakloc" - gdb_test "print a" " = 0$newline" "register var forward-breakpoint" + gdb_test "print a" " = 0" "register var forward-breakpoint" gdb_test "reverse-step" "hide.*" gdb_test "step" "$newline$breakloc.*" "step, 1" - gdb_test "print a" " = 0$newline" "register var forward step-to" + gdb_test "print a" " = 0" "register var forward step-to" gdb_test "step" " register post-change .*" "step, 2" - gdb_test "print a" " = 1$newline" \ + gdb_test "print a" " = 1" \ "register var step post-change, second time" } @@ -181,12 +181,12 @@ with_test_prefix "auto variable, forward" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "continue" "$srcfile:$breakloc.*" "forward to $breakloc" - gdb_test "print a" " = 0$newline" "auto var forward-breakpoint" + gdb_test "print a" " = 0" "auto var forward-breakpoint" gdb_test "reverse-step" "hide.*" gdb_test "step" "$newline$breakloc.*" "step, 1" - gdb_test "print a" " = 0$newline" "auto var forward step-to" + gdb_test "print a" " = 0" "auto var forward step-to" gdb_test "step" " auto post-change .*" "step, 2" - gdb_test "print a" " = 1$newline" "auto var step post-change" + gdb_test "print a" " = 1" "auto var step post-change" } # Function static variable, forward @@ -197,12 +197,12 @@ with_test_prefix "function static variable, forward" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "continue" "$srcfile:$breakloc.*" "forward to $breakloc" - gdb_test "print a" " = 0$newline" "function static forward-breakpoint" + gdb_test "print a" " = 0" "function static forward-breakpoint" gdb_test "reverse-step" "hide.*" gdb_test "step" "$newline$breakloc.*" "step, 1" - gdb_test "print a" " = 0$newline" "function static forward step-to" + gdb_test "print a" " = 0" "function static forward step-to" gdb_test "step" " function static post-change .*" "step, 2" - gdb_test "print a" " = 1$newline" "function static step post-change" + gdb_test "print a" " = 1" "function static step post-change" } # Module static variable, forward @@ -213,12 +213,12 @@ with_test_prefix "module static variable, forward" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "continue" "$srcfile:$breakloc.*" "forward to $breakloc" - gdb_test "print astatic" " = 0$newline" "module static forward-breakpoint" + gdb_test "print astatic" " = 0" "module static forward-breakpoint" gdb_test "reverse-step" "hide.*" gdb_test "step" "$newline$breakloc.*" "step, 1" - gdb_test "print astatic" " = 0$newline" "module static forward step-to" + gdb_test "print astatic" " = 0" "module static forward step-to" gdb_test "step" " module static post-change .*" "step, 2" - gdb_test "print astatic" " = 1$newline" "module static step post-change" + gdb_test "print astatic" " = 1" "module static step post-change" } # Module global variable, forward @@ -229,10 +229,10 @@ with_test_prefix "module global variable, forward" { gdb_test "tbreak $breakloc" "$srcfile, line $breakloc.*" gdb_test "continue" "$srcfile:$breakloc.*" "forward to $breakloc" - gdb_test "print aglobal" " = 0$newline" "module global forward-breakpoint" + gdb_test "print aglobal" " = 0" "module global forward-breakpoint" gdb_test "reverse-step" "hide.*" gdb_test "step" "$newline$breakloc.*" "step, 1" - gdb_test "print aglobal" " = 0$newline" "module global forward step-to" + gdb_test "print aglobal" " = 0" "module global forward step-to" gdb_test "step" " module global post-change .*" "step, 2" - gdb_test "print aglobal" " = 1$newline" "module global step post-change" + gdb_test "print aglobal" " = 1" "module global step post-change" } |