Move ChangeLog entry to proper place.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / completion.exp
CommitLineData
ecd75fc8 1# Copyright 1998-2014 Free Software Foundation, Inc.
c906108c
SS
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 15
c906108c
SS
16# This file was written by Elena Zannoni (ezannoni@cygnus.com)
17
18# This file is part of the gdb testsuite.
19
20#
21# tests for command completion
22#
23# Here are some useful test cases for completion.
24# They should be tested with both M-? and TAB.
25#
26# "show output-" "radix"
27# "show output" "-radix"
28# "p" ambiguous (commands starting with p--path, print, printf, etc.)
29# "p " ambiguous (all symbols)
30# "info t foo" no completions
31# "info t " no completions
32# "info t" ambiguous ("info target", "info terminal", etc.)
33# "info ajksdlfk" no completions
34# "info ajksdlfk " no completions
35# "info" " "
36# "info " ambiguous (all info commands)
a1dea79a
FF
37# "p \"break1" unambiguous (completes to filename "break1.c")
38# "p \"break1." unambiguous (should complete to "break1.c" but does not,
9b284272 39# due to readline limitations)
5ac01682
DJ
40# "p 'arg" ambiguous (all symbols starting with arg)
41# "p b-arg" ambiguous (all symbols starting with arg)
c906108c
SS
42# "p b-" ambiguous (all symbols)
43# "file Make" "file" (word break hard to screw up here)
44# "file ../gdb.stabs/we" "ird" (needs to not break word at slash)
45#
46
47
c906108c 48
c906108c
SS
49#
50# test running programs
51#
c906108c 52
f76495c8 53standard_testfile break.c break1.c
c906108c 54
4c93b1db 55if [get_compiler_info] {
ae59b1da 56 return -1
085dd6e6
JM
57}
58
f76495c8
TT
59if {[prepare_for_testing $testfile.exp $testfile \
60 [list $srcfile $srcfile2] {debug nowarnings}]} {
61 untested $testfile.exp
62 return -1
63}
c906108c
SS
64
65if ![runto_main] then {
66 perror "tests suppressed"
67}
68
085dd6e6 69set timeout 30
c906108c 70
0d4d0e77
YQ
71gdb_test_no_output "complete print values\[0\].x." \
72 "field completion with invalid field"
73
74# If there is a non-deprecated completion, it should be returned.
75gdb_test "complete sav" "save" "test non-deprecated completion"
76# If there is only a deprecated completion, then it should be returned.
77gdb_test "complete save-t" "save-tracepoints" "test deprecated completion"
78
79
80#
81# Tag name completion.
82#
83
84gdb_test "complete ptype struct some_" "ptype struct some_struct"
85gdb_test "complete ptype enum some_" "ptype enum some_enum"
86gdb_test "complete ptype union some_" "ptype union some_union"
87
88
89gdb_test "complete set gnutarget aut" "set gnutarget auto"
90
91
92gdb_test "complete set cp-abi aut" "set cp-abi auto"
93
94# Test that completion of commands 'target FOO' works well.
95set targets [list "core" "tfile" "exec"]
96
97# Test that completion of command 'target ctf' if GDB supports ctf
98# target.
99gdb_test_multiple "target ctf" "" {
100 -re "Undefined target command: \"ctf\"\. Try \"help target\"\.\r\n$gdb_prompt $" {
101 }
102 -re "No CTF directory specified.*\r\n$gdb_prompt $" {
103 lappend targets "ctf"
104 }
105}
106
322f9c21
YQ
107# Test artifacts are put in different locations depending on test
108# is a parallel run or not. Firstly check file exists, and then
109# do the test on file completion.
110
111foreach dir1 [ list "./gdb.base" "./outputs/gdb.base/completion" ] {
d7761c2c
DE
112 if { [remote_file host exists ${dir1}/completion]
113 && [remote_file host exists ${dir1}/completion0.o]
114 && [remote_file host exists ${dir1}/completion1.o] } {
322f9c21
YQ
115 foreach target_name ${targets} {
116 gdb_test "complete target ${target_name} ${dir1}/completion" \
117 "target ${target_name} ${dir1}/completion.*${dir1}/completion0\\.o.*${dir1}/completion1\\.o.*"
118 }
119 break
120 }
0d4d0e77
YQ
121}
122
123#
124# "set foo unlimited" completion.
125#
126
127# A var_uinteger command.
128gdb_test "complete set height " "set height unlimited"
129gdb_test "complete set height u" "set height unlimited"
130
131# A var_integer command.
132gdb_test "complete set listsize " "set listsize unlimited"
133gdb_test "complete set listsize unl" "set listsize unlimited"
134
135# A var_zuinteger_unlimited command.
136gdb_test "complete set trace-buffer-size " "set trace-buffer-size unlimited"
137gdb_test "complete set trace-buffer-size unl" "set trace-buffer-size unlimited"
138
139# Tests below are about tab-completion, which doesn't work if readline
140# library isn't used. Check it first.
141
142if { ![readline_is_used] } {
143 return -1
144}
145
8e28d804 146set test "complete 'hfgfh'"
c906108c 147send_gdb "hfgfh\t"
8e28d804
PA
148gdb_test_multiple "" "$test" {
149 -re "^hfgfh\\\x07$" {
150 send_gdb "\n"
151 gdb_test_multiple "" $test {
152 -re "Undefined command: \"hfgfh\"\\. Try \"help\"\\..*$gdb_prompt $" {
153 pass "$test"
154 }
155 }
156 }
157}
c906108c
SS
158
159#exp_internal 0
160
8e28d804 161set test "complete 'show output'"
c906108c 162send_gdb "show output\t"
8e28d804
PA
163gdb_test_multiple "" "$test" {
164 -re "^show output-radix $" {
165 send_gdb "\n"
166 gdb_test_multiple "" "$test" {
167 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $" {
168 pass "$test"
169 }
170 }
171 }
172}
c906108c 173
8e28d804 174set test "complete 'show output-'"
c906108c 175send_gdb "show output-\t"
8e28d804
PA
176gdb_test_multiple "" "$test" {
177 -re "^show output-radix $" {
178 send_gdb "\n"
179 gdb_test_multiple "" "$test" {
180 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $" {
181 pass "$test"
182 }
c906108c 183 }
8e28d804
PA
184 }
185}
c906108c 186
8e28d804 187set test "complete 'p'"
c906108c 188send_gdb "p\t"
8e28d804
PA
189gdb_test_multiple "" "$test" {
190 -re "^p\\\x07$" {
191 send_gdb "\n"
192 gdb_test_multiple "" "$test" {
193 -re "The history is empty\\..*$gdb_prompt $" {
194 pass "$test"
195 }
c906108c 196 }
8e28d804
PA
197 }
198}
c906108c 199
8e28d804 200set test "complete 'p '"
c906108c 201send_gdb "p \t"
8e28d804
PA
202gdb_test_multiple "" "$test" {
203 -re "^p \\\x07$" {
204 send_gdb "\n"
205 gdb_test_multiple "" "$test" {
206 -re "The history is empty\\..*$gdb_prompt $" {
207 pass "$test"
208 }
209 }
210 }
211}
c906108c 212
8e28d804 213set test "complete 'info t foo'"
c906108c 214send_gdb "info t foo\t"
8e28d804
PA
215gdb_test_multiple "" "$test" {
216 -re "^info t foo\\\x07$" {
217 send_gdb "\n"
218 gdb_test_multiple "" "$test" {
18a9fc12 219 -re "Ambiguous info command \"t foo\": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" {
8e28d804
PA
220 pass "$test"
221 }
222 }
223 }
224}
c906108c 225
8e28d804 226set test "complete 'info t'"
c906108c 227send_gdb "info t\t"
8e28d804
PA
228gdb_test_multiple "" "$test" {
229 -re "^info t\\\x07$" {
230 send_gdb "\n"
231 gdb_test_multiple "" "$test" {
18a9fc12 232 -re "Ambiguous info command \"t\": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" {
8e28d804
PA
233 pass "$test"
234 }
235 }
236 }
237}
c906108c 238
8e28d804 239set test "complete 'info t '"
c906108c 240send_gdb "info t \t"
8e28d804
PA
241gdb_test_multiple "" "$test" {
242 -re "^info t \\\x07$" {
243 send_gdb "\n"
244 gdb_test_multiple "" "$test" {
18a9fc12 245 -re "Ambiguous info command \"t \": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" {
8e28d804
PA
246 pass "$test"
247 }
248 }
249 }
250}
c906108c 251
8e28d804 252set test "complete 'info asdfgh'"
c906108c 253send_gdb "info asdfgh\t"
8e28d804
PA
254gdb_test_multiple "" "$test" {
255 -re "^info asdfgh\\\x07$" {
256 send_gdb "\n"
257 gdb_test_multiple "" "$test" {
258 -re "Undefined info command: \"asdfgh\". Try \"help info\"\\..*$gdb_prompt $" {
259 pass "$test"
260 }
261 }
262 }
263}
c906108c 264
8e28d804 265set test "complete 'info asdfgh '"
c906108c 266send_gdb "info asdfgh \t"
8e28d804
PA
267gdb_test_multiple "" "$test" {
268 -re "^info asdfgh \\\x07$" {
269 send_gdb "\n"
270 gdb_test_multiple "" "$test" {
271 -re "Undefined info command: \"asdfgh \". Try \"help info\"\\..*$gdb_prompt $" {
272 pass "$test"
273 }
274 }
275 }
276}
c906108c 277
8e28d804 278set test "complete 'info'"
c906108c 279send_gdb "info\t"
8e28d804
PA
280gdb_test_multiple "" "$test" {
281 -re "^info $" {
282 send_gdb "\n"
283 gdb_test_multiple "" "$test" {
284 -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands.*$gdb_prompt $" {
285 pass "$test"
286 }
287 }
288 }
289}
c906108c 290
8e28d804 291set test "complete 'info '"
c906108c 292send_gdb "info \t"
8e28d804
PA
293gdb_test_multiple "" "$test" {
294 -re "^info \\\x07$" {
295 send_gdb "\n"
296 gdb_test_multiple "" "$test" {
297 -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*$gdb_prompt $" {
298 pass "$test"
299 }
300 }
301 }
302}
c906108c 303
8e28d804 304set test "complete (2) 'info '"
c906108c 305send_gdb "info \t"
8e28d804
PA
306gdb_test_multiple "" "$test" {
307 -re "^info \\\x07$" {
308 send_gdb "\t"
309 gdb_test_multiple "" "$test" {
310 -re "address.*types.*$gdb_prompt " {
311 send_gdb "\n"
312 gdb_test_multiple "" "$test" {
313 -re "\"info\".*unambiguous\\..*$gdb_prompt $" {
314 pass "$test"
315 }
316 }
317 }
318 }
319 }
320}
c906108c 321
8ffd0459 322set test "complete 'help info wat'"
14032a66 323send_gdb "help info wat\t"
8e28d804
PA
324gdb_test_multiple "" "$test" {
325 -re "^help info watchpoints $" {
326 send_gdb "\n"
327 gdb_test_multiple "" "$test" {
328 -re "Status of specified watchpoints.*\r\n.*$gdb_prompt $" {
329 pass "$test"
330 }
331 }
332 }
333 -re "^help info wat\\\x07$" {
334 fail "$test"
335 }
336}
14032a66 337
8e28d804 338set test "complete 'p \"break1'"
a1dea79a 339send_gdb "p \"break1\t"
8e28d804
PA
340gdb_test_multiple "" "$test" {
341 -re "^p \"break1\\\x07$" {
342 send_gdb "\n"
343 gdb_test_multiple "" "$test" {}
344 }
345 -re "^p \"break1\\.c\"$" {
346 send_gdb "\n"
347 gdb_test_multiple "" "$test" {
8ffd0459 348 -re "$gdb_prompt $" {
8e28d804 349 pass "$test"
9b284272 350 }
8e28d804
PA
351 }
352 }
353}
9b284272
DJ
354
355setup_xfail "*-*-*"
8e28d804 356set test "complete 'p \"break1.'"
a1dea79a 357send_gdb "p \"break1.\t"
8e28d804
PA
358gdb_test_multiple "" "$test" {
359 -re "^p \"break1\\.\\\x07$" {
360 send_gdb "\n"
361 gdb_test_multiple "" "$test" {}
362 }
363 -re "^p \"break1\\.c\"$" {
364 send_gdb "\n"
365 gdb_test_multiple "" "$test" {
8ffd0459 366 -re "$gdb_prompt $" {
8e28d804 367 pass "$test"
9b284272 368 }
8e28d804
PA
369 }
370 }
371 -re "^p \"break1\\..*$" {
372 send_gdb "\n"
373 gdb_test_multiple "" "$test" {}
374 }
375}
c906108c 376
8ffd0459 377set test "complete 'p 'arg'"
5ac01682 378send_gdb "p 'arg\t"
8e28d804
PA
379gdb_test_multiple "" "$test" {
380 -re "^p 'arg\\\x07$" {
381 send_gdb "\n"
382 gdb_test_multiple "" "$test" {
383 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
384 pass "$test"
385 }
386 }
387 }
388}
c906108c 389
8ffd0459 390set test "complete (2) 'p 'arg'"
5ac01682 391send_gdb "p 'arg\t"
8e28d804 392gdb_test_multiple "" "$test" {
5ac01682 393 -re "^p 'arg\\\x07$" {
085dd6e6 394 send_gdb "\t"
8e28d804 395 gdb_test_multiple "" "$test" {
8ffd0459 396 -re "argv.*$gdb_prompt " {
085dd6e6 397 send_gdb "\n"
8e28d804 398 gdb_test_multiple "" "$test" {
f617d2b6 399 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
8e28d804 400 pass "$test"
085dd6e6 401 }
085dd6e6
JM
402 }
403 }
404 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
405 send_gdb "n"
8e28d804 406 gdb_test_multiple "" "$test" {
5ac01682 407 -re "\\(gdb\\) p 'arg$" {
085dd6e6 408 send_gdb "\n"
8e28d804 409 gdb_test_multiple "" "$test" {
f617d2b6 410 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
8e28d804 411 pass "$test"
085dd6e6 412 }
085dd6e6
JM
413 }
414 }
085dd6e6
JM
415 }
416 }
085dd6e6
JM
417 }
418 }
085dd6e6 419}
c906108c 420
de0bea00
MF
421set test "complete 'handle signal'"
422send_gdb "handle sigq\t"
423gdb_test_multiple "" "$test" {
424 -re "^handle sigq\b\b\b\bSIGQUIT $" {
425 send_gdb "\n"
426 gdb_test_multiple "" "$test" {
427 -re "SIGQUIT.*Quit.*$gdb_prompt $" {
428 pass "$test"
429 }
430 }
431 }
432}
433
434set test "complete 'handle keyword'"
435send_gdb "handle nos\t"
436gdb_test_multiple "" "$test" {
437 -re "^handle nostop $" {
438 send_gdb "\n"
439 gdb_test_multiple "" "$test" {
440 -re "$gdb_prompt $" {
441 pass "$test"
442 }
443 }
444 }
445}
446
ace21957
MF
447set test "complete help aliases"
448send_gdb "help user-define\t"
449gdb_test_multiple "" "$test" {
450 -re "^help user-defined $" {
451 send_gdb "\n"
452 gdb_test_multiple "" "$test" {
453 -re "$gdb_prompt $" {
454 pass "$test"
455 }
456 }
457 }
458}
459
c906108c 460
6970b5b1
JB
461# These tests used to try completing the shorter "p b-a".
462# Unfortunately, on some systems, there are .o files in system
463# libraries which declare static variables named `b'. Of course,
464# those variables aren't really in scope, as far as the compiler is
465# concerned. But GDB deliberately tries to be more liberal: if you
466# enter an identifier that doesn't have any binding in scope, GDB will
467# search all the program's compilation units for a static variable of
468# the given name.
469#
470# This behavior can help avoid a lot of pedantry, so it's usually a
471# good thing. But in this test case, it causes GDB to print the value
472# of some random variable, instead of giving us the "No symbol..."
473# error we were expecting.
474#
475# For example, on S/390 linux, the file s_atan.c in libm.a declares a
476# `b', which is a structure containing an int and a float, so GDB says
477# ``Argument to arithmetic operation not a number or boolean'' instead
478# of ``No symbol ...''.
479#
480# So, I'm hoping that there is no system with a static library variable named
481# `no_var_by_this_name'.
8e28d804
PA
482
483set test "complete 'p no_var_named_this-arg'"
5ac01682 484send_gdb "p no_var_named_this-arg\t"
8e28d804 485gdb_test_multiple "" "$test" {
5ac01682 486 -re "^p no_var_named_this-arg\\\x07$" {
2d842f13 487 send_gdb "\n"
8e28d804 488 gdb_test_multiple "" "$test" {
6970b5b1 489 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
8e28d804 490 pass "$test"
c906108c 491 }
c906108c 492 }
2d842f13 493 }
2d842f13 494}
c906108c 495
8e28d804 496set test "complete (2) 'p no_var_named_this-arg'"
5ac01682 497send_gdb "p no_var_named_this-arg\t"
8e28d804 498gdb_test_multiple "" "$test" {
5ac01682 499 -re "^p no_var_named_this-arg\\\x07$" {
085dd6e6 500 send_gdb "\t"
8e28d804 501 gdb_test_multiple "" "$test" {
8ffd0459 502 -re "argv.*$gdb_prompt " {
085dd6e6 503 send_gdb "\n"
8e28d804 504 gdb_test_multiple "" "$test" {
6970b5b1 505 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
8e28d804 506 pass "$test"
085dd6e6 507 }
085dd6e6
JM
508 }
509 }
510 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
c4cbc0df
PA
511 send_gdb "n\n"
512
513 # Eat the prompt
085dd6e6 514 gdb_expect {
c4cbc0df 515 -re "$gdb_prompt " {
8e28d804
PA
516 pass "$test (eat prompt)"
517 }
518 timeout {
519 fail "(timeout) $test (eat prompt)"
c4cbc0df 520 }
c4cbc0df
PA
521 }
522
8e28d804 523 gdb_test_multiple "" "$test" {
c4cbc0df 524 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
8e28d804 525 pass "$test"
c4cbc0df 526 }
085dd6e6
JM
527 }
528 }
c906108c 529 }
085dd6e6 530 }
085dd6e6 531}
c906108c 532
8e28d804 533set test "complete (2) 'p no_var_named_this-'"
6970b5b1 534send_gdb "p no_var_named_this-\t"
8e28d804 535gdb_test_multiple "" "$test" {
6970b5b1 536 -re "^p no_var_named_this-\\\x07$" {
085dd6e6 537 send_gdb "\t"
8e28d804 538 gdb_test_multiple "" "$test" {
085dd6e6 539 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
c4cbc0df
PA
540 send_gdb "n\n"
541
542 # Eat the prompt
085dd6e6 543 gdb_expect {
c4cbc0df 544 -re "$gdb_prompt " {
8e28d804
PA
545 pass "$test (eat prompt)"
546 }
547 timeout {
548 fail "(timeout) $test (eat prompt)"
c4cbc0df 549 }
c4cbc0df
PA
550 }
551
8e28d804 552 gdb_test_multiple "" "$test" {
c4cbc0df 553 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
8e28d804 554 pass "$test"
c4cbc0df 555 }
085dd6e6
JM
556 }
557 }
8ffd0459 558 -re "argv.*$gdb_prompt $" {
5ac01682 559 send_gdb "\n"
8e28d804 560 gdb_test_multiple "" "$test" {
5ac01682 561 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
8e28d804 562 pass "$test"
5ac01682
DJ
563 }
564 }
565 }
085dd6e6
JM
566 }
567 }
085dd6e6 568}
c906108c 569
8e28d804 570set test "complete 'p values\[0\].a'"
65d12d83 571send_gdb "p values\[0\].a\t"
8e28d804
PA
572gdb_test_multiple "" "$test" {
573 -re "^p values.0..a_field $" {
574 send_gdb "\n"
575 gdb_test_multiple "" "$test" {
8ffd0459 576 -re " = 0.*$gdb_prompt $" {
8e28d804
PA
577 pass "$test"
578 }
579 }
580 }
581}
0eba65ab 582
8e28d804 583set test "complete 'p values\[0\] . a'"
37cd5d19 584send_gdb "p values\[0\] . a\t"
8e28d804
PA
585gdb_test_multiple "" "$test" {
586 -re "^p values.0. . a_field $" {
587 send_gdb "\n"
588 gdb_test_multiple "" "$test" {
8ffd0459 589 -re " = 0.*$gdb_prompt $" {
8e28d804
PA
590 pass "$test"
591 }
592 }
593 }
594}
37cd5d19 595
8e28d804 596set test "complete 'p &values\[0\] -> a'"
37cd5d19 597send_gdb "p &values\[0\] -> a\t"
8e28d804
PA
598gdb_test_multiple "" "$test" {
599 -re "^p &values.0. -> a_field $" {
600 send_gdb "\n"
601 gdb_test_multiple "" "$test" {
8ffd0459 602 -re " = .*0x\[0-9a-fA-F\]*.*$gdb_prompt $" {
8e28d804
PA
603 pass "$test"
604 }
605 }
606 }
607}
37cd5d19 608
9ae8282d
TT
609gdb_test "complete p &values\[0\]->z" \
610 "p &values.0.->z_field" \
8e28d804 611 "completion of field in anonymous union"
9ae8282d 612
4fc5d43e
TT
613gdb_test "complete ptype &values\[0\]->z" \
614 "ptype &values.0.->z_field" \
615 "ptype completion of field in anonymous union"
616
617gdb_test "complete whatis &values\[0\]->z" \
618 "whatis &values.0.->z_field" \
619 "whatis completion of field in anonymous union"
620
1a371f2e 621# The following tests used to simply try to complete `${objdir}/file',
0eba65ab
JB
622# and so on. The problem is that ${objdir} can be very long; the
623# completed filename may be more than eighty characters wide. When
624# this happens, readline tries to manage things, producing output that
625# may make sense on the screen, but is rather hard for our script to
626# recognize.
627#
628# In the case that motivated this change, the (gdb) prompt occupied
1a371f2e 629# the leftmost six columns, and `${objdir}/' was seventy-four
0eba65ab
JB
630# characters long --- eighty in all. After printing the slash,
631# readline emitted a space, a carriage return, and then `Makefile'
632# (the tab character being received as input after `Make'.
633#
634# Basically, you have to let readline do whatever it's going to do to
635# make the screen look right. If it happens to use a different
636# strategy on Tuesdays to get the cursor in the right place, that's
637# not something the testsuite should care about.
638#
639# So, we avoid long lines. We `cd' to ${objdir} first, and then do
640# the completion relative to the current directory.
c906108c 641
37ab3bf8
DJ
642# ${srcdir} may be a relative path. We want to make sure we end up
643# in the right directory - so make sure we know where it is.
644set mydir [pwd]
645cd ${srcdir}
646set fullsrcdir [pwd]
647cd ${mydir}
648
68ab8fc5
EZ
649# If the directory name contains a '+' we must escape it, adding a backslash.
650# If not, the test below will fail because it will interpret the '+' as a
651# regexp operator. We use string_to_regexp for this purpose.
652
653gdb_test "cd ${fullsrcdir}" \
654 "Working directory [string_to_regexp ${fullsrcdir}].*" \
655 "cd to \${srcdir}"
656
cc1d7add 657
40974f91 658# GDB used to fail adding / on directories, on the first try only.
fdc498b8 659set uniquedir ../testsuite/gdb.base/comp-dir
40974f91
JK
660set escapeduniquedir [string_to_regexp ${uniquedir}]
661set uniquesu subdi
662set uniquesub ${uniquesu}r
663set escapeuniquesub [string_to_regexp ${uniquesub}]
40974f91 664send_gdb "dir ${uniquedir}\t"
cc1d7add 665gdb_expect {
40974f91 666 -re "${escapeduniquedir}/" {
cc1d7add 667 pass "directory completion"
40974f91 668 send_gdb "${uniquesu}\t"
cc1d7add 669 }
40974f91 670 -re "${escapeduniquedir} $" {
cc1d7add 671 fail "directory completion (old gdb bug)"
40974f91 672 send_gdb "\b/${uniquesu}\t"
cc1d7add
PM
673 }
674 default {
675 fail "directory completion (timeout)"
40974f91 676 send_gdb "\ndir ${uniquedir}/${uniquesu}\t"
cc1d7add
PM
677 }
678}
679
680gdb_expect {
40974f91 681 -re "${escapeuniquesub}/$" {
cc1d7add
PM
682 pass "directory completion 2"
683 }
684 timeout {
685 fail "directory completion 2"
686 }
687}
688
40974f91
JK
689# Empty COMMAND sends no newline while " " sends the newline we need.
690gdb_test " " "Source directories searched: .*" "Glob remaining of directory test"
cc1d7add 691
8e28d804
PA
692gdb_test "complete file ./gdb.base/compl" \
693 "file ./gdb.base/completion\\.exp.*" \
694 "complete-command 'file ./gdb.base/compl'"
cc1d7add 695
8e28d804 696set test "complete 'file ./gdb.base/complet'"
f1c2644b 697send_gdb "file ./gdb.base/complet\t"
8e28d804
PA
698gdb_test_multiple "" "$test" {
699 -re "^file ./gdb.base/completion\\.exp $" {
700 send_gdb "\n"
701 # Ignore the exact error message.
702 gdb_test_multiple "" "complete 'file ./gdb.base/complet'" {
703 -re "\r\nA program is being debugged already\\.\[\r\n\]+Are you sure you want to change the file\\? \\(y or n\\) $" {
704 send_gdb "n\n"
705 exp_continue
706 }
8ffd0459 707 -re "$gdb_prompt $" {
8e28d804
PA
708 pass "$test"
709 }
710 }
711 }
712}
c906108c 713
8e28d804 714set test "complete 'info func marke'"
3fe60e3c 715send_gdb "info func marke\t"
8e28d804
PA
716gdb_test_multiple "" "$test" {
717 -re "^info func marke.*r$" {
718 send_gdb "\t\t"
719 gdb_test_multiple "" "$test" {
720 -re "marker1.*$gdb_prompt " {
721 send_gdb "\n"
722 gdb_test_multiple "" "$test" {
723 -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 $" {
724 pass "$test"
725 }
726 }
727 }
728 }
729 }
730}
c906108c
SS
731
732
8e28d804 733set test "complete 'set follow-fork-mode'"
c906108c 734send_gdb "set follow-fork-mode \t\t"
8e28d804
PA
735gdb_test_multiple "" "$test" {
736 -re "child.*parent.*$gdb_prompt " {
737 send_gdb "\n"
738 gdb_test_multiple "" "$test" {
739 -re "Requires an argument.*child.*parent.*$gdb_prompt $" {
740 pass "$test"
741 }
742 -re "Ambiguous item \"\"\\..*$gdb_prompt $" {
743 pass "$test"
744 }
745 }
746 }
747}
c906108c 748
5ea2a32c 749return 0
This page took 1.459139 seconds and 4 git commands to generate.