Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.tui / basic.exp
blobecb91de709eac2196bae6d64b6029b32a0af2b9f
1 # Copyright 2019-2024 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 # Basic TUI tests.
18 tuiterm_env
20 # Use main-one-line.c to get the line info at a predictable location without
21 # resorting to a dwarf assembly test-case.
22 standard_testfile main-one-line.c
24 set main_line [gdb_get_line_number "int main"]
26 if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
27     return -1
30 Term::clean_restart 24 80 $testfile
31 if {![Term::enter_tui]} {
32     unsupported "TUI not supported"
33     return
36 set text [Term::get_all_lines]
37 gdb_assert {![string match "No Source Available" $text]} \
38     "initial source listing"
40 Term::command "list -q main"
41 set main_re "int main \\(\\) { return 0; }"
42 Term::check_contents "list -q main" "$main_line *$main_re"
44 # Get the first source line.
45 set line [Term::get_line 1]
46 # Send an up arrow.
47 send_gdb "\033\[A"
48 # Wait for a redraw and check that the first line changed.
49 if {[Term::wait_for [string_to_regexp $line]] \
50         && [Term::get_line 1] != $line\
51         && [Term::get_line 2] == $line} {
52     pass "scroll up"
53 } else {
54     fail "scroll up"
57 # Get the actual screen line that main is on.
58 set main_screen_line -1
59 for { set i 1 } { $i <= $Term::_cols } { incr i } {
60     set line [Term::get_line $i]
61     if { [regexp -- "$main_line\[\\t \]+$main_re" $line] } {
62         set main_screen_line $i
63         break
64     }
67 # Confirm that 'main ()' is where we expect it to be.  This relies on the
68 # current way we position source code on the screen, which might change in
69 # the future.
70 gdb_assert { $main_screen_line == 7 } \
71     "check main is where we expect on the screen"
72 if { $main_screen_line == -1 } {
73     return 0
76 # Check the horizontal scrolling.
77 set shifted_main_re [string range $main_re 1 end]
78 set regexp "$main_line\[\\t \]+$shifted_main_re"
79 # Send a right arrow.
80 send_gdb "\033\[C"
81 if {[Term::wait_for $regexp]} {
82     pass "scroll right"
83 } else {
84     fail "scroll right"
86 set line [Term::get_line $main_screen_line]
87 # Send a down arrow.
88 send_gdb "\033\[B"
89 if {[Term::wait_for $regexp] \
90         && [Term::get_line [expr {$main_screen_line - 1}]] == $line} {
91     pass "scroll down"
92 } else {
93     fail "scroll down"
96 Term::check_box "source box" 0 0 80 15
98 Term::command "layout asm"
99 Term::check_contents "asm window shows main" "$hex <main>"
101 Term::check_box "asm box" 0 0 80 15
103 Term::command "layout split"
104 Term::check_contents "split layout contents" \
105     "$main_line *$main_re.*$hex <main>"
107 Term::check_box "source box in split layout" 0 0 80 8
108 Term::check_box "asm box in split layout" 0 7 80 8
110 set re_noattr "\[^<\]"
112 set status_window_line 15
114 set status [Term::get_line_with_attrs $status_window_line]
115 gdb_assert { [regexp "^<reverse:1>$re_noattr*<reverse:0>$" $status] == 1} \
116     "status window: reverse"