Make mi-break.exp always expect breakpoint commands output on the main UI
authorPedro Alves <palves@redhat.com>
Tue, 21 Jun 2016 00:11:56 +0000 (01:11 +0100)
committerPedro Alves <palves@redhat.com>
Tue, 21 Jun 2016 00:11:56 +0000 (01:11 +0100)
mi-break.exp regresses when tested with MI running on a secondary UI,
with RUNTESTFLAGS="FORCE_SEPARATE_MI_TTY=1".

The problem is simply that the test sets a breakpoint, and attaches
"print" commands to the breakpoint.  Since breakpoint commands always
run with the main UI as current UI, the breakpoint command's output
goes to the main UI.  So we need to tweak the test to expect it there.

gdb/testsuite/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

* gdb.mi/mi-break.exp (test_breakpoint_commands): Always expect
breakpoint command's output on the main UI.
(test_break): New procedure, factored out from calls in the top
level.
(top level): Use foreach_with_prefix to test MI as main UI and as
separate UI.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/mi-break.exp

index 7e1e9b0a84160a3786be089fc70f1c5cb86e85fd..ee27566483e97dddd7d61edbd0084eebacfe6138 100644 (file)
@@ -1,3 +1,12 @@
+2016-06-21  Pedro Alves  <palves@redhat.com>
+
+       * gdb.mi/mi-break.exp (test_breakpoint_commands): Always expect
+       breakpoint command's output on the main UI.
+       (test_break): New procedure, factored out from calls in the top
+       level.
+       (top level): Use foreach_with_prefix to test MI as main UI and as
+       separate UI.
+
 2016-06-21  Pedro Alves  <palves@redhat.com>
 
        * gdb.mi/mi-watch.exp (test_watchpoint_creation_and_listing)
index 85f328d9cb9772ce9c6d66f050f2702588e20d69..00293d7f44354c86eedf4bf952a44b289b40cb8c 100644 (file)
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    continue
-}
-
 standard_testfile basics.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -35,10 +30,6 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
-
 # Locate line numbers in basics.c.
 set line_callee4_head  [gdb_get_line_number "callee4 ("]
 set line_callee4_body  [expr $line_callee4_head + 2]
@@ -292,9 +283,25 @@ proc test_breakpoint_commands {} {
 
     mi_send_resuming_command "exec-continue" "breakpoint commands: continue"
 
-    set test "intermediate stop and continue"
+
+    # The breakpoint command's output is always sent to the main UI,
+    # even when testing with MI running on a secondary UI.
+    global gdb_main_spawn_id
+
+    set test "intermediate stop and continue, bp commands"
     gdb_expect {
-        -re ".*\\\$1 = 0.*\\\$10 = 9.*\\*running" {
+       -i $gdb_main_spawn_id
+       -re ".*\\\$1 = 0.*\\\$10 = 9" {
+           pass $test
+       }
+       timeout {
+           fail $test
+       }
+    }
+
+    set test "intermediate stop and continue, mi running"
+    gdb_expect {
+        -re "\\*running" {
            pass $test
        }
         timeout {
@@ -385,20 +392,40 @@ proc test_explicit_breakpoints {} {
        ".*Source filename requires function, label, or line offset.*"
 }
 
-test_tbreak_creation_and_listing
-test_rbreak_creation_and_listing
+proc test_break {mi_mode} {
+    global srcdir subdir binfile
+
+    mi_gdb_exit
+
+    if {$mi_mode == "separate"} {
+       set start_ops "separate-mi-tty"
+    } else {
+       set start_ops ""
+    }
+    if [mi_gdb_start $start_ops] {
+       return
+    }
+
+    mi_delete_breakpoints
+    mi_gdb_reinitialize_dir $srcdir/$subdir
+    mi_gdb_load ${binfile}
 
-test_ignore_count
+    test_tbreak_creation_and_listing
+    test_rbreak_creation_and_listing
 
-test_error
+    test_ignore_count
 
-test_disabled_creation
+    test_error
 
-test_breakpoint_commands
+    test_disabled_creation
 
-test_abreak_creation
+    test_breakpoint_commands
 
-test_explicit_breakpoints
+    test_abreak_creation
 
-mi_gdb_exit
-return 0
+    test_explicit_breakpoints
+}
+
+foreach_with_prefix mi-mode {"main" "separate"} {
+    test_break ${mi-mode}
+}