[GAS, Arm] CLI with architecture sensitive extensions
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-completion.exp
CommitLineData
42a4f53d 1# Copyright (C) 2014-2019 Free Software Foundation, Inc.
7d793aa9
SDJ
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
16set testfile "py-completion"
17
18load_lib gdb-python.exp
19
20gdb_exit
21gdb_start
22
23# Skip all tests if Python scripting is not enabled.
24if { [skip_python_tests] } { continue }
25
dc9366eb
PA
26gdb_test_no_output "source ${srcdir}/${subdir}/${testfile}.py" \
27 "load python file"
7d793aa9
SDJ
28
29# Create a temporary directory
30set testdir "[standard_output_file "py-completion-testdir"]/"
31set testdir_regex [string_to_regexp $testdir]
32set testdir_complete [standard_output_file "py-completion-test"]
33file mkdir $testdir
34
35# This one should always pass.
36send_gdb "completefileinit ${testdir_complete}\t"
37gdb_test_multiple "" "completefileinit completion" {
38 -re "^completefileinit ${testdir_regex}$" {
39 pass "completefileinit completion"
40 }
41}
42
43# Just discarding whatever we typed.
6d62641c
SDJ
44set discard 0
45gdb_test " " ".*" "discard #[incr discard]"
7d793aa9
SDJ
46
47# This is the problematic one.
48send_gdb "completefilemethod ${testdir_complete}\t"
49gdb_test_multiple "" "completefilemethod completion" {
50 -re "^completefilemethod ${testdir_regex} $" {
51 fail "completefilemethod completion (completed filename as wrong command arg)"
52 }
53 -re "^completefilemethod ${testdir_regex}$" {
54 pass "completefilemethod completion"
55 }
56}
57
58# Discarding again
6d62641c 59gdb_test " " ".*" "discard #[incr discard]"
7d793aa9
SDJ
60
61# Another problematic
62set completion_regex "[string_to_regexp [standard_output_file "py-completion-t"]]"
63send_gdb "completefilecommandcond [standard_output_file "py-completion-t\t"]"
64gdb_test_multiple "" "completefilecommandcond completion" {
65 -re "^completefilecommandcond ${testdir}$" {
66 fail "completefilecommandcond completion (completed filename instead of command)"
67 }
68 -re "^completefilecommandcond ${completion_regex}\007$" {
69 pass "completefilecommandcond completion"
70 }
71}
6d62641c
SDJ
72
73# Start gdb over again to clear out current state. This can interfere
74# with the expected output of the below tests in a buggy gdb.
75gdb_exit
76gdb_start
dc9366eb
PA
77gdb_test_no_output "source ${srcdir}/${subdir}/${testfile}.py" \
78 "load python file again"
6d62641c
SDJ
79
80gdb_test_sequence "complete completel" \
81 "list all completions of 'complete completel'" {
82 "completelimit1"
83 "completelimit2"
84 "completelimit3"
85 "completelimit4"
86 "completelimit5"
87 "completelimit6"
88 "completelimit7"
89 }
90
91# Discarding again
92gdb_test " " ".*" "discard #[incr discard]"
93
94gdb_test_sequence "complete completelimit1 c" \
95 "list all completions of 'complete completelimit1 c'" {
96 "completelimit1 cl11"
97 "completelimit1 cl12"
98 "completelimit1 cl13"
99 }
100
101# Discarding again
102gdb_test " " ".*" "discard #[incr discard]"
103
104# If using readline, we can TAB-complete. This used to trigger a bug
105# because the cached result from the completer was being reused for
106# a different python command.
107if {[readline_is_used]} {
108 set testname "tab-complete 'completelimit1 c'"
109 send_gdb "completelimit1 c\t"
110 gdb_test_multiple "" $testname {
111 -re "^completelimit1 c\\\x07l1$" {
112 pass $testname
113
114 # Discard the command line
115 gdb_test " " ".*" "discard #[incr discard]"
116 }
117 }
118
119 gdb_test_sequence "complete completelimit2 c" \
120 "list all completions of 'complete completelimit2 c'" {
121 "completelimit2 cl21"
122 "completelimit2 cl210"
123 "completelimit2 cl22"
124 "completelimit2 cl23"
125 "completelimit2 cl24"
126 "completelimit2 cl25"
127 "completelimit2 cl26"
128 "completelimit2 cl27"
129 "completelimit2 cl28"
130 "completelimit2 cl29"
131 }
132}
This page took 0.479993 seconds and 4 git commands to generate.