From: Carl Love Date: Tue, 20 Jul 2021 23:13:50 +0000 (-0500) Subject: Fix for gdb.tui/tui-layout-asm.exp X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=abdd4204a2f80798e5e517aeaa0955778c728bdf;p=binutils-gdb.git Fix for gdb.tui/tui-layout-asm.exp The width of the window is too narrow to display the entire assembly line. The width of the columns in the window changes as the test walks thru the terminal window output. The column change results in the first and second reads of the same line to differ thus causing the test to fail. Increasing the width of the window keeps the column width consistent thru the test. If the test fails, the added check prints an message to the log file if the failure may be due to the window being too narrow. gdb/testsuite/ChangeLog * gdb.tui/tui-layout-asm.exp: Replace window width of 80 with the tui_asm_window_width variable for the width. Add if count_whitespace check. (count_whitespace): New proc --- diff --git a/gdb/testsuite/gdb.tui/tui-layout-asm.exp b/gdb/testsuite/gdb.tui/tui-layout-asm.exp index 19ce333ca9e..3ff5347f5ed 100644 --- a/gdb/testsuite/gdb.tui/tui-layout-asm.exp +++ b/gdb/testsuite/gdb.tui/tui-layout-asm.exp @@ -24,15 +24,23 @@ if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} { return -1 } -Term::clean_restart 24 80 $testfile +# PPC currently needs a minimum window width of 90 to work correctly. +set tui_asm_window_width 90 + +Term::clean_restart 24 ${tui_asm_window_width} $testfile if {![Term::prepare_for_tui]} { unsupported "TUI not supported" return } +# Helper proc, returns a count of the ' ' characters in STRING. +proc count_whitespace { string } { + return [expr {[llength [split $string { }]] - 1}] +} + # This puts us into TUI mode, and should display the ASM window. Term::command_no_prompt_prefix "layout asm" -Term::check_box_contents "check asm box contents" 0 0 80 15 "
" +Term::check_box_contents "check asm box contents" 0 0 ${tui_asm_window_width} 15 "
" # Scroll the ASM window down using the down arrow key. In an ideal # world we'd like to use PageDown here, but currently our terminal @@ -65,6 +73,26 @@ while (1) { && [regexp $re_line [Term::get_line 1]]} { # We scrolled successfully. } else { + if {[count_whitespace ${line}] != \ + [count_whitespace [Term::get_line 1]]} { + # GDB's TUI assembler display will widen columns based on + # the longest item that appears in a column on any line. + # As we have just scrolled, and so revealed a new line, it + # is possible that the width of some columns has changed. + # + # As a result it is possible that part of the line we were + # expected to see in the output is now off the screen. And + # this test will fail. + # + # This is unfortunate, but, right now, there's no easy way + # to "lock" the format of the TUI assembler window. The + # only option appears to be making the window width wider, + # this can be done by adjusting TUI_ASM_WINDOW_WIDTH. + verbose -log "WARNING: The following failure is probably due to the TUI window" + verbose -log " width. See the comments in the test script for more" + verbose -log " details." + } + fail "$testname (scroll failed)" Term::dump_screen break