]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 2019-2023 Free Software Foundation, Inc. |
c3786b3a TT |
2 | |
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. | |
7 | # | |
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. | |
12 | # | |
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/>. | |
15 | ||
16 | # Basic TUI tests. | |
17 | ||
8c74a764 | 18 | tuiterm_env |
c3786b3a | 19 | |
c178f2a1 TV |
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 | |
23 | ||
24 | set main_line [gdb_get_line_number "int main"] | |
c3786b3a TT |
25 | |
26 | if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} { | |
27 | return -1 | |
28 | } | |
29 | ||
30 | Term::clean_restart 24 80 $testfile | |
31 | if {![Term::enter_tui]} { | |
32 | unsupported "TUI not supported" | |
581bea2c | 33 | return |
c3786b3a TT |
34 | } |
35 | ||
36 | set text [Term::get_all_lines] | |
37 | gdb_assert {![string match "No Source Available" $text]} \ | |
38 | "initial source listing" | |
39 | ||
e777225b | 40 | Term::command "list -q main" |
c178f2a1 TV |
41 | set main_re "int main \\(\\) { return 0; }" |
42 | Term::check_contents "list -q main" "$main_line *$main_re" | |
c3786b3a | 43 | |
9ae6bf64 TT |
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" | |
55 | } | |
56 | ||
c178f2a1 TV |
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 | } | |
65 | } | |
66 | ||
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 } \ | |
f5a7c406 | 71 | "check main is where we expect on the screen" |
c178f2a1 TV |
72 | if { $main_screen_line == -1 } { |
73 | return 0 | |
74 | } | |
75 | ||
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" | |
f5a7c406 AB |
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" | |
85 | } | |
c178f2a1 | 86 | set line [Term::get_line $main_screen_line] |
f5a7c406 AB |
87 | # Send a down arrow. |
88 | send_gdb "\033\[B" | |
89 | if {[Term::wait_for $regexp] \ | |
c178f2a1 | 90 | && [Term::get_line [expr {$main_screen_line - 1}]] == $line} { |
f5a7c406 AB |
91 | pass "scroll down" |
92 | } else { | |
93 | fail "scroll down" | |
94 | } | |
95 | ||
398fdd60 | 96 | Term::check_box "source box" 0 0 80 15 |
d95fc6ee TT |
97 | |
98 | Term::command "layout asm" | |
99 | Term::check_contents "asm window shows main" "$hex <main>" | |
100 | ||
398fdd60 | 101 | Term::check_box "asm box" 0 0 80 15 |
f790b310 TT |
102 | |
103 | Term::command "layout split" | |
c178f2a1 TV |
104 | Term::check_contents "split layout contents" \ |
105 | "$main_line *$main_re.*$hex <main>" | |
f790b310 | 106 | |
b0fcf3e3 AB |
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 |