Switch the license of all .exp files to GPLv3.
[binutils-gdb.git] / gdb / testsuite / gdb.base / completion.exp
1 # Copyright 1998, 1999, 2002, 2003, 2004, 2007 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 # Please email any bugs, comments, and/or additions to this file to:
17 # bug-gdb@prep.ai.mit.edu
18
19 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
20
21 # This file is part of the gdb testsuite.
22
23 #
24 # tests for command completion
25 #
26 # Here are some useful test cases for completion.
27 # They should be tested with both M-? and TAB.
28 #
29 # "show output-" "radix"
30 # "show output" "-radix"
31 # "p" ambiguous (commands starting with p--path, print, printf, etc.)
32 # "p " ambiguous (all symbols)
33 # "info t foo" no completions
34 # "info t " no completions
35 # "info t" ambiguous ("info target", "info terminal", etc.)
36 # "info ajksdlfk" no completions
37 # "info ajksdlfk " no completions
38 # "info" " "
39 # "info " ambiguous (all info commands)
40 # "p \"break1" unambiguous (completes to filename "break1.c")
41 # "p \"break1." unambiguous (should complete to "break1.c" but does not,
42 # due to readline limitations)
43 # "p 'a" ambiguous (all symbols starting with a)
44 # "p b-a" ambiguous (all symbols starting with a)
45 # "p b-" ambiguous (all symbols)
46 # "file Make" "file" (word break hard to screw up here)
47 # "file ../gdb.stabs/we" "ird" (needs to not break word at slash)
48 #
49
50
51 if $tracelevel then {
52 strace $tracelevel
53 }
54
55
56 global usestubs
57
58 #
59 # test running programs
60 #
61 set prms_id 0
62 set bug_id 0
63
64 set testfile "break"
65 set srcfile ${testfile}.c
66 set srcfile1 ${testfile}1.c
67 set binfile ${objdir}/${subdir}/${testfile}
68
69 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
70 untested completion.exp
71 return -1
72 }
73
74 if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
75 untested completion.exp
76 return -1
77 }
78
79 if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
80 untested completion.exp
81 return -1
82 }
83
84 if [get_compiler_info ${binfile}] {
85 return -1;
86 }
87
88 gdb_exit
89
90 # Don't let a .inputrc file or an existing setting of INPUTRC mess up
91 # the test results. Even if /dev/null doesn't exist on the particular
92 # platform, the readline library will use the default setting just by
93 # failing to open the file. OTOH, opening /dev/null successfully will
94 # also result in the default settings being used since nothing will be
95 # read from this file.
96 global env
97 if [info exists env(INPUTRC)] {
98 set old_inputrc $env(INPUTRC)
99 }
100 set env(INPUTRC) "/dev/null"
101
102 gdb_start
103 gdb_reinitialize_dir $srcdir/$subdir
104 gdb_load ${binfile}
105
106 if ![runto_main] then {
107 perror "tests suppressed"
108 }
109
110 set oldtimeout1 $timeout
111 set timeout 30
112
113
114 send_gdb "hfgfh\t"
115 sleep 1
116 gdb_expect {
117 -re "^hfgfh\\\x07$"\
118 { send_gdb "\n"
119 gdb_expect {
120 -re "Undefined command: \"hfgfh\"\\. Try \"help\"\\..*$gdb_prompt $"\
121 { pass "complete 'hfgfh'"}
122 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'"}
123 timeout {fail "(timeout) complete 'hfgfh'"}
124 }
125 }
126 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'" }
127 timeout { fail "(timeout) complete 'hfgfh'" }
128 }
129
130 #exp_internal 0
131
132 send_gdb "show output\t"
133 sleep 1
134 gdb_expect {
135 -re "^show output-radix $"\
136 { send_gdb "\n"
137 gdb_expect {
138 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
139 { pass "complete 'show output'"}
140 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
141 timeout {fail "(timeout) complete 'show output'"}
142 }
143 }
144 -re "^show output$"\
145 { send_gdb "\n"
146 gdb_expect {
147 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
148 { fail "complete 'show output'"}
149 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
150 timeout { fail "(timeout) complete 'show output'"}
151 }
152
153 }
154
155 -re ".*$gdb_prompt $" { fail "complete 'show output'" }
156 timeout { fail "(timeout) complete 'show output'" }
157 }
158
159
160 send_gdb "show output-\t"
161 sleep 1
162 gdb_expect {
163 -re "^show output-radix $"\
164 { send_gdb "\n"
165 gdb_expect {
166 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
167 { pass "complete 'show output-'"}
168 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
169 timeout {fail "(timeout) complete 'show output-'"}
170 }
171 }
172 -re "^show output-$"\
173 { send_gdb "\n"
174 gdb_expect {
175 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
176 { fail "complete 'show output-'"}
177 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
178 timeout { fail "(timeout) complete 'show output-'"}
179 }
180
181 }
182
183 -re ".*$gdb_prompt $" { fail "complete 'show output-'" }
184 timeout { fail "(timeout) complete 'show output-'" }
185 }
186
187 send_gdb "p\t"
188 sleep 1
189 gdb_expect {
190 -re "^p\\\x07$"\
191 { send_gdb "\n"
192 sleep 1
193 gdb_expect {
194 -re "The history is empty\\..*$gdb_prompt $"\
195 { pass "complete 'p'"}
196 -re ".*$gdb_prompt $" { fail "complete 'p'"}
197 timeout {fail "(timeout) complete 'p' 2"}
198 }
199 }
200 -re ".*$gdb_prompt $" { fail "complete 'p'" }
201 timeout { fail "(timeout) complete 'p' 1" }
202 }
203
204 send_gdb "p \t"
205 sleep 3
206 gdb_expect {
207 -re "^p \\\x07$"\
208 { send_gdb "\n"
209 sleep 1
210 gdb_expect {
211 -re "The history is empty\\..*$gdb_prompt $"\
212 { pass "complete 'p '"}
213 -re ".*$gdb_prompt $" { fail "complete 'p '"}
214 timeout {fail "(timeout) complete 'p ' 1"}
215 }
216 }
217 -re ".*$gdb_prompt $" { fail "complete 'p '" }
218 timeout { fail "(timeout) complete 'p ' 2" }
219 }
220
221
222 send_gdb "info t foo\t"
223 sleep 1
224 gdb_expect {
225 -re "^info t foo\\\x07$"\
226 { send_gdb "\n"
227 gdb_expect {
228 -re "Ambiguous info command \"t foo\": target, terminal, threads, tp, tracepoints, types\\..*$gdb_prompt $"\
229 { pass "complete 'info t foo'"}
230 -re ".*$gdb_prompt $" { fail "complete 'info t foo'"}
231 timeout {fail "(timeout) complete 'info t foo'"}
232 }
233 }
234 -re ".*$gdb_prompt $" { fail "complete 'info t foo'" }
235 timeout { fail "(timeout) complete 'info t foo'" }
236 }
237
238 send_gdb "info t\t"
239 sleep 1
240 gdb_expect {
241 -re "^info t\\\x07$"\
242 { send_gdb "\n"
243 gdb_expect {
244 -re "Ambiguous info command \"t\": target, terminal, threads, tp, tracepoints, types\\..
245 *$gdb_prompt $"\
246 { pass "complete 'info t'"}
247 -re ".*$gdb_prompt $" { fail "complete 'info t'"}
248 timeout {fail "(timeout) complete 'info t'"}
249 }
250 }
251 -re ".*$gdb_prompt $" { fail "complete 'info t'" }
252 timeout { fail "(timeout) complete 'info t'" }
253 }
254
255
256 send_gdb "info t \t"
257 sleep 1
258 gdb_expect {
259 -re "^info t \\\x07$"\
260 { send_gdb "\n"
261 gdb_expect {
262 -re "Ambiguous info command \"t \": target, terminal, threads, tp, tracepoints, types\\..
263 *$gdb_prompt $"\
264 { pass "complete 'info t '"}
265 -re ".*$gdb_prompt $" { fail "complete 'info t '"}
266 timeout {fail "(timeout) complete 'info t '"}
267 }
268 }
269 -re ".*$gdb_prompt $" { fail "complete 'info t '" }
270 timeout { fail "(timeout) complete 'info t '" }
271 }
272
273
274 send_gdb "info asdfgh\t"
275 sleep 1
276 gdb_expect {
277 -re "^info asdfgh\\\x07$"\
278 { send_gdb "\n"
279 gdb_expect {
280 -re "Undefined info command: \"asdfgh\". Try \"help info\"\\..
281 *$gdb_prompt $"\
282 { pass "complete 'info asdfgh'"}
283 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'"}
284 timeout {fail "(timeout) complete 'info asdfgh'"}
285 }
286 }
287 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'" }
288 timeout { fail "(timeout) complete 'info asdfgh'" }
289 }
290
291
292 send_gdb "info asdfgh \t"
293 sleep 1
294 gdb_expect {
295 -re "^info asdfgh \\\x07$"\
296 { send_gdb "\n"
297 gdb_expect {
298 -re "Undefined info command: \"asdfgh \". Try \"help info\"\\..
299 *$gdb_prompt $"\
300 { pass "complete 'info asdfgh '"}
301 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '"}
302 timeout {fail "(timeout) complete 'info asdfgh '"}
303 }
304 }
305 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '" }
306 timeout { fail "(timeout) complete 'info asdfgh '" }
307 }
308
309 send_gdb "info\t"
310 sleep 1
311 gdb_expect {
312 -re "^info $"\
313 { send_gdb "\n"
314 gdb_expect {
315 -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands.*$gdb_prompt $"\
316 { pass "complete 'info'"}
317 -re ".*$gdb_prompt $" { fail "complete 'info'"}
318 timeout {fail "(timeout) complete 'info'"}
319 }
320 }
321 -re ".*$gdb_prompt $" { fail "complete 'info'" }
322 timeout { fail "(timeout) complete 'info'" }
323 }
324
325 send_gdb "info \t"
326 sleep 1
327 gdb_expect {
328 -re "^info \\\x07$"\
329 { send_gdb "\n"
330 gdb_expect {
331 -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*$gdb_prompt $"\
332 { pass "complete 'info '"}
333 -re ".*$gdb_prompt $" { fail "complete 'info '"}
334 timeout {fail "(timeout) complete 'info '"}
335 }
336 }
337 -re ".*$gdb_prompt $" { fail "complete 'info '" }
338 timeout { fail "(timeout) complete 'info '" }
339 }
340
341
342 send_gdb "info \t"
343 sleep 1
344 gdb_expect {
345 -re "^info \\\x07$"\
346 { send_gdb "\t"
347 gdb_expect {
348 -re "address.*types.*$gdb_prompt info $"\
349 { send_gdb "\n"
350 gdb_expect {
351 -re "\"info\".*unambiguous\\..*$gdb_prompt $"\
352 { pass "complete (2) 'info '"}
353 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
354 timeout {fail "(timeout) complete (2) 'info '"}
355 }
356 }
357 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
358 timeout {fail "(timeout) complete (2) 'info '"}
359 }
360 }
361 -re ".*$gdb_prompt $" { fail "complete (2) 'info '" }
362 timeout { fail "(timeout) complete (2) 'info '" }
363 }
364
365
366 send_gdb "p \"break1\t"
367 sleep 1
368 gdb_expect {
369 -re "^p \"break1\\\x07$"\
370 { send_gdb "\n"
371 gdb_expect {
372 -re ".*$gdb_prompt $" { fail "complete 'p \"break1'"}
373 timeout {fail "(timeout) complete 'p \"break1'"}
374 }
375 }
376 -re "^p \"break1\\.c\"$"\
377 { send_gdb "\n"
378 gdb_expect {
379 -re ".*$gdb_prompt $" { pass "complete 'p \"break1'"}
380 timeout {fail "(timeout) complete 'p \"break1'"}
381 }
382 }
383 -re "^p \"break1.*$"
384 { send_gdb "\n"
385 gdb_expect {
386 -re ".*$gdb_prompt $" { fail "complete 'p \"break1'"}
387 timeout {fail "(timeout) complete 'p \"break1'"}
388 }
389 }
390 -re ".*$gdb_prompt $" { fail "complete 'p \"break1'" }
391 timeout { fail "(timeout) complete 'p \"break1'" }
392 }
393
394 setup_xfail "*-*-*"
395 send_gdb "p \"break1.\t"
396 sleep 1
397 gdb_expect {
398 -re "^p \"break1\\.\\\x07$"\
399 { send_gdb "\n"
400 gdb_expect {
401 -re ".*$gdb_prompt $" { fail "complete 'p \"break1.'"}
402 timeout {fail "(timeout) complete 'p \"break1.'"}
403 }
404 }
405 -re "^p \"break1\\.c\"$"\
406 { send_gdb "\n"
407 gdb_expect {
408 -re ".*$gdb_prompt $" { pass "complete 'p \"break1.'"}
409 timeout {fail "(timeout) complete 'p \"break1.'"}
410 }
411 }
412 -re "^p \"break1\\..*$"
413 { send_gdb "\n"
414 gdb_expect {
415 -re ".*$gdb_prompt $" { fail "complete 'p \"break1.'"}
416 timeout {fail "(timeout) complete 'p \"break1.'"}
417 }
418 }
419 -re ".*$gdb_prompt $" { fail "complete 'p \"break1.'" }
420 timeout { fail "(timeout) complete 'p \"break1.'" }
421 }
422
423 send_gdb "p 'a\t"
424 sleep 1
425 gdb_expect {
426 -re "^p 'a\\\x07$"\
427 { send_gdb "\n"
428 gdb_expect {
429 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $"\
430 { pass "complete 'p \'a'"}
431 -re ".*$gdb_prompt $" { fail "complete 'p \'a'"}
432 timeout {fail "(timeout) complete 'p \'a'"}
433 }
434 }
435 -re ".*$gdb_prompt $" { fail "complete 'p \'a'" }
436 timeout { fail "(timeout) complete 'p \'a'" }
437 }
438
439 send_gdb "p 'a\t"
440 sleep 1
441 gdb_expect {
442 -re "^p 'a\\\x07$" {
443 send_gdb "\t"
444 gdb_expect {
445 -re ".*argv.*$gdb_prompt p .a$" {
446 send_gdb "\n"
447 gdb_expect {
448 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
449 pass "complete (2) 'p \'a'"
450 }
451 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
452 timeout { fail "(timeout) complete (2) 'p \'a'" }
453 }
454 }
455 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
456 send_gdb "n"
457 gdb_expect {
458 -re "\\(gdb\\) p 'a$" {
459 send_gdb "\n"
460 gdb_expect {
461 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
462 pass "complete (2) 'p \'a'"
463 }
464 -re ".*$gdb_prompt $" {
465 fail "complete (2) 'p \'a'"
466 }
467 timeout { fail "(timeout) complete (2) 'p \'a'" }
468 }
469 }
470 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
471 timeout { fail "(timeout) complete (2) 'p \'a'" }
472 }
473 }
474 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
475 timeout { fail "(timeout) complete (2) 'p \'a'" }
476 }
477 }
478 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
479 timeout { fail "(timeout) complete (2) 'p \'a'" }
480 }
481
482
483 # These tests used to try completing the shorter "p b-a".
484 # Unfortunately, on some systems, there are .o files in system
485 # libraries which declare static variables named `b'. Of course,
486 # those variables aren't really in scope, as far as the compiler is
487 # concerned. But GDB deliberately tries to be more liberal: if you
488 # enter an identifier that doesn't have any binding in scope, GDB will
489 # search all the program's compilation units for a static variable of
490 # the given name.
491 #
492 # This behavior can help avoid a lot of pedantry, so it's usually a
493 # good thing. But in this test case, it causes GDB to print the value
494 # of some random variable, instead of giving us the "No symbol..."
495 # error we were expecting.
496 #
497 # For example, on S/390 linux, the file s_atan.c in libm.a declares a
498 # `b', which is a structure containing an int and a float, so GDB says
499 # ``Argument to arithmetic operation not a number or boolean'' instead
500 # of ``No symbol ...''.
501 #
502 # So, I'm hoping that there is no system with a static library variable named
503 # `no_var_by_this_name'.
504 send_gdb "p no_var_named_this-a\t"
505 sleep 1
506 gdb_expect {
507 -re "^p no_var_named_this-a\\\x07$" {
508 send_gdb "\n"
509 gdb_expect {
510 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
511 pass "complete 'p no_var_named_this-a'"
512 }
513 -re ".*$gdb_prompt $" {
514 fail "complete 'p no_var_named_this-a'"
515 }
516 timeout {
517 fail "(timeout) complete 'p no_var_named_this-a'"
518 }
519 }
520 }
521 -re ".*$gdb_prompt $" {
522 fail "complete 'p no_var_named_this-a'"
523 }
524 timeout {
525 fail "(timeout) complete 'p no_var_named_this-a'"
526 }
527 }
528
529 send_gdb "p no_var_named_this-a\t"
530 sleep 1
531 gdb_expect {
532 -re "^p no_var_named_this-a\\\x07$" {
533 send_gdb "\t"
534 gdb_expect {
535 -re ".*argv.*$gdb_prompt p no_var_named_this-a$" {
536 send_gdb "\n"
537 gdb_expect {
538 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
539 pass "complete (2) 'p no_var_named_this-a'"
540 }
541 -re ".*$gdb_prompt $" {
542 fail "complete (2) 'p no_var_named_this-a'"
543 }
544 timeout {
545 fail "(timeout) complete (2) 'p no_var_named_this-a'"
546 }
547 }
548 }
549 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
550 send_gdb "n"
551 gdb_expect {
552 -re "\\(gdb\\) p no_var_named_this-a$" {
553 send_gdb "\n"
554 gdb_expect {
555 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
556 pass "complete (2) 'p no_var_named_this-a'"
557 }
558 -re ".*$gdb_prompt $" {
559 fail "complete (2) 'p no_var_named_this-a'"
560 }
561 timeout {
562 fail "(timeout) complete (2) 'p no_var_named_this-a'"
563 }
564 }
565 }
566 -re ".*$gdb_prompt $" {
567 fail "complete (2) 'p no_var_named_this-a'"
568 }
569 timeout {
570 fail "(timeout) complete (2) 'p no_var_named_this-a'"
571 }
572 }
573 }
574 -re ".*$gdb_prompt $" {
575 fail "complete (2) 'p no_var_named_this-a'"
576 }
577 timeout { fail "(timeout) complete (2) 'p no_var_named_this-a'" }
578 }
579 }
580 -re ".*$gdb_prompt $" { fail "complete (2) 'p no_var_named_this-a'" }
581 timeout { fail "(timeout) complete (2) 'p no_var_named_this-a'" }
582 }
583
584 send_gdb "p no_var_named_this-\t"
585 sleep 1
586 gdb_expect {
587 -re "^p no_var_named_this-\\\x07$" {
588 send_gdb "\t"
589 gdb_expect {
590 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
591 send_gdb "n"
592 gdb_expect {
593 -re "\\(gdb\\) p no_var_named_this-$" {
594 send_gdb "\n"
595 gdb_expect {
596 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
597 pass "complete (2) 'p no_var_named_this-'"
598 }
599 -re ".*$gdb_prompt $" {
600 fail "complete (2) 'p no_var_named_this-'"
601 }
602 timeout {
603 fail "(timeout) complete (2) 'p no_var_named_this-'"
604 }
605 }
606 }
607 -re ".*$gdb_prompt $" {
608 fail "complete (2) 'p no_var_named_this-'"
609 }
610 timeout {
611 fail "(timeout) complete (2) 'p no_var_named_this-'"
612 }
613 }
614 }
615 -re ".*$gdb_prompt $" {
616 fail "complete (2) 'p no_var_named_this-'"
617 }
618 timeout { fail "(timeout) complete (2) 'p no_var_named_this-'" }
619 }
620 }
621 -re ".*$gdb_prompt $" { fail "complete (2) 'p no_var_named_this-'" }
622 timeout { fail "(timeout) complete (2) 'p no_var_named_this-'" }
623 }
624
625
626 # The following tests used to simply try to complete `${objdir}/file',
627 # and so on. The problem is that ${objdir} can be very long; the
628 # completed filename may be more than eighty characters wide. When
629 # this happens, readline tries to manage things, producing output that
630 # may make sense on the screen, but is rather hard for our script to
631 # recognize.
632 #
633 # In the case that motivated this change, the (gdb) prompt occupied
634 # the leftmost six columns, and `${objdir}/' was seventy-four
635 # characters long --- eighty in all. After printing the slash,
636 # readline emitted a space, a carriage return, and then `Makefile'
637 # (the tab character being received as input after `Make'.
638 #
639 # Basically, you have to let readline do whatever it's going to do to
640 # make the screen look right. If it happens to use a different
641 # strategy on Tuesdays to get the cursor in the right place, that's
642 # not something the testsuite should care about.
643 #
644 # So, we avoid long lines. We `cd' to ${objdir} first, and then do
645 # the completion relative to the current directory.
646
647 # ${srcdir} may be a relative path. We want to make sure we end up
648 # in the right directory - so make sure we know where it is.
649 set mydir [pwd]
650 cd ${srcdir}
651 set fullsrcdir [pwd]
652 cd ${mydir}
653
654 # If the directory name contains a '+' we must escape it, adding a backslash.
655 # If not, the test below will fail because it will interpret the '+' as a
656 # regexp operator. We use string_to_regexp for this purpose.
657
658 gdb_test "cd ${fullsrcdir}" \
659 "Working directory [string_to_regexp ${fullsrcdir}].*" \
660 "cd to \${srcdir}"
661
662 send_gdb "complete file ./gdb.base/compl\n"
663 sleep 1
664 gdb_expect {
665 -re "file ./gdb.base/completion\\.exp.*$gdb_prompt $"
666 { pass "complete-command 'file ./gdb.base/compl'"}
667 -re ".*$gdb_prompt $" { fail "complete-command 'file ./gdb.base/compl'" }
668 timeout { fail "(timeout) complete-command 'file ./gdb.base/compl'" }
669 }
670
671 send_gdb "file ./gdb.base/complet\t"
672 sleep 1
673 gdb_expect {
674 -re "^file ./gdb.base/completion\\.exp $"\
675 { send_gdb "\n"
676 # Ignore the exact error message.
677 gdb_test_multiple "" "complete 'file ./gdb.base/complet'" {
678 -re "\r\nA program is being debugged already\\.\[\r\n\]+Are you sure you want to change the file\\? \\(y or n\\) $" {
679 send_gdb "n\n"
680 exp_continue
681 }
682 -re ".*$gdb_prompt $" { pass "complete 'file ./gdb.base/complet'" }
683 }
684 }
685 -re ".*$gdb_prompt $" { fail "complete 'file ./gdb.base/complet'" }
686 timeout { fail "(timeout) complete 'file ./gdb.base/complet'" }
687 }
688
689 send_gdb "info func marke\t"
690 sleep 1
691 gdb_expect {
692 -re "^info func marke.*r$"\
693 {
694 send_gdb "\t\t"
695 sleep 3
696 gdb_expect {
697 -re "marker1.*$gdb_prompt info func marker$"\
698 { send_gdb "\n"
699 gdb_expect {
700 -re "All functions matching regular expression \"marker\":.*File.*break1.c:\r\nint marker1\\((void|)\\);\r\nint marker2\\(int\\).*marker3\\(char.*char.*\\).*marker4\\(long int\\);.*$gdb_prompt $"\
701 { pass "complete 'info func marke'"}
702 -re ".*$gdb_prompt $" { fail "complete 'info func marke'"}
703 timeout {fail "(timeout) complete 'info func marke'"}
704 }
705 }
706 -re ".*$gdb_prompt $" { fail "complete 'info func marke'"}
707 timeout {fail "(timeout) complete 'info func marke'"}
708 }
709 }
710 -re ".*$gdb_prompt $" { fail "complete 'info func marke'" }
711 timeout { fail "(timeout) complete 'info func marke'" }
712 }
713
714
715 send_gdb "set follow-fork-mode \t\t"
716 sleep 1
717 gdb_expect {
718 -re "child.*parent.*$gdb_prompt set follow-fork-mode $"\
719 { send_gdb "\n"
720 gdb_expect {
721 -re "Requires an argument.*child.*parent.*$gdb_prompt $"\
722 { pass "complete 'set follow-fork-mode'"}
723 -re "Ambiguous item \"\"\\..*$gdb_prompt $"\
724 { pass "complete 'set follow-fork-mode'"}
725 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'"}
726 timeout {fail "(timeout) complete 'set follow-fork-mode'"}
727 }
728 }
729 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'" }
730 timeout { fail "(timeout) complete 'set follow-fork-mode'" }
731 }
732
733 # Restore globals modified in this test...
734 if [info exists old_inputrc] {
735 set env(INPUTRC) $old_inputrc
736 } else {
737 unset env(INPUTRC)
738 }
739 set timeout $oldtimeout1
740
741 return 0