OLD | NEW |
1 # Copyright (C) 2011-2012 Free Software Foundation, Inc. | 1 # Copyright (C) 2011-2012 Free Software Foundation, Inc. |
2 | 2 |
3 # This program is free software; you can redistribute it and/or modify | 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 | 4 # it under the terms of the GNU General Public License as published by |
5 # the Free Software Foundation; either version 3 of the License, or | 5 # the Free Software Foundation; either version 3 of the License, or |
6 # (at your option) any later version. | 6 # (at your option) any later version. |
7 # | 7 # |
8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License |
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
16 # This file is part of the GDB testsuite. It tests the mechanism | 16 # This file is part of the GDB testsuite. It tests the mechanism |
17 # for defining the prompt in Python. | 17 # for defining the prompt in Python. |
18 | 18 |
19 if $tracelevel then { | 19 standard_testfile |
20 strace $tracelevel | 20 |
| 21 # We need to use TCL's exec to get the pid. |
| 22 if [is_remote target] then { |
| 23 return 0 |
21 } | 24 } |
22 | 25 |
23 set testfile "py-prompt" | |
24 set srcfile ${testfile}.c | |
25 set binfile ${objdir}/${subdir}/${testfile} | |
26 | |
27 | |
28 load_lib gdb-python.exp | 26 load_lib gdb-python.exp |
29 load_lib prompt.exp | 27 load_lib prompt.exp |
30 | 28 |
31 # Start with a fresh gdb. | 29 # Start with a fresh gdb. |
32 | 30 |
33 gdb_exit | 31 gdb_exit |
34 gdb_start | 32 gdb_start |
35 gdb_reinitialize_dir $srcdir/$subdir | 33 gdb_reinitialize_dir $srcdir/$subdir |
36 | 34 |
37 # Skip all tests if Python scripting is not enabled. | 35 # Skip all tests if Python scripting is not enabled. |
38 if { [skip_python_tests] } { continue } | 36 if { [skip_python_tests] } { continue } |
39 gdb_exit | 37 gdb_exit |
40 | 38 |
41 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
ug}] != "" } { | 39 if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} { |
42 untested py-prompt.exp | |
43 return -1 | 40 return -1 |
44 } | 41 } |
45 | 42 |
46 global GDBFLAGS | 43 global GDBFLAGS |
47 set saved_gdbflags $GDBFLAGS | 44 set saved_gdbflags $GDBFLAGS |
48 set GDBFLAGS [concat $GDBFLAGS " -ex \"set height 0\""] | 45 set GDBFLAGS [concat $GDBFLAGS " -ex \"set height 0\""] |
49 set GDBFLAGS [concat $GDBFLAGS " -ex \"set width 0\""] | 46 set GDBFLAGS [concat $GDBFLAGS " -ex \"set width 0\""] |
50 set GDBFLAGS [concat $GDBFLAGS " -ex \"python p = list()\""] | 47 set GDBFLAGS [concat $GDBFLAGS " -ex \"python p = list()\""] |
51 set prompt_func "python def foo(x): global p; p.append(x); return \'(Foo) \'" | 48 set prompt_func "python def foo(x): global p; p.append(x); return \'(Foo) \'" |
52 set GDBFLAGS [concat $GDBFLAGS " -ex \"$prompt_func\""] | 49 set GDBFLAGS [concat $GDBFLAGS " -ex \"$prompt_func\""] |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 ".*prompt is \"$gdb_prompt \".*" \ | 119 ".*prompt is \"$gdb_prompt \".*" \ |
123 "show prompt gets the correct result 4" | 120 "show prompt gets the correct result 4" |
124 gdb_test "python print x, len(p)" "1 2" \ | 121 gdb_test "python print x, len(p)" "1 2" \ |
125 "retrieving the prompt causes no extra prompt_hook calls 4" | 122 "retrieving the prompt causes no extra prompt_hook calls 4" |
126 gdb_test "python print \"'\" + str(p\[0\]) + \"'\"" "'$gdb_prompt_fail '" \ | 123 gdb_test "python print \"'\" + str(p\[0\]) + \"'\"" "'$gdb_prompt_fail '" \ |
127 "prompt_hook argument is default prompt. 4" | 124 "prompt_hook argument is default prompt. 4" |
128 gdb_exit | 125 gdb_exit |
129 | 126 |
130 set GDBFLAGS $saved_gdbflags | 127 set GDBFLAGS $saved_gdbflags |
131 return 0 | 128 return 0 |
OLD | NEW |