diff options
author | Pedro Alves <palves@redhat.com> | 2016-06-21 01:11:57 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-06-21 01:11:57 +0100 |
commit | ac69f7863a6b5dbd1792356275de437371b8c879 (patch) | |
tree | 753e80633e0c23edfff69f969d78c215b9dc2bb3 /gdb/testsuite/gdb.base/new-ui.exp | |
parent | 49940788ab38b9d58c663cf38855f29c0ebb1b55 (diff) | |
download | fsf-binutils-gdb-ac69f7863a6b5dbd1792356275de437371b8c879.zip fsf-binutils-gdb-ac69f7863a6b5dbd1792356275de437371b8c879.tar.gz fsf-binutils-gdb-ac69f7863a6b5dbd1792356275de437371b8c879.tar.bz2 |
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:
2016-06-21 Pedro Alves <palves@redhat.com>
* 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.
Diffstat (limited to 'gdb/testsuite/gdb.base/new-ui.exp')
-rw-r--r-- | gdb/testsuite/gdb.base/new-ui.exp | 146 |
1 files changed, 146 insertions, 0 deletions
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 |