[gdb/testsuite] Fix gdb.tui/wrap-line.exp with wrapping disabled

There are a couple of ways that readline wrapping can be disabled:
- using "set horizontal-scroll-mode on" in INPUTRC,
- using a TERM setting like TERM=dumb, and
- building gdb with stub-termcap.

Using a trigger patch in default_gdb_init that adds
"set horizontal-scroll-mode on" to INPUTRC:
...
-    setenv INPUTRC [cached_file inputrc "set enable-bracketed-paste off"]
+    setenv INPUTRC [cached_file inputrc "set enable-bracketed-paste off\nset horizontal-scroll-mode on"]
...
we can easily reproduce a failure in gdb.tui/wrap-line.exp mentioned in
PR testsuite/31201 (which was reported for the stub-termcap case):
...
WARNING: timeout in accept_gdb_output
Screen Dump (size 50 columns x 24 rows, cursor at column 34, row 1):
    0 Quit
    1 <89012345678901234567890123456789W
    2
    ...
    23
FAIL: gdb.tui/wrap-line.exp: width-hard-coded: cli: wrap
...

Fix this by accepting the horizontal-scroll-mode style output.  We do
this only when in CLI mode though, when in TUI wrapping works as before
because it doesn't rely on readline.

Tested on x86_64-linux.

Co-Authored-By: Tom de Vries <tdevries@suse.de>

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31201
This commit is contained in:
Bernd Edlinger
2024-08-12 17:32:44 +02:00
committed by Tom de Vries
parent 37ef6d976a
commit 250f1bbaf3

View File

@@ -50,7 +50,7 @@ proc fill_line { width } {
}
# Test wrapping.
proc test_wrap { wrap_width } {
proc test_wrap { wrap_width tui } {
# Generate a prompt and parse it.
send_gdb "\003"
gdb_assert { [Term::wait_for "(^|$::gdb_prompt )$::re_control_c"] } "start line"
@@ -65,12 +65,31 @@ proc test_wrap { wrap_width } {
send_gdb "W"
# Check that the wrap occurred at the expected location.
gdb_assert { [Term::wait_for_region_contents 0 0 $::cols $::lines \
"$::gdb_prompt $str$space\r\nW"] } "wrap"
set re_wrap \
[multi_line \
"$::gdb_prompt $str$space" \
"W"]
set re_no_wrap \
[multi_line \
"" \
"<.*W"]
if { $tui } {
set re $re_wrap
} else {
set re ($re_wrap|$re_no_wrap)
}
gdb_assert { [Term::wait_for_region_contents 0 0 $::cols $::lines $re] } "wrap"
# Generate a prompt and parse it.
send_gdb "\003"
gdb_assert { [Term::wait_for "^W$::re_control_c"] } "prompt after wrap"
set re_wrap W$::re_control_c
set re_no_wrap <.*W$::re_control_c
if { $tui } {
set re $re_wrap
} else {
set re ($re_wrap|$re_no_wrap)
}
gdb_assert { [Term::wait_for ^$re] } "prompt after wrap"
}
# Test wrapping in both CLI and TUI.
@@ -107,7 +126,7 @@ proc test_wrap_cli_tui { auto_detected_width } {
with_test_prefix cli {
set wrap_width $readline_width
test_wrap $wrap_width
test_wrap $wrap_width 0
}
with_test_prefix tui {
@@ -126,7 +145,7 @@ proc test_wrap_cli_tui { auto_detected_width } {
# for wrapping from curses.
set wrap_width $::cols
test_wrap $wrap_width
test_wrap $wrap_width 1
}
}