From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v3 35/34] Add "new-ui console" tests
Date: Thu, 26 May 2016 18:37:00 -0000 [thread overview]
Message-ID: <fb009bd3-05aa-8213-3bfe-66bd5a9a46a4@redhat.com> (raw)
In-Reply-To: <1462538104-19109-1-git-send-email-palves@redhat.com>
I'm adding this one to the series to cover a few bugs
that were pointed out in earlier reviews, and more.
From 19266f547086ae4f25900c1eeb10796f8951ee40 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Thu, 26 May 2016 13:12:32 +0100
Subject: [PATCH] Add "new-ui console" tests
This adds a test that uses new-ui to create a secondary console, and
then runs some basic smoke tests. It ensures that:
- synchronous commands send output to the UI that initiated it
- asynchronous events like breakpoint hits are reported on all
consoles.
- "new-ui" without arguments doesn't crash.
- The "new-ui" command doesn't repeat.
gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* gdb.base/new-ui.c: New file.
* gdb.base/new-ui.exp: New file.
* lib/mi-support.exp (switch_gdb_spawn_id): Move to ...
* lib/gdb.exp (switch_gdb_spawn_id): ... here.
(with_spawn_id): New procedure.
---
gdb/testsuite/gdb.base/new-ui.c | 42 +++++++++++
gdb/testsuite/gdb.base/new-ui.exp | 146 ++++++++++++++++++++++++++++++++++++++
gdb/testsuite/lib/gdb.exp | 32 +++++++++
gdb/testsuite/lib/mi-support.exp | 12 ----
4 files changed, 220 insertions(+), 12 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/new-ui.c
create mode 100644 gdb/testsuite/gdb.base/new-ui.exp
diff --git a/gdb/testsuite/gdb.base/new-ui.c b/gdb/testsuite/gdb.base/new-ui.c
new file mode 100644
index 0000000..8fff0bc
--- /dev/null
+++ b/gdb/testsuite/gdb.base/new-ui.c
@@ -0,0 +1,42 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2016 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+volatile int global = 0;
+
+int
+main (void)
+{
+ global = 1;
+ global = 1;
+ global = 1;
+ global = 1;
+ global = 1;
+ global = 1;
+ global = 1;
+ global = 1; /* set break main console here */
+ global = 1;
+ global = 1;
+ global = 1;
+ global = 1;
+ global = 1;
+ global = 1;
+ global = 1;
+ global = 1; /* set break extra console here */
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/new-ui.exp b/gdb/testsuite/gdb.base/new-ui.exp
new file mode 100644
index 0000000..f3f66db
--- /dev/null
+++ b/gdb/testsuite/gdb.base/new-ui.exp
@@ -0,0 +1,146 @@
+# Copyright 2016 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile
+
+set compile_options "debug"
+if {[build_executable $testfile.exp $testfile ${srcfile} ${compile_options}] == -1} {
+ untested "failed to compile $testfile"
+ return -1
+}
+
+# Ensure no output has been sent. Use MESSAGE as test message.
+
+proc ensure_no_output {message} {
+ global decimal
+
+ # Run a command and use an anchor to make sure no output appears
+ # before the command's expected output.
+ gdb_test "print 999" "^print 999\r\n\\\$$decimal = 999" $message
+}
+
+# Run a few execution-related commands on CON1, and ensure the proper
+# output, or none, if appropriate, is sent to CON2. CON1_NAME and
+# CON2_NAME are the names of the consoles.
+
+proc do_execution_tests {con1 con1_name con2 con2_name} {
+ global srcfile
+ global decimal
+
+ set bp_lineno [gdb_get_line_number "set break $con1_name here"]
+
+ with_spawn_id $con1 {
+ gdb_test "next" "global = 1;"
+ }
+ with_spawn_id $con2 {
+ ensure_no_output "next causes no spurious output on other console"
+ }
+
+ with_spawn_id $con1 {
+ gdb_test "break $srcfile:$bp_lineno" \
+ "Breakpoint $decimal .*$srcfile, line $bp_lineno\\." \
+ "set breakpoint"
+ }
+ with_spawn_id $con2 {
+ ensure_no_output "break causes no spurious output on other console"
+ }
+
+ with_spawn_id $con1 {
+ gdb_test "continue" "set break $con1_name here .*" "continue to breakpoint"
+ }
+
+ with_spawn_id $con2 {
+ set test "breakpoint hit reported on other console"
+ gdb_test_multiple "" $test {
+ -re "Breakpoint $decimal, .* set break $con1_name here " {
+ pass $test
+ }
+ }
+ }
+}
+
+# The test proper.
+
+proc do_test {} {
+ global srcfile testfile
+ global gdb_prompt
+ global gdb_spawn_id
+ global gdb_main_spawn_id extra_spawn_id
+
+ clean_restart $testfile
+
+ if ![runto_main] {
+ untested "could not run to main"
+ return -1
+ }
+
+ gdb_test "new-ui" \
+ "usage: new-ui <interpreter> <tty>" \
+ "new-ui without arguments"
+
+ set test "new-ui does not repeat"
+ send_gdb "\n"
+ gdb_test_multiple "" $test {
+ -re "^\r\n$gdb_prompt $" {
+ pass $test
+ }
+ }
+
+ # Save the main UI's spawn ID.
+ set gdb_main_spawn_id $gdb_spawn_id
+
+ # Create the new PTY for the secondary console UI.
+ spawn -pty
+ set extra_spawn_id $spawn_id
+ set extra_tty_name $spawn_out(slave,name)
+ gdb_test_multiple "new-ui console $extra_tty_name" "new-ui" {
+ -re "New UI allocated\r\n$gdb_prompt $" {
+ }
+ }
+
+ with_spawn_id $extra_spawn_id {
+ set test "initial prompt on extra console"
+ gdb_test_multiple "" $test {
+ -re "$gdb_prompt $" {
+ pass $test
+ }
+ }
+ }
+
+ # Ensure non-execution commands in one console don't cause output
+ # in the other consoles.
+ with_spawn_id $gdb_main_spawn_id {
+ gdb_test "print 1" "^print 1\r\n\\\$1 = 1" "print on main console"
+ }
+ with_spawn_id $extra_spawn_id {
+ gdb_test "print 2" "^print 2\r\n\\\$2 = 2" "print on extra console"
+ }
+
+ # Run a few execution tests with the main console as the driver
+ # console.
+ with_test_prefix "main console" {
+ do_execution_tests \
+ $gdb_main_spawn_id "main console" \
+ $extra_spawn_id "extra console"
+ }
+ # Same, but with the extra console as driver.
+ with_test_prefix "extra console" {
+ do_execution_tests \
+ $extra_spawn_id "extra console" \
+ $gdb_main_spawn_id "main console"
+ }
+}
+
+do_test
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index a374370..40de630 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2070,6 +2070,38 @@ proc with_target_charset { target_charset body } {
}
}
+# Switch the default spawn id to SPAWN_ID, so that gdb_test,
+# mi_gdb_test etc. default to using it.
+
+proc switch_gdb_spawn_id {spawn_id} {
+ global gdb_spawn_id
+ global board board_info
+
+ set gdb_spawn_id $spawn_id
+ set board [host_info name]
+ set board_info($board,fileid) $spawn_id
+}
+
+# Run BODY with SPAWN_ID as current spawn id.
+
+proc with_spawn_id { spawn_id body } {
+ global gdb_spawn_id
+
+ set saved_spawn_id $gdb_spawn_id
+ switch_gdb_spawn_id $spawn_id
+
+ set code [catch {uplevel 1 $body} result]
+
+ switch_gdb_spawn_id $saved_spawn_id
+
+ if {$code == 1} {
+ global errorInfo errorCode
+ return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
+ } else {
+ return -code $code $result
+ }
+}
+
# Select the largest timeout from all the timeouts:
# - the local "timeout" variable of the scope two levels above,
# - the global "timeout" variable,
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index edfc07d..7b5c90b 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -122,18 +122,6 @@ proc mi_create_inferior_pty {} {
}
}
-# Switch the default spawn id to SPAWN_ID, so that mi_gdb_test
-# etc. default to using it.
-
-proc switch_gdb_spawn_id {spawn_id} {
- global gdb_spawn_id
- global board board_info
-
- set gdb_spawn_id $spawn_id
- set board [host_info name]
- set board_info($board,fileid) $spawn_id
-}
-
proc mi_gdb_start_separate_mi_tty { args } {
global gdb_prompt mi_gdb_prompt
global timeout
--
2.5.5
next prev parent reply other threads:[~2016-05-26 18:37 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-06 12:35 [PATCH v3 00/34] Towards great frontend GDB consoles Pedro Alves
2016-05-06 12:35 ` [PATCH v3 29/34] Add new command to create extra console/mi UI channels Pedro Alves
2016-05-26 18:34 ` Pedro Alves
2016-05-06 12:35 ` [PATCH v3 24/34] Push thread->control.command_interp to the struct thread_fsm Pedro Alves
2016-07-01 11:02 ` Thomas Preudhomme
[not found] ` <20144b4c-11ee-fc84-e3ad-b9992f14ce15@redhat.com>
2016-07-01 15:24 ` [PATCH] Build gdb.opt/inline-*.exp tests at -O0, rely on __attribute__((always_inline)) (was: Re: [PATCH v3 24/34] Push thread->control.command_interp to the struct thread_fsm) Thomas Preudhomme
2016-07-15 12:05 ` Thomas Preudhomme
2016-07-19 17:02 ` [PATCH] Build gdb.opt/inline-*.exp tests at -O0, rely on __attribute__((always_inline)) Pedro Alves
2016-07-20 16:35 ` Thomas Preudhomme
2016-05-06 12:35 ` [PATCH v3 16/34] Make target_terminal_inferior/ours almost nops on non-main UIs Pedro Alves
2016-05-06 12:35 ` [PATCH v3 15/34] Always process target events in the main UI Pedro Alves
2016-05-06 12:35 ` [PATCH v3 03/34] Introduce "struct ui" Pedro Alves
2016-05-06 12:35 ` [PATCH v3 01/34] Prepare gdb.python/mi-py-events.exp for Python/MI in separate channels Pedro Alves
2016-05-06 12:35 ` [PATCH v3 14/34] Make command line editing (use of readline) be per UI Pedro Alves
2016-05-06 12:35 ` [PATCH v3 21/34] Replace the sync_execution global with a new enum prompt_state tristate Pedro Alves
2016-05-06 12:35 ` [PATCH v3 20/34] Make gdb_in_secondary_prompt_p() be per UI Pedro Alves
2016-05-06 12:35 ` [PATCH v3 02/34] [Ada catchpoints] Fix "warning: failed to get exception name: No definition of \"e.full_name\" in current context" Pedro Alves
2016-05-06 12:35 ` [PATCH v3 33/34] Make mi-break.exp always expect breakpoint commands output on the main UI Pedro Alves
2016-05-06 12:36 ` [PATCH v3 31/34] Add testing infrastruture bits for running with MI on a separate UI Pedro Alves
2016-06-28 20:19 ` Simon Marchi
2016-06-29 10:50 ` Pedro Alves
2016-06-30 11:12 ` [pushed] Fix gdbserver/MI testing regression (was: Re: [PATCH v3 31/34] Add testing infrastruture bits for running with MI on a separate UI) Pedro Alves
2016-06-30 12:10 ` gdbserver/ada testing broken (was: Re: [pushed] Fix gdbserver/MI testing regression) Pedro Alves
2016-07-04 20:40 ` gdbserver/ada testing broken Simon Marchi
2016-07-05 15:28 ` Joel Brobecker
2016-07-05 15:47 ` Joel Brobecker
2016-07-05 16:36 ` gdbserver/ada testing broken (was: Re: [pushed] Fix gdbserver/MI testing regression) Joel Brobecker
2016-07-05 17:19 ` gdbserver/ada testing broken Simon Marchi
2016-07-06 13:23 ` Joel Brobecker
2016-07-06 14:28 ` Simon Marchi
2016-07-19 17:11 ` Pedro Alves
2016-07-04 17:22 ` [pushed] Fix gdbserver/MI testing regression Simon Marchi
2016-05-06 12:40 ` [PATCH v3 11/34] Make out and error streams be per UI Pedro Alves
2016-05-06 12:40 ` [PATCH v3 23/34] New function should_print_stop_to_console Pedro Alves
2016-05-06 12:40 ` [PATCH v3 13/34] Make current_ui_out be per UI Pedro Alves
2016-05-06 12:41 ` [PATCH v3 06/34] Introduce interpreter factories Pedro Alves
2016-05-18 19:18 ` Simon Marchi
2016-05-26 18:11 ` Pedro Alves
2016-05-18 19:20 ` Simon Marchi
2016-05-26 18:08 ` Pedro Alves
2016-05-06 12:42 ` [PATCH v3 30/34] [DOC] Document support for running interpreters on separate UI channels Pedro Alves
2016-05-06 13:04 ` Eli Zaretskii
2016-05-26 11:11 ` Pedro Alves
2016-06-17 17:24 ` Pedro Alves
2016-06-17 20:02 ` Eli Zaretskii
2016-05-06 12:43 ` [PATCH v3 12/34] Delete def_uiout Pedro Alves
2016-05-06 12:43 ` [PATCH v3 04/34] Make gdb_stdout&co be per UI Pedro Alves
2016-05-06 12:43 ` [PATCH v3 17/34] Introduce display_mi_prompt Pedro Alves
2016-05-06 12:43 ` [PATCH v3 05/34] Make the interpreters be per UI Pedro Alves
2016-05-18 17:51 ` Simon Marchi
2016-05-26 18:08 ` Pedro Alves
2016-05-06 12:43 ` [PATCH v3 10/34] Make input_fd " Pedro Alves
2016-05-06 12:43 ` [PATCH v3 07/34] Make the intepreters output to all UIs Pedro Alves
2016-05-19 15:16 ` Simon Marchi
2016-05-26 18:12 ` Pedro Alves
2016-05-06 12:43 ` [PATCH v3 08/34] Always run async signal handlers in the main UI Pedro Alves
2016-05-19 19:28 ` Simon Marchi
2016-05-26 18:13 ` Pedro Alves
2016-05-26 18:15 ` Simon Marchi
2016-05-06 12:43 ` [PATCH v3 25/34] Only send sync execution command output to the UI that ran the command Pedro Alves
2016-05-06 12:43 ` [PATCH v3 28/34] Make stdin be per UI Pedro Alves
2016-05-06 12:45 ` [PATCH v3 34/34] Always switch fork child to the main UI Pedro Alves
2016-05-06 12:45 ` [PATCH v3 32/34] Send deleted watchpoint-scope output to all UIs Pedro Alves
2016-05-06 12:45 ` [PATCH v3 22/34] Fix for spurious prompts in secondary UIs Pedro Alves
2016-05-06 12:45 ` [PATCH v3 27/34] Handle UI's terminal closing Pedro Alves
2016-05-06 12:45 ` [PATCH v3 26/34] Make main_ui be heap allocated Pedro Alves
2016-05-06 12:52 ` [PATCH v3 18/34] Make raw_stdout be per MI instance Pedro Alves
2016-05-06 12:53 ` [PATCH v3 09/34] Make instream be per UI Pedro Alves
2016-05-06 12:53 ` [PATCH v3 19/34] Simplify starting the command event loop Pedro Alves
2016-05-26 18:37 ` Pedro Alves [this message]
2016-06-21 0:23 ` [pushed] Re: [PATCH v3 00/34] Towards great frontend GDB consoles Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fb009bd3-05aa-8213-3bfe-66bd5a9a46a4@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox