diff --git a/gdb/testsuite/gdb.python/py-prompt.exp b/gdb/testsuite/gdb.python/py-prompt.exp new file mode 100644 index 0000000..fc15931 --- /dev/null +++ b/gdb/testsuite/gdb.python/py-prompt.exp @@ -0,0 +1,60 @@ +# Copyright (C) 2009, 2010, 2011 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 file is part of the GDB testsuite. It tests the mechanism +# for defining new GDB commands in Python. + +if $tracelevel then { + strace $tracelevel +} + +load_lib gdb-python.exp + +# Start with a fresh gdb. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir + +# Skip all tests if Python scripting is not enabled. +if { [skip_python_tests] } { continue } +gdb_exit + +global GDBFLAGS +set saved_gdbflags $GDBFLAGS +set GDBFLAGS [concat $GDBFLAGS " -ex \"python def foo(x): return \'(Foo) \'\""] +set GDBFLAGS [concat $GDBFLAGS " -ex \"python gdb.prompt_hook = foo\""] + +set tmp_gdbflags $GDBFLAGS +set saved_gdb_prompt $gdb_prompt + +global gdb_prompt +set gdb_prompt "\[(\]Foo\[)\]" + + +# The following tests are strange in that we are testing the first prompt +# gdb_start will fail/timeout if does not receive the '(foo) ' prompt. +# otherwise no 'passing' test is performed. +set GDBFLAGS [concat $tmp_gdbflags " -ex \"set editing on\""] +gdb_start +gdb_exit + +set GDBFLAGS [concat $tmp_gdbflags " -ex \"set editing off\""] +gdb_start +gdb_exit + +set GDBFLAGS $saved_gdbflags +set gdb_prompt $saved_gdb_prompt +return 0