binutils-gdb/gdb/testsuite/gdb.tui/scroll.exp
Tom de Vries 4a43e2435b [gdb/testsuite] Fix gdb.tui/scroll.exp with read1
When running test-case gdb.tui/scroll.exp, I get:
...
Box Dump (80 x 8) @ (0, 0):
    0 $17 = 16
    1 (gdb) p 17
    2 $18 = 17
    3 (gdb) p 18
    4 $19 = 18
    5 (gdb) p 19
    6 $20 = 19
    7 (gdb)
PASS: gdb.tui/scroll.exp: check cmd window in flip layout
...
but with check-read1 I get instead:
...
Box Dump (80 x 8) @ (0, 0):
    0 (gdb) 15
    1 (gdb) p 16
    2 $17 = 16
    3 (gdb) p 17
    4 $18 = 17
    5 (gdb) p 18
    6 $19 = 18
    7 (gdb) p 19
FAIL: gdb.tui/scroll.exp: check cmd window in flip layout
...

The "p 19" command is handled by Term::command, which sends the command and then
does Term::wait_for "^$gdb_prompt [string_to_regexp $cmd]", which:
- matches the line with "(gdb) p 19", and
- tries to match the following prompt "(gdb) "

The problem is that scrolling results in reissuing output before the "(gdb) p
19", and the second matching triggers on that.  Consequently, wait_for no
longer translates gdb output into screen actions, and the screen does not
reflect the result of "p 19".

Fix this by using a new proc wait_for_region_contents, which in contrast to
wait_for can handle a multi-line regexp.

Tested on x86_64-linux with make targets check and check-read1.
2022-05-08 19:47:40 +02:00

83 lines
2.5 KiB
Plaintext

# Copyright 2021-2022 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/>.
# Check scrolling in the command window. This test only covers the
# case where scrolling in the command window is caused by issuing many
# non-inferior related commands, as once the inferior is given control
# the terminal settings are modified and our tuiterm library really
# gets confused.
tuiterm_env
standard_testfile tui-layout.c
if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
return -1
}
Term::clean_restart 24 80 $testfile
if {![Term::enter_tui]} {
unsupported "TUI not supported"
return
}
for {set i 0} {$i < 10} {incr i 1} {
Term::command "p $i"
}
# Now check that the contents of the command window are as expected.
Term::check_region_contents "check cmd window" 0 16 80 8 \
[multi_line \
"\\\$7 = 6\\s+" \
"\\(gdb\\) p 7\\s+" \
"\\\$8 = 7\\s+" \
"\\(gdb\\) p 8\\s+" \
"\\\$9 = 8\\s+" \
"\\(gdb\\) p 9\\s+" \
"\\\$10 = 9\\s+" \
"\\(gdb\\)"]
# Now create a new layout where the CMD window is at the top of the
# screen. Sitch to this layout and ensure that scrolling still works
# as expected.
Term::command "tui new-layout flip cmd 1 src 1"
Term::command "layout flip"
Term::check_box "src window" 0 8 80 16
Term::command "winheight cmd 8"
Term::check_box "src window after resize" 0 8 80 16
for {set i 10} {$i < 20} {incr i 1} {
set cmd "p $i"
send_gdb "$cmd\n"
Term::wait_for_region_contents 0 0 80 8 \
[multi_line \
"$gdb_prompt [string_to_regexp $cmd]\\s+" \
"\\\$\\d+ = $i\\s+" \
"$gdb_prompt "]
}
# Now check that the contents of the command window are as expected.
Term::check_region_contents "check cmd window in flip layout" 0 0 80 8 \
[multi_line \
"\\\$17 = 16\\s+" \
"\\(gdb\\) p 17\\s+" \
"\\\$18 = 17\\s+" \
"\\(gdb\\) p 18\\s+" \
"\\\$19 = 18\\s+" \
"\\(gdb\\) p 19\\s+" \
"\\\$20 = 19\\s+" \
"\\(gdb\\)"]