Commit | Line | Data |
---|---|---|
26648588 JV |
1 | # Copyright 2018-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 | # Verify GDB/MI -complete in various scenarios. This test only tests | |
17 | # -complete command, not the correctness of completions. | |
18 | ||
19 | load_lib mi-support.exp | |
20 | set MIFLAGS "-i=mi" | |
21 | ||
22 | gdb_exit | |
23 | if [mi_gdb_start] { | |
24 | continue | |
25 | } | |
26 | ||
27 | standard_testfile .cc | |
28 | ||
29 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { | |
30 | untested "failed to compile" | |
31 | return -1 | |
32 | } | |
33 | ||
34 | mi_run_to_main | |
35 | ||
36 | mi_gdb_test "1-complete br" \ | |
37 | "1\\^done,completion=\"break\",matches=\\\[.*\"break\",.*\"break-range\".*\\\],max_completions_reached=\"0\"" \ | |
38 | "-complete br" | |
39 | ||
40 | # Check empty completion list. | |
41 | mi_gdb_test "5-complete bogus" \ | |
42 | "5\\^done,matches=\\\[\\\],max_completions_reached=\"0\"" \ | |
43 | "-complete bogus" | |
44 | ||
45 | # Check completions for commands with space. | |
46 | mi_gdb_test "4-complete \"b mai\"" \ | |
47 | "4\\^done,completion=\"b main\",matches=\\\[.*\"b main\".*\\\],max_completions_reached=\"0\"" \ | |
48 | "-complete \"b mai\"" | |
49 | ||
50 | # Check wildmatching. | |
51 | mi_gdb_test "5-complete \"b push_ba\"" \ | |
52 | "5\\^done,completion=\"b push_back\\(\",matches=\\\[.*\"b A::push_back\\(void\\*\\)\".*\\\],max_completions_reached=\"0\"" \ | |
53 | "-complete \"b push_ba\", wildmatching" | |
54 | ||
55 | mi_gdb_test "-info-gdb-mi-command complete" \ | |
56 | "\\^done,command=\{exists=\"true\"\}" \ | |
57 | "-info-gdb-mi-command complete" | |
58 | ||
59 | # Limit max completions and check that max_completions_reached=\"0\" is set | |
60 | # to 1. | |
5ba29434 TV |
61 | mi_gdb_test "set max-completions 1" ".*=cmd-param-changed.*\\^done" \ |
62 | "set max-completions 1" | |
26648588 JV |
63 | |
64 | mi_gdb_test "2-complete br" \ | |
65 | ".*2\\^done,completion=\"br\[A-Za-z0-9-\]+\",matches=\\\[\"br\[A-Za-z0-9-\]+\"\\\],max_completions_reached=\"1\"" \ | |
66 | "-complete br, max-completions 1" | |
67 | ||
68 | # Disable completions and check an error is returned | |
5ba29434 TV |
69 | mi_gdb_test "set max-completions 0" ".*=cmd-param-changed.*\\^done" \ |
70 | "set max-completions 0" | |
26648588 JV |
71 | |
72 | mi_gdb_test "3-complete br" \ | |
73 | ".*3\\^error,msg=\".*" \ | |
74 | "-complete br, max-completions 0" |