1 # Copyright 1998, 1999 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 \"break" unambiguous (completes to filename "break.c")
42 # "p \"break." unambiguous (should complete to "break.c" but does not,
43 # due to readline limitations)
44 # "p 'a" ambiguous (all symbols starting with a)
45 # "p b-a" ambiguous (all symbols starting with a)
46 # "p b-" ambiguous (all symbols)
47 # "file Make" "file" (word break hard to screw up here)
48 # "file ../gdb.stabs/we" "ird" (needs to not break word at slash)
60 # test running programs
66 set srcfile ${testfile}.c
67 set binfile ${objdir}/${subdir}/${testfile}
68 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
69 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
72 if [get_compiler_info ${binfile}] {
78 # Don't let a .inputrc file or an existing setting of INPUTRC mess up
79 # the test results. Even if /dev/null doesn't exist on the particular
80 # platform, the readline library will use the default setting just by
81 # failing to open the file. OTOH, opening /dev/null successfully will
82 # also result in the default settings being used since nothing will be
83 # read from this file.
85 if [info exists env(INPUTRC)] {
86 set old_inputrc $env(INPUTRC)
88 set env(INPUTRC) "/dev/null"
91 gdb_reinitialize_dir $srcdir/$subdir
94 if ![runto_main] then {
95 perror "tests suppressed"
98 set oldtimeout1 $timeout
108 -re "Undefined command: \"hfgfh\"\\. Try \"help\"\\..*$gdb_prompt $"\
109 { pass "complete 'hfgfh'"}
110 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'"}
111 timeout {fail "(timeout) complete 'hfgfh'"}
114 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'" }
115 timeout { fail "(timeout) complete 'hfgfh'" }
120 send_gdb "show output\t"
123 -re "^show output-radix $"\
126 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
127 { pass "complete 'show output'"}
128 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
129 timeout {fail "(timeout) complete 'show output'"}
135 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
136 { fail "complete 'show output'"}
137 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
138 timeout { fail "(timeout) complete 'show output'"}
143 -re ".*$gdb_prompt $" { fail "complete 'show output'" }
144 timeout { fail "(timeout) complete 'show output'" }
148 send_gdb "show output-\t"
151 -re "^show output-radix $"\
154 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
155 { pass "complete 'show output-'"}
156 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
157 timeout {fail "(timeout) complete 'show output-'"}
160 -re "^show output-$"\
163 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
164 { fail "complete 'show output-'"}
165 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
166 timeout { fail "(timeout) complete 'show output-'"}
171 -re ".*$gdb_prompt $" { fail "complete 'show output-'" }
172 timeout { fail "(timeout) complete 'show output-'" }
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' 2"}
188 -re ".*$gdb_prompt $" { fail "complete 'p'" }
189 timeout { fail "(timeout) complete 'p' 1" }
199 -re "The history is empty\\..*$gdb_prompt $"\
200 { pass "complete 'p '"}
201 -re ".*$gdb_prompt $" { fail "complete 'p '"}
202 timeout {fail "(timeout) complete 'p ' 1"}
205 -re ".*$gdb_prompt $" { fail "complete 'p '" }
206 timeout { fail "(timeout) complete 'p ' 2" }
210 send_gdb "info t foo\t"
213 -re "^info t foo\\\x07$"\
216 -re "Ambiguous info command \"t foo\": target, terminal, threads, tp, tracepoints, types\\..*$gdb_prompt $"\
217 { pass "complete 'info t foo'"}
218 -re ".*$gdb_prompt $" { fail "complete 'info t foo'"}
219 timeout {fail "(timeout) complete 'info t foo'"}
222 -re ".*$gdb_prompt $" { fail "complete 'info t foo'" }
223 timeout { fail "(timeout) complete 'info t foo'" }
229 -re "^info t\\\x07$"\
232 -re "Ambiguous info command \"t\": target, terminal, threads, tp, tracepoints, types\\..
234 { pass "complete 'info t'"}
235 -re ".*$gdb_prompt $" { fail "complete 'info t'"}
236 timeout {fail "(timeout) complete 'info t'"}
239 -re ".*$gdb_prompt $" { fail "complete 'info t'" }
240 timeout { fail "(timeout) complete 'info t'" }
247 -re "^info t \\\x07$"\
250 -re "Ambiguous info command \"t \": target, terminal, threads, tp, tracepoints, types\\..
252 { pass "complete 'info t '"}
253 -re ".*$gdb_prompt $" { fail "complete 'info t '"}
254 timeout {fail "(timeout) complete 'info t '"}
257 -re ".*$gdb_prompt $" { fail "complete 'info t '" }
258 timeout { fail "(timeout) complete 'info t '" }
262 send_gdb "info asdfgh\t"
265 -re "^info asdfgh\\\x07$"\
268 -re "Undefined info command: \"asdfgh\". Try \"help info\"\\..
270 { pass "complete 'info asdfgh'"}
271 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'"}
272 timeout {fail "(timeout) complete 'info asdfgh'"}
275 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'" }
276 timeout { fail "(timeout) complete 'info asdfgh'" }
280 send_gdb "info asdfgh \t"
283 -re "^info asdfgh \\\x07$"\
286 -re "Undefined info command: \"asdfgh \". Try \"help info\"\\..
288 { pass "complete 'info asdfgh '"}
289 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '"}
290 timeout {fail "(timeout) complete 'info asdfgh '"}
293 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '" }
294 timeout { fail "(timeout) complete 'info asdfgh '" }
303 -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*info 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 $"\
304 { pass "complete 'info'"}
305 -re ".*$gdb_prompt $" { fail "complete 'info'"}
306 timeout {fail "(timeout) complete 'info'"}
309 -re ".*$gdb_prompt $" { fail "complete 'info'" }
310 timeout { fail "(timeout) complete 'info'" }
319 -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*info address.*Type \"help info\" followed by info subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
320 { pass "complete 'info '"}
321 -re ".*$gdb_prompt $" { fail "complete 'info '"}
322 timeout {fail "(timeout) complete 'info '"}
325 -re ".*$gdb_prompt $" { fail "complete 'info '" }
326 timeout { fail "(timeout) complete 'info '" }
336 -re "address.*types.*$gdb_prompt info $"\
339 -re "\"info\".*unambiguous\\..*$gdb_prompt $"\
340 { pass "complete (2) 'info '"}
341 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
342 timeout {fail "(timeout) complete (2) 'info '"}
345 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
346 timeout {fail "(timeout) complete (2) 'info '"}
349 -re ".*$gdb_prompt $" { fail "complete (2) 'info '" }
350 timeout { fail "(timeout) complete (2) 'info '" }
354 send_gdb "p \"break\t"
357 -re "^p \"break\\\x07$"\
360 -re ".*$gdb_prompt $" { fail "complete 'p \"break'"}
361 timeout {fail "(timeout) complete 'p \"break'"}
364 -re "^p \"break\\.c\"$"\
367 -re ".*$gdb_prompt $" { pass "complete 'p \"break'"}
368 timeout {fail "(timeout) complete 'p \"break'"}
374 -re ".*$gdb_prompt $" { fail "complete 'p \"break'"}
375 timeout {fail "(timeout) complete 'p \"break'"}
378 -re ".*$gdb_prompt $" { fail "complete 'p \"break'" }
379 timeout { fail "(timeout) complete 'p \"break'" }
383 send_gdb "p \"break.\t"
386 -re "^p \"break\\.\\\x07$"\
389 -re ".*$gdb_prompt $" { fail "complete 'p \"break.'"}
390 timeout {fail "(timeout) complete 'p \"break.'"}
393 -re "^p \"break\\.c\"$"\
396 -re ".*$gdb_prompt $" { pass "complete 'p \"break.'"}
397 timeout {fail "(timeout) complete 'p \"break.'"}
400 -re "^p \"break\\..*$"
403 -re ".*$gdb_prompt $" { fail "complete 'p \"break.'"}
404 timeout {fail "(timeout) complete 'p \"break.'"}
407 -re ".*$gdb_prompt $" { fail "complete 'p \"break.'" }
408 timeout { fail "(timeout) complete 'p \"break.'" }
417 -re "Invalid character constant\\..*$gdb_prompt $"\
418 { pass "complete 'p \'a'"}
419 -re ".*$gdb_prompt $" { fail "complete 'p \'a'"}
420 timeout {fail "(timeout) complete 'p \'a'"}
423 -re ".*$gdb_prompt $" { fail "complete 'p \'a'" }
424 timeout { fail "(timeout) complete 'p \'a'" }
433 -re ".*argv.*$gdb_prompt p .a$" {
436 -re "Invalid character constant\\..*$gdb_prompt $" {
437 pass "complete (2) 'p \'a'"
439 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
440 timeout { fail "(timeout) complete (2) 'p \'a'" }
443 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
446 -re "\\(gdb\\) p 'a$" {
449 -re "Invalid character constant\\..*$gdb_prompt $" {
450 pass "complete (2) 'p \'a'"
452 -re ".*$gdb_prompt $" {
453 fail "complete (2) 'p \'a'"
455 timeout { fail "(timeout) complete (2) 'p \'a'" }
458 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
459 timeout { fail "(timeout) complete (2) 'p \'a'" }
462 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
463 timeout { fail "(timeout) complete (2) 'p \'a'" }
466 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
467 timeout { fail "(timeout) complete (2) 'p \'a'" }
477 -re "No symbol \"b\" in current context\\..*$gdb_prompt $"\
478 { pass "complete 'p b-a'"}
479 -re ".*$gdb_prompt $" { fail "complete 'p b-a'"}
480 timeout {fail "(timeout) complete 'p b-a'"}
483 -re ".*$gdb_prompt $" { fail "complete 'p b-a'" }
484 timeout { fail "(timeout) complete 'p b-a'" }
490 -re "^p b-a\\\x07$" {
493 -re ".*argv.*$gdb_prompt p b-a$" {
496 -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
497 pass "complete (2) 'p b-a'"
499 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
500 timeout { fail "(timeout) complete (2) 'p b-a'" }
503 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
506 -re "\\(gdb\\) p b-a$" {
509 -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
510 pass "complete (2) 'p b-a'"
512 -re ".*$gdb_prompt $" {
513 fail "complete (2) 'p b-a'"
515 timeout { fail "(timeout) complete (2) 'p b-a'" }
518 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
519 timeout { fail "(timeout) complete (2) 'p b-a'" }
522 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
523 timeout { fail "(timeout) complete (2) 'p b-a'" }
526 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
527 timeout { fail "(timeout) complete (2) 'p b-a'" }
536 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
539 -re "\\(gdb\\) p b-$" {
542 -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
543 pass "complete (2) 'p b-'"
545 -re ".*$gdb_prompt $" {
546 fail "complete (2) 'p b-'"
548 timeout { fail "(timeout) complete (2) 'p b-'" }
551 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'" }
552 timeout { fail "(timeout) complete (2) 'p b-'" }
555 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'" }
556 timeout { fail "(timeout) complete (2) 'p b-'" }
559 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'" }
560 timeout { fail "(timeout) complete (2) 'p b-'" }
563 send_gdb "file ${objdir}/Make\t"
566 -re "file ${objdir}/Makefile.*$"\
569 -re "\r\nA program is being debugged already\\. Kill it\\? \\(y or n\\) $"\
572 -re "\r\nProgram not killed\\.\r\n$gdb_prompt $"\
573 { pass "complete 'file Make'"}
574 -re ".*$gdb_prompt $" { fail "complete 'file Make'"}
575 timeout {fail "(timeout) complete 'file Make'"}
578 -re ".*$gdb_prompt $" { fail "complete 'file Make'"}
579 timeout {fail "(timeout) complete 'file Make'"}
582 -re ".*$gdb_prompt $" { fail "complete 'file Make'" }
583 timeout { fail "(timeout) complete 'file Make'" }
587 send_gdb "file ${srcdir}/gdb.base/compl\t"
590 -re "^file ${srcdir}/gdb.base/completion\\.exp $"\
593 -re "\r\nA program is being debugged already\\. Kill it\\? \\(y or n\\) $"
597 -re "\r\nProgram not killed\\.\r\n$gdb_prompt $"\
598 { pass "complete 'file gdb.base/compl'"}
599 -re ".*$gdb_prompt $" { fail "complete 'file gdb.base/compl'"}
600 timeout {fail "(timeout) complete 'file gdb.base/compl'"}
603 -re ".*$gdb_prompt $" { fail "complete 'file gdb.base/compl'"}
604 timeout {fail "(timeout) complete 'file gdb.base/compl'"}
607 -re ".*$gdb_prompt $" { fail "complete 'file gdb.base/compl'" }
608 timeout { fail "(timeout) complete 'file gdb.base/compl'" }
611 send_gdb "info func mark\t"
614 -re "^info func mark.*er$"\
619 -re "marker1.*$gdb_prompt info func marker$"\
622 -re "All functions matching regular expression \"marker\":.*File.*break.c:\r\nint marker1\\(\\);\r\nint marker2\\(int\\).*marker3\\(char.*char.*\\).*marker4\\(long int\\);.*$gdb_prompt $"\
623 { pass "complete 'info func mar'"}
624 -re ".*$gdb_prompt $" { fail "complete 'info func mar'"}
625 timeout {fail "(timeout) complete 'info func mar'"}
628 -re ".*$gdb_prompt $" { fail "complete 'info func mar'"}
629 timeout {fail "(timeout) complete 'info func mar'"}
632 -re ".*$gdb_prompt $" { fail "complete 'info func mar'" }
633 timeout { fail "(timeout) complete 'info func mar'" }
637 send_gdb "set follow-fork-mode \t\t"
640 -re "ask.*child.*parent.*$gdb_prompt set follow-fork-mode $"\
643 -re "Requires an argument.*ask.*child.*parent.*$gdb_prompt $"\
644 { pass "complete 'set follow-fork-mode'"}
645 -re "Ambiguous item \"\"\\..*$gdb_prompt $"\
646 { pass "complete 'set follow-fork-mode'"}
647 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'"}
648 timeout {fail "(timeout) complete 'set follow-fork-mode'"}
651 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'" }
652 timeout { fail "(timeout) complete 'set follow-fork-mode'" }
655 # Restore globals modified in this test...
656 if [info exists old_inputrc] {
657 set env(INPUTRC) $old_inputrc
661 set timeout $oldtimeout1