[gdb/testsuite] Fix gdb.cp/annota{2,3}.exp for native-extended-gdbserver
authorTom de Vries <tdevries@suse.de>
Wed, 22 Mar 2023 08:37:41 +0000 (09:37 +0100)
committerTom de Vries <tdevries@suse.de>
Wed, 22 Mar 2023 08:37:41 +0000 (09:37 +0100)
When running test-cases gdb.cp/annota{2,3}.exp with target board
native-extended-gdbserver, we run into a few FAILs, due to the test-cases
trying to match inferior output together with gdb output.

Fix this by ignoring the inferior output in this case.

Tested on x86_64-linux.

gdb/testsuite/gdb.cp/annota2.exp
gdb/testsuite/gdb.cp/annota3.exp

index 64adbbdb220ff1cec2920ce703309488356e3002..506817bd49873f580f4ef6e1263746548f475efd 100644 (file)
@@ -126,13 +126,24 @@ gdb_test_multiple "print a" "print class" {
 # `a.x is 1' is asynchronous regarding to `frames-invalid'.
 #
 
+if { $gdb_spawn_id == $inferior_spawn_id } {
+    set match_output \
+       [multi_line \
+            "\($frames_invalid\)*a.x is 1" \
+            "\($frames_invalid\)*"]
+} else {
+    # Usually we'd handle this using gdb_test_stdio, but that looks too
+    # complicated in combination with annotations, so just ignore the inferior
+    # output.
+    set match_output "\($frames_invalid\)*"
+}
+
 set pat [multi_line "" \
             "\032\032post-prompt" \
             "Continuing." \
             "" \
             "\032\032starting" \
-            "\(${frames_invalid}\)*a.x is 1" \
-            "\(${frames_invalid}\)*"\
+            $match_output \
             "\032\032exited 0" \
             "$inferior_exited_re normally." \
             "" \
index 788bda77f3dd26e049115367a699f7c79877b97f..7b85c84cd97143b39ef1e6165f701e87e51c6458 100644 (file)
@@ -95,14 +95,23 @@ gdb_expect_list "print class" "$gdb_prompt$" {
 # annotate-exited
 #
 send_gdb "continue\n"
-gdb_expect_list "continue to exit" "$gdb_prompt$" [concat {
-    "\r\n\032\032post-prompt\r\n"
-    "Continuing.\r\n"
-    "\r\n\032\032starting\r\n"
-    "a.x is 1\r\n"
-    "\r\n\032\032exited 0\r\n"} [list "$inferior_exited_re normally.\r\n"] {
-    "\r\n\032\032stopped\r\n"
-}]
+
+set el {}
+lappend el "\r\n\032\032post-prompt\r\n"
+lappend el "Continuing.\r\n"
+lappend el "\r\n\032\032starting\r\n"
+if { $gdb_spawn_id == $inferior_spawn_id } {
+    lappend el "a.x is 1\r\n"
+} else {
+    # Usually we'd handle this using gdb_test_stdio, but that looks too
+    # complicated in combination with annotations, so just ignore the inferior
+    # output.
+}
+lappend el "\r\n\032\032exited 0\r\n"
+lappend el "$inferior_exited_re normally.\r\n"
+lappend el "\r\n\032\032stopped\r\n"
+
+gdb_expect_list "continue to exit" "$gdb_prompt$" $el
 
 #
 # delete all breakpoints