diff options
author | Phil Muldoon <pmuldoon@redhat.com> | 2013-11-07 12:32:31 +0000 |
---|---|---|
committer | Phil Muldoon <pmuldoon@redhat.com> | 2013-11-07 12:32:31 +0000 |
commit | 92e32e33f16b40988327df8e8beacf3a8a356916 (patch) | |
tree | d2bf276c96c29ea698823470ef545a7ef2747341 /gdb/testsuite | |
parent | f76c27b5bdd446964d9920464b2f761ae7a4f62a (diff) | |
download | gdb-92e32e33f16b40988327df8e8beacf3a8a356916.zip gdb-92e32e33f16b40988327df8e8beacf3a8a356916.tar.gz gdb-92e32e33f16b40988327df8e8beacf3a8a356916.tar.bz2 |
2013-11-07 Phil Muldoon <pmuldoon@redhat.com>
PR python/15747
* python/py-cmd.c: Add COMPLETE_EXPRESSION constant.
2013-11-07 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-cmd.exp: Add COMPLETE_EXPRESSION tests.
* gdb.python/py-cmd.c: New File.
2013-11-07 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Commands In Python): Document COMPLETE_EXPRESSION
constant.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-cmd.c | 29 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-cmd.exp | 42 |
3 files changed, 72 insertions, 4 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 11ca125..3f2467d 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2013-11-07 Phil Muldoon <pmuldoon@redhat.com> + * gdb.python/py-cmd.exp: Add COMPLETE_EXPRESSION tests. + * gdb.python/py-cmd.c: New File. + +2013-11-07 Phil Muldoon <pmuldoon@redhat.com> + * gdb.python/py-breakpoint.exp: Add temporary breakpoint tests. 2013-11-06 Doug Evans <dje@sebabeach.org> diff --git a/gdb/testsuite/gdb.python/py-cmd.c b/gdb/testsuite/gdb.python/py-cmd.c new file mode 100644 index 0000000..7f0dc59 --- /dev/null +++ b/gdb/testsuite/gdb.python/py-cmd.c @@ -0,0 +1,29 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2013 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +struct foo +{ + int ij; + int bc; +}; + +int +main (void) +{ + struct foo bar; + return 0; +} diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp index 610fe52..6d12950 100644 --- a/gdb/testsuite/gdb.python/py-cmd.exp +++ b/gdb/testsuite/gdb.python/py-cmd.exp @@ -18,15 +18,20 @@ load_lib gdb-python.exp -# Start with a fresh gdb. +standard_testfile -gdb_exit -gdb_start -gdb_reinitialize_dir $srcdir/$subdir +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { + return -1 +} # Skip all tests if Python scripting is not enabled. if { [skip_python_tests] } { continue } +if ![runto_main] then { + fail "Cannot run to main." + return 0 +} + # Test a simple command. gdb_py_test_multiple "input simple command" \ @@ -155,3 +160,32 @@ gdb_test "test_help ugh" "test_cmd output, arg = ugh" "call simple user-defined # Make sure the command shows up in `help user-defined`. gdb_test "help user-defined" "User-defined commands.\[\r\n\]+The commands in this class are those defined by the user.\[\r\n\]+Use the \"define\" command to define a command.\[\r\n\]+\[\r\n\]+List of commands:\[\r\n\]+\[\r\n\]+test_help -- Docstring\[\r\n\]+\[\r\n\]+Type \"help\" followed by command name for full documentation.\[\r\n\]+Type \"apropos word\" to search for commands related to \"word\".\[\r\n\]+Command name abbreviations are allowed if unambiguous.\[\r\n\]+" "see user-defined command in `help user-defined`" + +# Test expression completion on fields +gdb_py_test_multiple "expression completion command" \ + "python" "" \ + "class expr_test (gdb.Command):" "" \ + " def __init__ (self):" "" \ + " super (expr_test, self).__init__ (\"expr_test\", gdb.COMMAND_USER, gdb.COMPLETE_EXPRESSION)" "" \ + " def invoke (self, arg, from_tty):" "" \ + " print (\"invoked on = %s\" % arg)" "" \ + "expr_test ()" "" \ + "end" "" + + +gdb_test "complete expr_test bar\." \ + "expr_test bar\.bc.*expr_test bar\.ij.*" \ + "Test completion through complete command" + +set test "complete 'expr_test bar.i'" +send_gdb "expr_test bar\.i\t\t" +gdb_test_multiple "" "$test" { + -re "expr_test bar\.ij \\\x07$" { + send_gdb "\n" + gdb_test_multiple "" $test { + -re "invoked on = bar.ij.*$gdb_prompt $" { + pass "$test" + } + } + } +} |