aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-03-30 13:26:25 +0100
committerAndrew Burgess <aburgess@redhat.com>2023-04-27 13:56:37 +0100
commite2f620135d92f7cd670af4e524fffec7ac307666 (patch)
tree806c567979eb14373f6bd639bc9600e9a54b0818 /gdb/testsuite/gdb.cp
parentgdb/testsuite: use 'return' in gdb_test_no_output (diff)
downloadbinutils-gdb-e2f620135d92f7cd670af4e524fffec7ac307666.tar.gz
binutils-gdb-e2f620135d92f7cd670af4e524fffec7ac307666.tar.bz2
binutils-gdb-e2f620135d92f7cd670af4e524fffec7ac307666.zip
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.cp')
-rw-r--r--gdb/testsuite/gdb.cp/incomplete-type-overload.exp2
-rw-r--r--gdb/testsuite/gdb.cp/maint.exp8
-rw-r--r--gdb/testsuite/gdb.cp/ovldbreak.exp14
-rw-r--r--gdb/testsuite/gdb.cp/userdef.exp20
-rw-r--r--gdb/testsuite/gdb.cp/virtfunc.exp23
5 files changed, 39 insertions, 28 deletions
diff --git a/gdb/testsuite/gdb.cp/incomplete-type-overload.exp b/gdb/testsuite/gdb.cp/incomplete-type-overload.exp
index 050bd98cf56..01201ecd396 100644
--- a/gdb/testsuite/gdb.cp/incomplete-type-overload.exp
+++ b/gdb/testsuite/gdb.cp/incomplete-type-overload.exp
@@ -172,5 +172,5 @@ gdb_test "print foo(inc)"\
"The type. 'incomplete .' isn't fully known to GDB.*"\
"unsuccessful because declaration"
gdb_test "print foo(ip)"\
- "Cannot resolve function foo to any overloaded instance."\
+ "Cannot resolve function foo to any overloaded instance"\
"unsuccessful because incorrect"
diff --git a/gdb/testsuite/gdb.cp/maint.exp b/gdb/testsuite/gdb.cp/maint.exp
index 59dccfbb3bd..36a48e5637d 100644
--- a/gdb/testsuite/gdb.cp/maint.exp
+++ b/gdb/testsuite/gdb.cp/maint.exp
@@ -21,8 +21,8 @@
# Test the help messages.
proc test_help {} {
- set first_component_help "Print the first class/namespace component of NAME"
- set namespace_help "Deprecated placeholder for removed functionality."
+ set first_component_help "Print the first class/namespace component of NAME\\."
+ set namespace_help "Deprecated placeholder for removed functionality\\."
test_prefix_command_help {"maintenance cplus"} {
"C\\+\\+ maintenance commands\.\[\r\n\]+"
@@ -36,8 +36,8 @@ proc test_help {} {
gdb_test "maint cp" $multiple_help_body
- gdb_test "help maint cp first_component" "${first_component_help}."
- gdb_test "help maint cp namespace" "${namespace_help}."
+ gdb_test "help maint cp first_component" "${first_component_help}"
+ gdb_test "help maint cp namespace" "${namespace_help}"
}
# This is used when NAME should contain only a single component. Be
diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp
index 62e45f50d0e..fd8268a5791 100644
--- a/gdb/testsuite/gdb.cp/ovldbreak.exp
+++ b/gdb/testsuite/gdb.cp/ovldbreak.exp
@@ -241,11 +241,11 @@ for {set idx 0} {$idx < [llength $overloads]} {incr idx} {
}
# Verify the breakpoints.
-set bptable "Num\[\t \]+Type\[\t \]+Disp Enb Address\[\t \]+What.*\[\r\n]+"
-append bptable "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep\[\t \]y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\[\r\n\]+"
-append bptable "\[\t \]+breakpoint already hit 1 time\[\r\n\]+."
+set bptable "Num\[\t \]+Type\[\t \]+Disp Enb Address\[\t \]+What\\s*\r\n"
+append bptable "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep\[\t \]y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\r\n"
+append bptable "\[\t \]+breakpoint already hit 1 time"
foreach ovld $overloads {
- append bptable [format "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(%s\\) at.*$srcfile:%d\[\r\n\]+" $ovld \
+ append bptable [format "\r\n\[0-9\]+\[\t \]+breakpoint\[\t \]+keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(%s\\) at.*$srcfile:%d" $ovld \
$line($type_map("$ovld"))]
}
gdb_test "info break" $bptable "breakpoint info (after setting one-by-one)"
@@ -366,12 +366,12 @@ gdb_expect {
}
# Create the breakpoint table for "info breakpoint".
-set bptable "Num\[\t \]+Type\[\t \]+Disp Enb Address\[\t \]+What.*\[\r\n]+"
-append bptable "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep\[\t \]y\[\t \]+<MULTIPLE>.*\[\r\n\]+"
+set bptable "Num\[\t \]+Type\[\t \]+Disp Enb Address\[\t \]+What\\s*\r\n"
+append bptable "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep\[\t \]y\[\t \]+<MULTIPLE>\\s*"
foreach ovld {void char signed_char unsigned_char short_int \
unsigned_short_int int unsigned_int long_int \
unsigned_long_int float double} {
- append bptable [format "\[0-9\]+.\[0-9\]+\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(%s\\) at.*$srcfile:%d\[\r\n\]+" \
+ append bptable [format "\r\n\[0-9\]+.\[0-9\]+\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(%s\\) at.*$srcfile:%d" \
$types($ovld) $line($ovld)]
}
diff --git a/gdb/testsuite/gdb.cp/userdef.exp b/gdb/testsuite/gdb.cp/userdef.exp
index f04a441c54d..ac453179da2 100644
--- a/gdb/testsuite/gdb.cp/userdef.exp
+++ b/gdb/testsuite/gdb.cp/userdef.exp
@@ -67,9 +67,9 @@ gdb_test "print one / two" "\\\$\[0-9\]* = {x = 0, y = 0}"
gdb_test "print one % two" "\\\$\[0-9\]* = {x = 2, y = 3}"
-gdb_test "print one && two" "\\\$\[0-9\]* = 1\[\r\n\]"
+gdb_test "print one && two" "\\\$\[0-9\]* = 1"
-gdb_test "print one || two" "\\\$\[0-9\]* = 1\[\r\n\]"
+gdb_test "print one || two" "\\\$\[0-9\]* = 1"
gdb_test "print one & two" "\\\$\[0-9\]* = {x = 0, y = 1}"
@@ -77,18 +77,18 @@ gdb_test "print one | two" "\\\$\[0-9\]* = {x = 6, y = 7}"
gdb_test "print one ^ two" "\\\$\[0-9\]* = {x = 6, y = 6}"
-gdb_test "print one < two" "\\\$\[0-9\]* = 1\[\r\n\]"
+gdb_test "print one < two" "\\\$\[0-9\]* = 1"
-gdb_test "print one <= two" "\\\$\[0-9\]* = 1\[\r\n\]"
+gdb_test "print one <= two" "\\\$\[0-9\]* = 1"
-gdb_test "print one > two" "\\\$\[0-9\]* = 0\[\r\n\]"
+gdb_test "print one > two" "\\\$\[0-9\]* = 0"
-gdb_test "print one >= two" "\\\$\[0-9\]* = 0\[\r\n\]"
+gdb_test "print one >= two" "\\\$\[0-9\]* = 0"
-gdb_test "print one == two" "\\\$\[0-9\]* = 0\[\r\n\]"
-gdb_test "print one.operator== (two)" "\\\$\[0-9\]* = 0\[\r\n\]"
+gdb_test "print one == two" "\\\$\[0-9\]* = 0"
+gdb_test "print one.operator== (two)" "\\\$\[0-9\]* = 0"
-gdb_test "print one != two" "\\\$\[0-9\]* = 1\[\r\n\]"
+gdb_test "print one != two" "\\\$\[0-9\]* = 1"
# Can't really check the output of this one without knowing
# target integer width. Make sure we don't try to call
@@ -98,7 +98,7 @@ gdb_test "print one << 31" "\\\$\[0-9\]* = {x = -?\[0-9\]*, y = -?\[0-9\]*}"
# Should be fine even on < 32-bit targets.
gdb_test "print one >> 31" "\\\$\[0-9\]* = {x = 0, y = 0}"
-gdb_test "print !one" "\\\$\[0-9\]* = 0\[\r\n\]"
+gdb_test "print !one" "\\\$\[0-9\]* = 0"
# Assumes 2's complement. So does everything...
gdb_test "print +one" "\\\$\[0-9\]* = {x = 2, y = 3}"
diff --git a/gdb/testsuite/gdb.cp/virtfunc.exp b/gdb/testsuite/gdb.cp/virtfunc.exp
index 445befddf28..908c969741b 100644
--- a/gdb/testsuite/gdb.cp/virtfunc.exp
+++ b/gdb/testsuite/gdb.cp/virtfunc.exp
@@ -228,7 +228,7 @@ proc test_virtual_calls {} {
proc make_one_vtable_result {name args} {
global hex
- set nls "\[\r\n\]+"
+ set nls "\r\n"
set result "vtable for '${name}' @ $hex .subobject @ $hex.:$nls"
set count 0
@@ -237,9 +237,20 @@ proc make_one_vtable_result {name args} {
incr count
}
+ # Remove the last instance of $nls.
+ if {$count > 0} {
+ set result [string range $result 0 end-[string length $nls]]
+ }
+
+ verbose -log "APB: result: '$result'"
+
return $result
}
+proc vtable_seq { args } {
+ return [join "\r\n\r\n" $args]
+}
+
# Test "info vtbl".
proc test_info_vtbl {} {
@@ -255,12 +266,12 @@ proc test_info_vtbl {} {
set vt_D2 [make_one_vtable_result D "non-virtual thunk to E::vg" D::vd]
set vt_E [make_one_vtable_result E E::f E::vg E::vv]
- gdb_test "info vtbl a" "${vt_A}${vt_V}"
- gdb_test "info vtbl b" "${vt_B}${vt_V}"
+ gdb_test "info vtbl a" [vtable_seq ${vt_A} ${vt_V}]
+ gdb_test "info vtbl b" [vtable_seq ${vt_B} ${vt_V}]
gdb_test "info vtbl c" "${vt_V}"
- gdb_test "info vtbl d" "${vt_D}${vt_V}"
- gdb_test "info vtbl e" "${vt_E}${vt_D2}${vt_V2}"
- gdb_test "info vtbl pEe" "${vt_E}${vt_D2}${vt_V2}"
+ gdb_test "info vtbl d" [vtable_seq ${vt_D} ${vt_V}]
+ gdb_test "info vtbl e" [vtable_seq ${vt_E} ${vt_D2} ${vt_V2}]
+ gdb_test "info vtbl pEe" [vtable_seq ${vt_E} ${vt_D2} ${vt_V2}]
gdb_test "info vtbl" "Argument required.*"
gdb_test "info vtbl va" \