diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-01-22 16:25:15 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-02-08 09:51:45 +0000 |
commit | 5fb97639911a4ab55f0287b5deea2f06d83a5f8c (patch) | |
tree | c983cfd40d8351f71a2b0cbb00fd2d05b81c5377 /gdb | |
parent | d6f2700b4863f24d8fdab2f549a39a9453b86e93 (diff) | |
download | gdb-5fb97639911a4ab55f0287b5deea2f06d83a5f8c.zip gdb-5fb97639911a4ab55f0287b5deea2f06d83a5f8c.tar.gz gdb-5fb97639911a4ab55f0287b5deea2f06d83a5f8c.tar.bz2 |
gdb/testsuite: fix implementation of delete line in tuiterm.exp
The implementation of the delete line escape sequence in tuiterm.exp
was wrong. Delete should take a count and then delete COUNT lines at
the current cursor location, all remaining lines in the scroll region
are moved up to replace the deleted lines, with blank lines being
added at the end of the scroll region.
It's not clear to me what "scroll region" means here (or at least how
that is defined), but for now I'm just treating the whole screen as
the scroll region, which seems to work fine.
In contrast the current broken implementation deletes COUNT lines at
the cursor location moving the next COUNT lines up to fill the gap.
The rest of the screen is then cleared.
gdb/testsuite/ChangeLog:
* gdb.tui/scroll.exp: New file.
* gdb.tui/tui-layout-asm-short-prog.exp: Update expected results.
* lib/tuiterm.exp (Term::_csi_M): Delete count lines, scroll
remaining lines up.
(Term::check_region_contents): New proc.
(Term::check_box_contents): Use check_region_contents.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/testsuite/gdb.tui/scroll.exp | 62 | ||||
-rw-r--r-- | gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/lib/tuiterm.exp | 49 |
4 files changed, 106 insertions, 18 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 222e819..5082f1d 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2021-02-08 Andrew Burgess <andrew.burgess@embecosm.com> + + * gdb.tui/scroll.exp: New file. + * gdb.tui/tui-layout-asm-short-prog.exp: Update expected results. + * lib/tuiterm.exp (Term::_csi_M): Delete count lines, scroll + remaining lines up. + (Term::check_region_contents): New proc. + (Term::check_box_contents): Use check_region_contents. + 2021-02-06 Tom de Vries <tdevries@suse.de> PR testsuite/26922 diff --git a/gdb/testsuite/gdb.tui/scroll.exp b/gdb/testsuite/gdb.tui/scroll.exp new file mode 100644 index 0000000..4566bd8 --- /dev/null +++ b/gdb/testsuite/gdb.tui/scroll.exp @@ -0,0 +1,62 @@ +# Copyright 2021 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. +# +# Well, we would if there wasn't a massive bug in GDB!! The command +# window contents will not be exactly what you'd expect after this +# test has run. +# +# The expected output pattern given here is crafted so that it matches +# those bits of the GDB output that will be correct, and ignores those +# parts of the output that are known to be incorrect. +# +# If/when GDB is fixed it is expected that this test will continue to +# pass, though it is possible that at that point the pattern here +# could be improved. +Term::check_region_contents "check cmd window" 0 16 80 8 \ + [multi_line \ + "\[^\r\n\]*\\\$7 = 6\[^\r\n\]+" \ + "\\(gdb\\)\[^\r\n\]+" \ + "\[^\r\n\]*\\\$8 = 7\[^\r\n\]+" \ + "\\(gdb\\)\[^\r\n\]+" \ + "\[^\r\n\]*\\\$9 = 8\[^\r\n\]+" \ + "\\(gdb\\)\[^\r\n\]+" \ + "\[^\r\n\]*\\\$10 = 9\[^\r\n\]+" \ + "\\(gdb\\)"] diff --git a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp index 7d3c8e1..a7d4d91 100644 --- a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp +++ b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp @@ -43,7 +43,9 @@ set first_line [Term::get_line 1] # instruction in the program. Term::command "+ 13" Term::check_box_contents "check asm box contents again" 0 0 80 15 \ - "^ *$hex\[^\n\]+\n +\n" + [multi_line \ + "^ *$hex\[^\r\n\]+" \ + "\\s+"] # Now scroll backward again, we should return to the start of the # program. diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 4160586..3f6271e 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -367,16 +367,15 @@ namespace eval Term { variable _chars set y $_cur_row - set next_y [expr {$y + 1}] - while {$count > 0 && $next_y < $_rows} { + set next_y [expr {$y + $count}] + while {$next_y < $_rows} { for {set x 0} {$x < $_cols} {incr x} { set _chars($x,$y) $_chars($x,$next_y) } incr y incr next_y - incr count -1 } - _clear_lines $next_y $_rows + _clear_lines $y $_rows } } @@ -789,6 +788,33 @@ namespace eval Term { } } + # Check that the region of the screen described by X, Y, WIDTH, + # and HEIGHT match REGEXP. This is like check_contents except + # only part of the screen is checked. This can be used to check + # the contents within a box (though check_box_contents is a better + # choice for boxes with a border). + proc check_region_contents { test_name x y width height regexp } { + variable _chars + + # Now grab the contents of the box, join each line together + # with a '\r\n' sequence and match against REGEXP. + set result "" + for {set yy $y} {$yy < [expr {$y + $height}]} {incr yy} { + if {$yy > $y} { + # Add the end of line sequence only if this isn't the + # first line. + append result "\r\n" + } + for {set xx $x} {$xx < [expr {$x + $width}]} {incr xx} { + append result [lindex $_chars($xx,$yy) 0] + } + } + + if {![gdb_assert {[regexp -- $regexp $result]} $test_name]} { + dump_screen + } + } + # Check the contents of a box on the screen. This is a little # like check_contents, but doens't check the whole screen # contents, only the contents of a single box. This procedure @@ -805,19 +831,8 @@ namespace eval Term { return } - # Now grab the contents of the box, join each line together - # with a newline character and match against REGEXP. - set result "" - for {set yy [expr {$y + 1}]} {$yy < [expr {$y + $height - 1}]} {incr yy} { - for {set xx [expr {$x + 1}]} {$xx < [expr {$x + $width - 1}]} {incr xx} { - append result [lindex $_chars($xx,$yy) 0] - } - append result "\n" - } - - if {![gdb_assert {[regexp -- $regexp $result]} $test_name]} { - dump_screen - } + check_region_contents $test_name [expr {$x + 1}] [expr {$y + 1}] \ + [expr {$width - 2}] [expr {$height - 2}] $regexp } # A debugging function to dump the current screen, with line |