X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Ftestsuite%2Fgdb.base%2Fcompletion.exp;h=2a85df57a65d1ad0c71a13f7327e5554a1ca0f4a;hb=da02b3a81f661022256bfc44ddd280fd7923a459;hp=ccdc199e670ba754af92a09276491949bfe6f7ea;hpb=de0bea007c446f40ecec90a2672e0a806d397e1a;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index ccdc199e67..2a85df57a6 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -1,5 +1,4 @@ -# Copyright 1998-1999, 2002-2004, 2007-2012 Free Software Foundation, -# Inc. +# Copyright 1998-2014 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -51,42 +50,98 @@ # test running programs # -set testfile "break" -set srcfile ${testfile}.c -set srcfile1 ${testfile}1.c -set binfile ${objdir}/${subdir}/${testfile} +standard_testfile break.c break1.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { - untested completion.exp - return -1 +if [get_compiler_info] { + return -1 } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { - untested completion.exp - return -1 +if {[prepare_for_testing $testfile.exp $testfile \ + [list $srcfile $srcfile2] {debug nowarnings}]} { + untested $testfile.exp + return -1 } -if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { - untested completion.exp - return -1 +if ![runto_main] then { + perror "tests suppressed" } -if [get_compiler_info] { - return -1; -} +set timeout 30 + +gdb_test_no_output "complete print values\[0\].x." \ + "field completion with invalid field" -gdb_exit +# If there is a non-deprecated completion, it should be returned. +gdb_test "complete sav" "save" "test non-deprecated completion" +# If there is only a deprecated completion, then it should be returned. +gdb_test "complete save-t" "save-tracepoints" "test deprecated completion" -gdb_start -gdb_reinitialize_dir $srcdir/$subdir -gdb_load ${binfile} -if ![runto_main] then { - perror "tests suppressed" +# +# Tag name completion. +# + +gdb_test "complete ptype struct some_" "ptype struct some_struct" +gdb_test "complete ptype enum some_" "ptype enum some_enum" +gdb_test "complete ptype union some_" "ptype union some_union" + + +gdb_test "complete set gnutarget aut" "set gnutarget auto" + + +gdb_test "complete set cp-abi aut" "set cp-abi auto" + +# Test that completion of commands 'target FOO' works well. +set targets [list "core" "tfile" "exec"] + +# Test that completion of command 'target ctf' if GDB supports ctf +# target. +gdb_test_multiple "target ctf" "" { + -re "Undefined target command: \"ctf\"\. Try \"help target\"\.\r\n$gdb_prompt $" { + } + -re "No CTF directory specified.*\r\n$gdb_prompt $" { + lappend targets "ctf" + } } -set oldtimeout1 $timeout -set timeout 30 +# Test artifacts are put in different locations depending on test +# is a parallel run or not. Firstly check file exists, and then +# do the test on file completion. + +foreach dir1 [ list "./gdb.base" "./outputs/gdb.base/completion" ] { + if { [remote_file host exists ${dir1}/completion] + && [remote_file host exists ${dir1}/completion0.o] + && [remote_file host exists ${dir1}/completion1.o] } { + foreach target_name ${targets} { + gdb_test "complete target ${target_name} ${dir1}/completion" \ + "target ${target_name} ${dir1}/completion.*${dir1}/completion0\\.o.*${dir1}/completion1\\.o.*" + } + break + } +} + +# +# "set foo unlimited" completion. +# + +# A var_uinteger command. +gdb_test "complete set height " "set height unlimited" +gdb_test "complete set height u" "set height unlimited" + +# A var_integer command. +gdb_test "complete set listsize " "set listsize unlimited" +gdb_test "complete set listsize unl" "set listsize unlimited" + +# A var_zuinteger_unlimited command. +gdb_test "complete set trace-buffer-size " "set trace-buffer-size unlimited" +gdb_test "complete set trace-buffer-size unl" "set trace-buffer-size unlimited" + +# Tests below are about tab-completion, which doesn't work if readline +# library isn't used. Check it first. + +if { ![readline_is_used] } { + return -1 +} set test "complete 'hfgfh'" send_gdb "hfgfh\t" @@ -161,7 +216,7 @@ gdb_test_multiple "" "$test" { -re "^info t foo\\\x07$" { send_gdb "\n" gdb_test_multiple "" "$test" { - -re "Ambiguous info command \"t foo\": target, tasks, terminal, threads, tp, tracepoints, tvariables, types\\..*$gdb_prompt $" { + -re "Ambiguous info command \"t foo\": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" { pass "$test" } } @@ -174,7 +229,7 @@ gdb_test_multiple "" "$test" { -re "^info t\\\x07$" { send_gdb "\n" gdb_test_multiple "" "$test" { - -re "Ambiguous info command \"t\": target, tasks, terminal, threads, tp, tracepoints, tvariables, types\\..*$gdb_prompt $" { + -re "Ambiguous info command \"t\": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" { pass "$test" } } @@ -187,7 +242,7 @@ gdb_test_multiple "" "$test" { -re "^info t \\\x07$" { send_gdb "\n" gdb_test_multiple "" "$test" { - -re "Ambiguous info command \"t \": target, tasks, terminal, threads, tp, tracepoints, tvariables, types\\..*$gdb_prompt $" { + -re "Ambiguous info command \"t \": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" { pass "$test" } } @@ -389,6 +444,19 @@ gdb_test_multiple "" "$test" { } } +set test "complete help aliases" +send_gdb "help user-define\t" +gdb_test_multiple "" "$test" { + -re "^help user-defined $" { + send_gdb "\n" + gdb_test_multiple "" "$test" { + -re "$gdb_prompt $" { + pass "$test" + } + } + } +} + # These tests used to try completing the shorter "p b-a". # Unfortunately, on some systems, there are .o files in system @@ -542,6 +610,14 @@ gdb_test "complete p &values\[0\]->z" \ "p &values.0.->z_field" \ "completion of field in anonymous union" +gdb_test "complete ptype &values\[0\]->z" \ + "ptype &values.0.->z_field" \ + "ptype completion of field in anonymous union" + +gdb_test "complete whatis &values\[0\]->z" \ + "whatis &values.0.->z_field" \ + "whatis completion of field in anonymous union" + # The following tests used to simply try to complete `${objdir}/file', # and so on. The problem is that ${objdir} can be very long; the # completed filename may be more than eighty characters wide. When @@ -670,16 +746,4 @@ gdb_test_multiple "" "$test" { } } -gdb_test_no_output "complete print values\[0\].x." \ - "field completion with invalid field" - -# If there is a non-deprecated completion, it should be returned. -gdb_test "complete sav" "save" "test non-deprecated completion" -# If there is only a deprecated completion, then it should be returned. -gdb_test "complete save-t" "save-tracepoints" "test deprecated completion" - - -# Restore globals modified in this test... -set timeout $oldtimeout1 - return 0