]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 2021-2023 Free Software Foundation, Inc. |
cc81bc2d LS |
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 tab-completion for the 'show user' command. | |
17 | ||
18 | load_lib completion-support.exp | |
19 | ||
20 | # This test does not require any file to be loaded. | |
21 | clean_restart | |
22 | ||
23 | # Define the 'foo' and 'bar' commands so we have something to complete. | |
24 | set re [multi_line "Type commands for definition of \"foo\"." \ | |
25 | "End with a line saying just \"end\"." \ | |
26 | ">$" ] | |
27 | gdb_test_multiple "define foo" "define user command: foo" { | |
28 | -re $re { | |
29 | gdb_test "print \"foo\"\nend" "" $gdb_test_name | |
30 | } | |
31 | } | |
32 | ||
33 | set re [multi_line "Type commands for definition of \"bar\"." \ | |
34 | "End with a line saying just \"end\"." \ | |
35 | ">$"] | |
36 | gdb_test_multiple "define bar" "define user command: bar" { | |
37 | -re $re { | |
38 | gdb_test "print \"bar\"\nend" "" $gdb_test_name | |
39 | } | |
40 | } | |
41 | ||
42 | # The completer should show both options. | |
43 | test_gdb_complete_multiple "show user " "" "" "bar foo" | |
44 | ||
45 | # If we give the beginning of one of the commands, it should complete it. | |
46 | test_gdb_complete_unique "show user f" "show user foo" | |
47 | test_gdb_complete_unique "show user b" "show user bar" | |
48 | ||
49 | # Define a user prefix. | |
50 | gdb_test "define-prefix mygroup" | |
51 | ||
52 | # Add a user defined command in the user defined prefix. | |
53 | set re [multi_line "Type commands for definition of \"mygroup mycommand\"." \ | |
54 | "End with a line saying just \"end\"." \ | |
55 | ">$"] | |
56 | set test_name "define user command: mygroup mycommand" | |
57 | gdb_test_multiple "define mygroup mycommand" $test_name { | |
58 | -re $re { | |
59 | gdb_test "print \"42\"\nend" "" $gdb_test_name | |
60 | } | |
61 | } | |
62 | ||
63 | with_test_prefix "with user-prefix" { | |
64 | # We now expect the completion to yield only 3 results. As the 'mycommand' | |
65 | # is within the 'mygroup' prefix, it should not be reachable without | |
66 | # traversing 'mygroup' first. | |
67 | test_gdb_complete_multiple "show user " "" "" "bar foo mygroup" | |
68 | } | |
69 | ||
70 | # Check that we can complete commands defined under a prefix. | |
71 | test_gdb_complete_unique "show user m" "show user mygroup" | |
72 | test_gdb_complete_unique "show user mygroup " "show user mygroup mycommand" |