1 # Copyright (C) 1998 Free Software Foundation, Inc.
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 2 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
22 # This file is part of the gdb testsuite.
25 # tests for command completion
27 # Here are some useful test cases for completion.
28 # They should be tested with both M-? and TAB.
30 # "show output-" "radix"
31 # "show output" "-radix"
32 # "p" ambiguous (commands starting with p--path, print, printf, etc.)
33 # "p " ambiguous (all symbols)
34 # "info t foo" no completions
35 # "info t " no completions
36 # "info t" ambiguous ("info target", "info terminal", etc.)
37 # "info ajksdlfk" no completions
38 # "info ajksdlfk " no completions
40 # "info " ambiguous (all info commands)
41 # "p \"a" no completions (string constant)
42 # "p 'a" ambiguous (all symbols starting with a)
43 # "p b-a" ambiguous (all symbols starting with a)
44 # "p b-" ambiguous (all symbols)
45 # "file Make" "file" (word break hard to screw up here)
46 # "file ../gdb.stabs/we" "ird" (needs to not break word at slash)
55 #skip all these tests for now (FIXME)
62 # test running programs
68 set srcfile ${testfile}.c
69 set binfile ${objdir}/${subdir}/${testfile}
70 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
71 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
76 gdb_reinitialize_dir $srcdir/$subdir
79 if ![runto_main] then {
80 perror "tests suppressed"
83 set oldtimeout1 $timeout
84 set timeout [expr $timeout + 500]
93 -re "Undefined command: \"hfgfh\"\\. Try \"help\"\\..*$gdb_prompt $"\
94 { pass "complete 'hfgfh'"}
95 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'"}
96 timeout {fail "(timeout) complete 'hfgfh'"}
99 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'" }
100 timeout { fail "(timeout) complete 'hfgfh'" }
105 send_gdb "show output\t"
108 -re "^show output-radix $"\
111 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
112 { pass "complete 'show output'"}
113 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
114 timeout {fail "(timeout) complete 'show output'"}
120 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
121 { fail "complete 'show output'"}
122 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
123 timeout { fail "(timeout) complete 'show output'"}
128 -re ".*$gdb_prompt $" { fail "complete 'show output'" }
129 timeout { fail "(timeout) complete 'show output'" }
133 send_gdb "show output-\t"
136 -re "^show output-radix $"\
139 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
140 { pass "complete 'show output-'"}
141 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
142 timeout {fail "(timeout) complete 'show output-'"}
145 -re "^show output-$"\
148 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
149 { fail "complete 'show output-'"}
150 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
151 timeout { fail "(timeout) complete 'show output-'"}
156 -re ".*$gdb_prompt $" { fail "complete 'show output-'" }
157 timeout { fail "(timeout) complete 'show output-'" }
166 -re "The history is empty\\..*$gdb_prompt $"\
167 { pass "complete 'p'"}
168 -re ".*$gdb_prompt $" { fail "complete 'p'"}
169 timeout {fail "(timeout) complete 'p'"}
172 -re ".*$gdb_prompt $" { fail "complete 'p'" }
173 timeout { fail "(timeout) complete 'p'" }
182 -re "The history is empty\\..*$gdb_prompt $"\
183 { pass "complete 'p '"}
184 -re ".*$gdb_prompt $" { fail "complete 'p '"}
185 timeout {fail "(timeout) complete 'p '"}
188 -re ".*$gdb_prompt $" { fail "complete 'p '" }
189 timeout { fail "(timeout) complete 'p '" }
193 send_gdb "info t foo\t"
196 -re "^info t foo\\\x07$"\
199 -re "Ambiguous info command \"t foo\": target, terminal, threads, tp, tracepoints, types\\..*$gdb_prompt $"\
200 { pass "complete 'info t foo'"}
201 -re ".*$gdb_prompt $" { fail "complete 'info t foo'"}
202 timeout {fail "(timeout) complete 'info t foo'"}
205 -re ".*$gdb_prompt $" { fail "complete 'info t foo'" }
206 timeout { fail "(timeout) complete 'info t foo'" }
212 -re "^info t\\\x07$"\
215 -re "Ambiguous info command \"t\": target, terminal, threads, tp, tracepoints, types\\..
217 { pass "complete 'info t'"}
218 -re ".*$gdb_prompt $" { fail "complete 'info t'"}
219 timeout {fail "(timeout) complete 'info t'"}
222 -re ".*$gdb_prompt $" { fail "complete 'info t'" }
223 timeout { fail "(timeout) complete 'info t'" }
230 -re "^info t \\\x07$"\
233 -re "Ambiguous info command \"t \": target, terminal, threads, tp, tracepoints, types\\..
235 { pass "complete 'info t '"}
236 -re ".*$gdb_prompt $" { fail "complete 'info t '"}
237 timeout {fail "(timeout) complete 'info t '"}
240 -re ".*$gdb_prompt $" { fail "complete 'info t '" }
241 timeout { fail "(timeout) complete 'info t '" }
245 send_gdb "info asdfgh\t"
248 -re "^info asdfgh\\\x07$"\
251 -re "Undefined info command: \"asdfgh\". Try \"help info\"\\..
253 { pass "complete 'info asdfgh'"}
254 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'"}
255 timeout {fail "(timeout) complete 'info asdfgh'"}
258 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'" }
259 timeout { fail "(timeout) complete 'info asdfgh'" }
263 send_gdb "info asdfgh \t"
266 -re "^info asdfgh \\\x07$"\
269 -re "Undefined info command: \"asdfgh \". Try \"help info\"\\..
271 { pass "complete 'info asdfgh '"}
272 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '"}
273 timeout {fail "(timeout) complete 'info asdfgh '"}
276 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '" }
277 timeout { fail "(timeout) complete 'info asdfgh '" }
286 -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\ninfo address.*info watchpoints.*\r\n\r\nType \"help info\" followed by info subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
287 { pass "complete 'info'"}
288 -re ".*$gdb_prompt $" { fail "complete 'info'"}
289 timeout {fail "(timeout) complete 'info'"}
292 -re ".*$gdb_prompt $" { fail "complete 'info'" }
293 timeout { fail "(timeout) complete 'info'" }
302 -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\ninfo address.*Type \"help info\" followed by info subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
303 { pass "complete 'info '"}
304 -re ".*$gdb_prompt $" { fail "complete 'info '"}
305 timeout {fail "(timeout) complete 'info '"}
308 -re ".*$gdb_prompt $" { fail "complete 'info '" }
309 timeout { fail "(timeout) complete 'info '" }
319 -re "address.*types.*$gdb_prompt info $"\
322 -re "\"info\".*unambiguous\\..*$gdb_prompt $"\
323 { pass "complete (2) 'info '"}
324 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
325 timeout {fail "(timeout) complete (2) 'info '"}
328 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
329 timeout {fail "(timeout) complete (2) 'info '"}
332 -re ".*$gdb_prompt $" { fail "complete (2) 'info '" }
333 timeout { fail "(timeout) complete (2) 'info '" }
343 -re "Unterminated string in expression\\..*$gdb_prompt $"\
344 { pass "complete 'p a'"}
345 -re ".*$gdb_prompt $" { fail "complete 'p a'"}
346 timeout {fail "(timeout) complete 'p a'"}
349 -re ".*$gdb_prompt $" { fail "complete 'p \"a'" }
350 timeout { fail "(timeout) complete 'p \"a'" }
359 -re "Invalid character constant\\..*$gdb_prompt $"\
360 { pass "complete 'p \'a'"}
361 -re ".*$gdb_prompt $" { fail "complete 'p \'a'"}
362 timeout {fail "(timeout) complete 'p \'a'"}
365 -re ".*$gdb_prompt $" { fail "complete 'p \'a'" }
366 timeout { fail "(timeout) complete 'p \'a'" }
375 -re "a64l.*atol.*$gdb_prompt p .a$"\
378 -re "Invalid character constant\\..*$gdb_prompt $"\
379 { pass "complete (2) 'p \'a'"}
380 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'"}
381 timeout {fail "(timeout) complete (2) 'p \'a'"}
384 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'"}
385 timeout {fail "(timeout) complete (2) 'p \'a'"}
388 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
389 timeout { fail "(timeout) complete (2) 'p \'a'" }
399 -re "No symbol \"b\" in current context\\..*$gdb_prompt $"\
400 { pass "complete 'p b-a'"}
401 -re ".*$gdb_prompt $" { fail "complete 'p b-a'"}
402 timeout {fail "(timeout) complete 'p b-a'"}
405 -re ".*$gdb_prompt $" { fail "complete 'p b-a'" }
406 timeout { fail "(timeout) complete 'p b-a'" }
415 -re "a64l.*atol.*$gdb_prompt p b-a$"\
418 -re "No symbol \"b\" in current context\\..*$gdb_prompt $"\
419 { pass "complete (2) 'p b-a'"}
420 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'"}
421 timeout {fail "(timeout) complete (2) 'p b-a'"}
424 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'"}
425 timeout {fail "(timeout) complete (2) 'p b-a'"}
428 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
429 timeout { fail "(timeout) complete (2) 'p b-a'" }
439 -re "There are $decimal possibilities\\. Do you really\r\nwish to see them all. \\(y or n\\)$"\
442 -re "\\(gdb\\) p b-$"\
445 -re "No symbol \"b\" in current context\\..*$gdb_prompt $"\
446 { pass "complete (2) 'p b-'"}
447 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'"}
448 timeout {fail "(timeout) complete (2) 'p b-'"}
451 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'"}
452 timeout {fail "(timeout) complete (2) 'p b-'"}
455 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'"}
456 timeout {fail "(timeout) complete (2) 'p b-'"}
459 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'" }
460 timeout { fail "(timeout) complete (2) 'p b-'" }
463 send_gdb "file ${objdir}/Make\t"
466 -re "file ${objdir}/Makefile.*$"\
469 -re "\r\nA program is being debugged already\\. Kill it\\? \\(y or n\\) $"\
472 -re "\r\nProgram not killed\\.\r\n$gdb_prompt $"\
473 { pass "complete 'file Make'"}
474 -re ".*$gdb_prompt $" { fail "complete 'file Make'"}
475 timeout {fail "(timeout) complete 'file Make'"}
478 -re ".*$gdb_prompt $" { fail "complete 'file Make'"}
479 timeout {fail "(timeout) complete 'file Make'"}
482 -re ".*$gdb_prompt $" { fail "complete 'file Make'" }
483 timeout { fail "(timeout) complete 'file Make'" }
487 send_gdb "file ${srcdir}/gdb.base/a1\t"
490 -re "^file ${srcdir}/gdb.base/.*'a1.*-selftest\\.exp' $"\
493 -re "\r\nA program is being debugged already\\. Kill it\\? \\(y or n\\) $"
497 -re "\r\nProgram not killed\\.\r\n$gdb_prompt $"\
498 { pass "complete 'file gdb.base/a1'"}
499 -re ".*$gdb_prompt $" { fail "complete 'file gdb.base/a1'"}
500 timeout {fail "(timeout) complete 'file gdb.base/a1'"}
503 -re ".*$gdb_prompt $" { fail "complete 'file gdb.base/a1'"}
504 timeout {fail "(timeout) complete 'file gdb.base/a1'"}
507 -re ".*$gdb_prompt $" { fail "complete 'file gdb.base/a1'" }
508 timeout { fail "(timeout) complete 'file gdb.base/a1'" }
512 send_gdb "info func mark\t"
515 -re "^info func mark.*er$"\
519 -re "marker1 marker2 marker3 marker4.*$gdb_prompt info func marker$"\
522 -re "All functions matching regular expression \"marker\":\r\n\r\nFile.*break.c:\r\nint marker1\\(\\);\r\nint marker2\\(int\\).*marker3\\(char.*char.*\\);\r\n$gdb_prompt $"\
523 { pass "complete 'info func mar'"}
524 -re ".*$gdb_prompt $" { fail "complete 'info func mar'"}
525 timeout {fail "(timeout) complete 'info func mar'"}
528 -re ".*$gdb_prompt $" { fail "complete 'info func mar'"}
529 timeout {fail "(timeout) complete 'info func mar'"}
532 -re ".*$gdb_prompt $" { fail "complete 'info func mar'" }
533 timeout { fail "(timeout) complete 'info func mar'" }
537 send_gdb "set follow-fork-mode \t\t"
540 -re "ask.*child.*parent.*$gdb_prompt set follow-fork-mode $"\
543 -re "Ambiguous item \"\"\\..*$gdb_prompt $"\
544 { pass "complete 'set follow-fork-mode'"}
545 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'"}
546 timeout {fail "(timeout) complete 'set follow-fork-mode'"}
549 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'" }
550 timeout { fail "(timeout) complete 'set follow-fork-mode'" }
553 set timeout $oldtimeout1