diff options
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/gdb.dap/attach-fail.exp | 32 | ||||
-rwxr-xr-x | gdb/testsuite/gdb.tui/gdb.sh (renamed from gdb/testsuite/gdb.tui/gdb.tcl) | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.tui/pr30056.exp | 114 | ||||
-rw-r--r-- | gdb/testsuite/gdb.tui/tui-long-line.c | 24 | ||||
-rw-r--r-- | gdb/testsuite/gdb.tui/tui-missing-src.exp | 1 | ||||
-rw-r--r-- | gdb/testsuite/gdb.tui/tuiterm-2.exp | 18 | ||||
-rw-r--r-- | gdb/testsuite/gdb.tui/wrap-line.exp | 22 | ||||
-rw-r--r-- | gdb/testsuite/lib/dap-support.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 4 |
9 files changed, 153 insertions, 72 deletions
diff --git a/gdb/testsuite/gdb.dap/attach-fail.exp b/gdb/testsuite/gdb.dap/attach-fail.exp new file mode 100644 index 0000000..8992f62 --- /dev/null +++ b/gdb/testsuite/gdb.dap/attach-fail.exp @@ -0,0 +1,32 @@ +# Copyright 2025 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/>. + +# Test "attach" failure in DAP. + +require can_spawn_for_attach allow_dap_tests + +load_lib dap-support.exp + +# Passing an empty remote name here will guarantee a failure without +# trying to find a real remote. +set id [dap_target_remote {""}] + +dap_check_request_and_response "configurationDone" configurationDone + +set resp [lindex [dap_read_response attach $id] 0] +gdb_assert {[dict get $resp success] == "false"} \ + "attach failed" + +dap_shutdown diff --git a/gdb/testsuite/gdb.tui/gdb.tcl b/gdb/testsuite/gdb.tui/gdb.sh index ca207ed..0079a3f 100755 --- a/gdb/testsuite/gdb.tui/gdb.tcl +++ b/gdb/testsuite/gdb.tui/gdb.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env tclsh +#!/bin/sh # Copyright 2025 Free Software Foundation, Inc. @@ -15,6 +15,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -puts "foo\033(%5" +printf "foo\033(%%5" -gets stdin +read diff --git a/gdb/testsuite/gdb.tui/pr30056.exp b/gdb/testsuite/gdb.tui/pr30056.exp index dd3b25c..3cf5e90 100644 --- a/gdb/testsuite/gdb.tui/pr30056.exp +++ b/gdb/testsuite/gdb.tui/pr30056.exp @@ -22,66 +22,72 @@ require {have_host_locale C.UTF-8} tuiterm_env +standard_testfile tui-long-line.c + +if { [build_executable "failed to prepare" $testfile $srcfile] == -1 } { + return +} + save_vars { env(LC_ALL) } { setenv LC_ALL C.UTF-8 # Start terminal. - Term::clean_restart 24 80 - - # Start TUI. - if {![Term::enter_tui]} { - unsupported "TUI not supported" - return - } - - # Send "^R", starting reverse-i-search. - send_gdb "\022" - Term::wait_for_region_contents 0 $Term::_cur_row $Term::_cols 1 \ - [string_to_regexp "(reverse-i-search)`': "] - - # Send "xyz". - send_gdb "xyz" - Term::wait_for_region_contents 0 $Term::_cur_row $Term::_cols 1 \ - [string_to_regexp "(failed reverse-i-search)`xyz': "] - - # Send arrow-right. - send_gdb "\033\[C" + Term::clean_restart 24 80 $testfile +} - # We need to the arrow-right to be processed by readline, before we - # send the following ^C. Waiting 1 ms seems to do that. - after 1 +# Start TUI. +if {![Term::enter_tui]} { + unsupported "TUI not supported" + return +} - # Send ^C. +# Send "^R", starting reverse-i-search. +send_gdb "\022" +gdb_assert { [Term::wait_for_region_contents 0 $Term::_cur_row $Term::_cols 1 \ + [string_to_regexp "(reverse-i-search)`': "]] } \ + "reverse-i-search" + +# Send "xyz". +send_gdb "xyz" +gdb_assert { [Term::wait_for_region_contents 0 $Term::_cur_row $Term::_cols 1 \ + [string_to_regexp "(failed reverse-i-search)`xyz': "]] } \ + "xyz" + +# Send arrow-right. +send_gdb "\033\[C" +# Wait for arrow-right effect. +gdb_assert { [Term::wait_for_region_contents 1 5 78 1 \ + [string_to_regexp " ain (void)"]] } "arrow right" + +# Send ^C. +send_gdb "\003" +gdb_assert { [Term::wait_for "Quit"] } "Control-C" + +set test "Control-C aborts isearch" + +# Send "xyz", again. +send_gdb "xyz" +# Wait for xyx to appear. +gdb_assert { [Term::wait_for_region_contents \ + 0 $Term::_cur_row $Term::_cols 1 "xyz"] } \ + "xyz, again" + +if { [Term::check_region_contents_p 0 $Term::_cur_row $Term::_cols 1 \ + "^$gdb_prompt xyz"] } { + pass $test + + # Send ^C to clear the command line. send_gdb "\003" - gdb_assert { [Term::wait_for "Quit"] } "Control-C" - - # Uncomment this to simulate that PR cli/30498 is fixed. - #send_gdb "\007" - - set test "Control-C aborts isearch" - - # Send "xyz", again. - send_gdb "xyz" - # Wait for xyx to appear. - Term::wait_for_region_contents 0 $Term::_cur_row $Term::_cols 1 "xyz" +} else { + # Sending ^C currently doesn't abort the i-search. + fail $test - if { [Term::check_region_contents_p 0 $Term::_cur_row $Term::_cols 1 \ - "^$gdb_prompt xyz"] } { - pass $test - - # Send ^C to clear the command line. - send_gdb "\003" - } else { - # Sending ^C currently doesn't abort the i-search. - fail $test - - # At this point we don't have a responsive prompt. Send ^G to abort - # the i-search. - send_gdb "\007" - } - - # We need a responsive prompt here, to deal with the "monitor exit" - # that native-extended-gdbserver will send. Check that we have a - # responsive prompt. - Term::command "echo \\n" + # At this point we don't have a responsive prompt. Send ^G to abort + # the i-search. + send_gdb "\007" } + +# We need a responsive prompt here, to deal with the "monitor exit" +# that native-extended-gdbserver will send. Check that we have a +# responsive prompt. +Term::command "echo \\n" diff --git a/gdb/testsuite/gdb.tui/tui-long-line.c b/gdb/testsuite/gdb.tui/tui-long-line.c new file mode 100644 index 0000000..8f1d6eb --- /dev/null +++ b/gdb/testsuite/gdb.tui/tui-long-line.c @@ -0,0 +1,24 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2025 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/>. */ + + +int +main (void) +{ + /* This is a comment that is meant to be longer than the usual 80 characters width of a tuiterm. */ + return 0; +} diff --git a/gdb/testsuite/gdb.tui/tui-missing-src.exp b/gdb/testsuite/gdb.tui/tui-missing-src.exp index aca417c..ae98775 100644 --- a/gdb/testsuite/gdb.tui/tui-missing-src.exp +++ b/gdb/testsuite/gdb.tui/tui-missing-src.exp @@ -27,6 +27,7 @@ # Check if start command is supported. require !use_gdb_stub +require allow_tui_tests tuiterm_env diff --git a/gdb/testsuite/gdb.tui/tuiterm-2.exp b/gdb/testsuite/gdb.tui/tuiterm-2.exp index a451834..9e3ddc7 100644 --- a/gdb/testsuite/gdb.tui/tuiterm-2.exp +++ b/gdb/testsuite/gdb.tui/tuiterm-2.exp @@ -152,14 +152,17 @@ with_override Term::accept_gdb_output test_accept_gdb_output { } } -with_test_prefix "Unrecognized escape sequence" { - spawn $srcdir/$subdir/gdb.tcl - switch_gdb_spawn_id $spawn_id +proc_with_prefix unrecognized_escape_sequence {} { + if { [spawn $::srcdir/$::subdir/gdb.sh] == 0 } { + unsupported "cannot spawn gdb.sh" + return + } + switch_gdb_spawn_id $spawn_id Term::_setup 4 20 - save_vars timeout { - set timeout 1 + save_vars ::timeout { + set ::timeout 1 set line { 0 0 20 1 } @@ -178,4 +181,9 @@ with_test_prefix "Unrecognized escape sequence" { "echoed escape sequence" } Term::dump_screen + + close $spawn_id + clear_gdb_spawn_id } + +unrecognized_escape_sequence diff --git a/gdb/testsuite/gdb.tui/wrap-line.exp b/gdb/testsuite/gdb.tui/wrap-line.exp index a1ba706..67ad36c 100644 --- a/gdb/testsuite/gdb.tui/wrap-line.exp +++ b/gdb/testsuite/gdb.tui/wrap-line.exp @@ -104,29 +104,35 @@ proc test_wrap_cli_tui { auto_detected_width } { set re1 "Number of characters gdb thinks are in a line is ($::decimal)\\." set re2 \ "Number of characters readline reports are in a line is ($::decimal)\\." + set re3 \ + "Readline wrapping mode: (\[a-z\]+) \[\^\r\n]*" set cmd "maint info screen" set re \ [multi_line \ "^$re1" \ $re2 \ - ".*"] + ".*" \ + $re3] gdb_test_multiple $cmd "" { -re -wrap $re { set gdb_width $expect_out(1,string) set readline_width $expect_out(2,string) + set wrapping_mode $expect_out(3,string) pass $gdb_test_name } } - gdb_assert { $gdb_width == $::cols } "width" + if { $wrapping_mode == "readline" } { + gdb_assert { $gdb_width == $::cols } "width" - # TERM=ansi, so readline hides the last column. - gdb_assert { $gdb_width == [expr $readline_width + 1] } + # TERM=ansi, so readline hides the last column. + gdb_assert { $gdb_width == [expr $readline_width + 1] } - with_test_prefix cli { - set wrap_width $readline_width + with_test_prefix cli { + set wrap_width $readline_width - test_wrap $wrap_width 0 + test_wrap $wrap_width 0 + } } with_test_prefix tui { @@ -172,7 +178,7 @@ with_test_prefix width-auto-detected { set test "startup prompt" gdb_test_multiple "" $test { - -re "^$gdb_prompt $" { + -re "^(\033\\\[6n)?$gdb_prompt $" { pass "$test" } } diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp index 2d962e6..5c078ca 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -231,9 +231,9 @@ proc dap_read_response {cmd num} { set d [_dap_read_json] if {[dict get $d type] == "response"} { if {[dict get $d request_seq] != $num} { - error "saw wrong request_seq in $obj" + error "saw wrong request_seq in $d" } elseif {[dict get $d command] != $cmd} { - error "saw wrong command in $obj" + error "saw wrong command in $d" } else { return [list $d $result] } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index f05e1c8..9497850 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3122,6 +3122,10 @@ gdb_caching_proc allow_dlmopen_tests {} { # Return 1 if we should allow TUI-related tests. gdb_caching_proc allow_tui_tests {} { + if { [istarget *-*-mingw*] } { + # Avoid "Cannot enable the TUI when output is not a terminal". + return 0 + } set output [remote_exec host $::GDB "$::INTERNAL_GDBFLAGS --configuration"] return [expr {[string first "--enable-tui" $output] != -1}] } |