From 9e14a9ba25afb7116d7220271973cd11fe2d6902 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Mon, 18 Jan 2010 06:31:24 +0000 Subject: [PATCH] * gdb.python/source2.py: New file. * gdb.python/source1: New file. * gdb.python/python.exp: Test "source" command. --- gdb/testsuite/ChangeLog | 7 +++++++ gdb/testsuite/gdb.python/python.exp | 6 ++++++ gdb/testsuite/gdb.python/source1 | 19 +++++++++++++++++++ gdb/testsuite/gdb.python/source2.py | 18 ++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 gdb/testsuite/gdb.python/source1 create mode 100644 gdb/testsuite/gdb.python/source2.py diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 79b5759..3611875 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2010-01-18 Tom Tromey + Thiago Jung Bauermann + + * gdb.python/source2.py: New file. + * gdb.python/source1: New file. + * gdb.python/python.exp: Test "source" command. + 2010-01-15 Stan Shebs * gdb.trace/tfile.c: New file. diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index 951c295..b345ad2 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -29,6 +29,10 @@ gdb_reinitialize_dir $srcdir/$subdir gdb_test_multiple "python print 23" "verify python support" { -re "not supported.*$gdb_prompt $" { unsupported "python support is disabled" + + # If Python is not supported, verify that sourcing a python script + # causes an error. + gdb_test "source $srcdir/$subdir/source2.py" "Error in sourced command file:.*" return -1 } -re "$gdb_prompt $" {} @@ -72,5 +76,7 @@ gdb_py_test_multiple "indented multi-line python command" \ "foo ()" "" \ "end" "hello, world!" +gdb_test "source $srcdir/$subdir/source2.py" "yes" + gdb_test "python print gdb.current_objfile()" "None" gdb_test "python print gdb.objfiles()" "\\\[\\\]" diff --git a/gdb/testsuite/gdb.python/source1 b/gdb/testsuite/gdb.python/source1 new file mode 100644 index 0000000..f9c19bd --- /dev/null +++ b/gdb/testsuite/gdb.python/source1 @@ -0,0 +1,19 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2008, 2009, 2010 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 . + +# This is sourced as python; pick an expression that is not valid for gdb. +print 'y%ss' % 'e' diff --git a/gdb/testsuite/gdb.python/source2.py b/gdb/testsuite/gdb.python/source2.py new file mode 100644 index 0000000..4e9a9e3 --- /dev/null +++ b/gdb/testsuite/gdb.python/source2.py @@ -0,0 +1,18 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2008, 2009, 2010 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 . + +print 'y%ss' % 'e' -- 2.7.4