]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.python/tui-window-names.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / tui-window-names.exp
CommitLineData
1d506c26 1# Copyright (C) 2022-2024 Free Software Foundation, Inc.
7abc6ec0
AB
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 that GDB rejects invalid TUI window names, and that valid names
17# are allowed.
18
19load_lib gdb-python.exp
20
b5075fb6 21require allow_python_tests allow_tui_tests
79749205 22
7abc6ec0
AB
23tuiterm_env
24
25clean_restart
26
7abc6ec0
AB
27# Define a function we can use as a window constructor. If this ever
28# gets called we'll throw an error, but that's OK, this test doesn't
29# actually try to create any windows.
30gdb_test_multiline "create a window constructor" \
31 "python" "" \
32 "def failwin(win):" "" \
33 " raise RuntimeError('failwin')" "" \
34 "end" ""
35
36# Check for some of the characters that can't be used within a window
37# name.
38foreach c {$ * \{ \} ( ) @ #} {
39 set re [string_to_regexp "$c"]
40 gdb_test "python gdb.register_window_type('te${c}st', failwin)" \
41 [multi_line \
42 "gdb.error: invalid character '${re}' in window name" \
43 "Error while executing Python code\\." ]
44
45 gdb_test "python gdb.register_window_type('${c}test', failwin)" \
46 [multi_line \
47 "gdb.error: invalid character '${re}' in window name" \
48 "Error while executing Python code\\." ]
49}
50
51# Check that whitespace within a window name is rejected.
52foreach c [list " " "\\t" "\\n" "\\r"] {
53 gdb_test "python gdb.register_window_type('te${c}st', failwin)" \
54 [multi_line \
55 "gdb.error: invalid whitespace character in window name" \
56 "Error while executing Python code\\." ]
57}
58
59# Check some of the characters which are allowed within a window name,
60# but are not allowed to be used as the first character.
61foreach c {1 _ - .} {
62 set re [string_to_regexp "$c"]
63 gdb_test "python gdb.register_window_type('${c}test', failwin)" \
64 [multi_line \
65 "gdb.error: window name must start with a letter, not '${re}'" \
66 "Error while executing Python code\\." ]
67}
68
69# Check different capitalisations.
70gdb_test_no_output "python gdb.register_window_type('TEST', failwin)"
71gdb_test_no_output "python gdb.register_window_type('test', failwin)"
72gdb_test_no_output "python gdb.register_window_type('tEsT', failwin)"
73gdb_test_no_output "python gdb.register_window_type('TeSt', failwin)"
74
75# Check a set of characters that can appear within a name, just not
76# necessarily as the first character. We check at both the end of the
77# name, and within the name.
78foreach c {1 _ - . A} {
79 set re [string_to_regexp "$c"]
80 gdb_test_no_output "python gdb.register_window_type('test${c}', failwin)"
81 gdb_test_no_output "python gdb.register_window_type('te${c}st', failwin)"
82}