]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.python/py-completion.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / py-completion.exp
1 # Copyright (C) 2014-2019 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 set testfile "py-completion"
17
18 load_lib gdb-python.exp
19
20 gdb_exit
21 gdb_start
22
23 # Skip all tests if Python scripting is not enabled.
24 if { [skip_python_tests] } { continue }
25
26 gdb_test_no_output "source ${srcdir}/${subdir}/${testfile}.py" \
27 "load python file"
28
29 # Create a temporary directory
30 set testdir "[standard_output_file "py-completion-testdir"]/"
31 set testdir_regex [string_to_regexp $testdir]
32 set testdir_complete [standard_output_file "py-completion-test"]
33 file mkdir $testdir
34
35 # This one should always pass.
36 send_gdb "completefileinit ${testdir_complete}\t"
37 gdb_test_multiple "" "completefileinit completion" {
38 -re "^completefileinit ${testdir_regex}$" {
39 pass "completefileinit completion"
40 }
41 }
42
43 # Just discarding whatever we typed.
44 set discard 0
45 gdb_test " " ".*" "discard #[incr discard]"
46
47 # This is the problematic one.
48 send_gdb "completefilemethod ${testdir_complete}\t"
49 gdb_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
59 gdb_test " " ".*" "discard #[incr discard]"
60
61 # Another problematic
62 set completion_regex "[string_to_regexp [standard_output_file "py-completion-t"]]"
63 send_gdb "completefilecommandcond [standard_output_file "py-completion-t\t"]"
64 gdb_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 }
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.
75 gdb_exit
76 gdb_start
77 gdb_test_no_output "source ${srcdir}/${subdir}/${testfile}.py" \
78 "load python file again"
79
80 gdb_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
92 gdb_test " " ".*" "discard #[incr discard]"
93
94 gdb_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
102 gdb_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.
107 if {[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 }