]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.tui/winheight.exp
gold: Properly remove the versioned symbol
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.tui / winheight.exp
1 # Copyright 2019-2024 Free Software Foundation, Inc.
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 # Test the "winheight" command.
17
18 tuiterm_env
19
20 standard_testfile tui-layout.c
21
22 if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
23 return -1
24 }
25
26 Term::clean_restart 24 80 $testfile
27 if {![Term::enter_tui]} {
28 unsupported "TUI not supported"
29 return
30 }
31
32 Term::check_box "source box" 0 0 80 15
33
34 Term::command "winheight cmd +5"
35 Term::check_box "smaller source box" 0 0 80 10
36
37 Term::command "winheight cmd -5"
38 Term::check_box "larger source box" 0 0 80 15
39
40 Term::command "winheight src -5"
41 Term::check_box "smaller source box again" 0 0 80 10
42
43 Term::command "winheight src +5"
44 Term::check_box "larger source box again" 0 0 80 15
45
46 # Check that attempting a window to be too large gives an error.
47 Term::command "winheight src 100"
48 Term::check_box "source box has not changed" 0 0 80 15
49 Term::check_region_contents "check error message about src size 100" 0 16 80 8 \
50 [multi_line "$gdb_prompt winheight src 100\\s+" \
51 "warning: Invalid window height specified\\s+" \
52 "$gdb_prompt"]
53
54 # Check that incrementing to a size that is "too big" will trigger an
55 # error, and that the window doesn't resize.
56 Term::command "winheight src 20"
57 Term::check_box "source box is at its max size" 0 0 80 20
58 Term::command "winheight src +1"
59 Term::check_box "source box is still at its max size" 0 0 80 20
60 Term::check_region_contents "check error message about src +1" 0 21 80 3 \
61 [multi_line "$gdb_prompt winheight src \\+1\\s+" \
62 "warning: Invalid window height specified\\s+" \
63 "$gdb_prompt"]
64
65 # Reset the cmd window to a sane size.
66 Term::command "winheight cmd 8"
67
68 Term::command "layout regs"
69 Term::check_box "register window" 0 0 80 8
70 Term::check_box "source window" 0 7 80 8
71
72 Term::command "winheight cmd 10"
73 Term::check_box "register window after resize" 0 0 80 7
74 Term::check_box "source window after resize" 0 6 80 7
75
76 # At one point we had a bug where adjusting the winheight would result
77 # in GDB keeping hold of duplicate window pointers, which it might
78 # then try to delete when the layout was changed. Running this test
79 # under valgrind would expose that bug.
80 Term::command "layout asm"
81 Term::command "winheight cmd 8"
82 Term::check_box "check for asm window" 0 0 80 15
83
84
85 # Check what happens when we switch from src layout to split layout.
86 # The interesting thing here is that the src layout has one flexible
87 # window (the src), the status window, which is of fixed size, and the
88 # cmd window, which tries to retain its size when a layout changes.
89 #
90 # In contrast, the split layout has both a src and asm window, plus
91 # the same status and cmd windows.
92 #
93 # Of particular interest here is the first test, where we maximise the
94 # cmd window before switching to split. This requires gdb to realise
95 # that it has to shrink the cmd window, even though this is something
96 # gdb usually avoids doing.
97 #
98 # Each test here is a size for the src window in the 'src' layout.
99 # The test then switches to the 'split' layout, and calculates the
100 # expected window sizes.
101 foreach_with_prefix cmd_size {20 12 5} {
102 set src_size_before [expr 24 - ${cmd_size} - 1]
103 set split_size [expr (24 - ${cmd_size}) / 2]
104
105 if { $split_size < 3 } {
106 # The minimum window size is 3, so force that.
107 set src_size_after 3
108 set asm_size_after 3
109 } elseif { [expr $split_size % 2] == 0 } {
110 # The remaining space can be divided evenly between the two
111 # windows.
112 set src_size_after ${split_size}
113 set asm_size_after ${split_size}
114 } else {
115 # The space can't be divided evenly, the asm window will get
116 # the extra line.
117 set src_size_after ${split_size}
118 set asm_size_after [expr ${split_size} + 1]
119 }
120
121 Term::command "layout src"
122 Term::command "winheight cmd ${cmd_size}"
123 Term::check_box "check for src window" 0 0 80 ${src_size_before}
124
125 # Both windows should be of equal size, which will be their minimum.
126 Term::command "layout split"
127 Term::check_box "check for src window in split" 0 0 80 ${src_size_after}
128 Term::check_box "check for asm window in split" 0 [expr ${src_size_after} - 1] 80 ${asm_size_after}
129 }