]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Add gdb.tui/tui-mode-switch.exp
authorTom de Vries <tdevries@suse.de>
Fri, 15 Aug 2025 12:48:10 +0000 (14:48 +0200)
committerTom de Vries <tdevries@suse.de>
Fri, 15 Aug 2025 12:48:10 +0000 (14:48 +0200)
Add test-case gdb.tui/tui-mode-switch.exp, a regression test for
PR tui/30523.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30523

gdb/testsuite/gdb.tui/tui-mode-switch.exp [new file with mode: 0644]

diff --git a/gdb/testsuite/gdb.tui/tui-mode-switch.exp b/gdb/testsuite/gdb.tui/tui-mode-switch.exp
new file mode 100644 (file)
index 0000000..827677c
--- /dev/null
@@ -0,0 +1,52 @@
+require allow_tui_tests
+
+tuiterm_env
+
+if { [ishost *-*-*bsd*] } {
+    # We need support for alternate screen, and xterm doesn't have it.
+    set term xterm-clear
+} else {
+    set term xterm
+}
+
+Term::with_term $term {
+    Term::clean_restart 12 40
+}
+
+if {![Term::prepare_for_tui]} {
+    unsupported "TUI not supported"
+    return 0
+}
+
+# Generate prompt.
+Term::gen_prompt
+
+# Move to last line.
+for { set i 1 } { $i <= 11 } { incr i } {
+    send_gdb "\n"
+    Term::wait_for ""
+}
+
+# Type "foo".
+send_gdb "foo"
+set line { 0 11 40 1 }
+Term::wait_for_region_contents {*}$line "^$gdb_prompt foo"
+
+# Enter TUI.
+send_gdb "\030\001"
+Term::wait_for ""
+
+# Exit TUI, type b.
+send_gdb "\030\001"
+send_gdb "b"
+Term::wait_for_region_contents {*}$line "^$gdb_prompt b"
+
+# Check that we don't see "boo".
+gdb_assert { ![Term::check_region_contents_p {*}$line "^$gdb_prompt boo"] } \
+    "no boo"
+Term::dump_screen
+
+# We need an empty prompt here, to deal with the "monitor exit" that
+# native-extended-gdbserver will send.  Send a backspace.
+send_gdb "\010"
+Term::wait_for ""