Commit | Line | Data |
---|---|---|
0fb0cc75 | 1 | # Copyright (C) 2008, 2009 Free Software Foundation, Inc. |
d57a3c85 TJB |
2 | |
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 | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
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/>. | |
15 | ||
16 | # This file is part of the GDB testsuite. It tests the mechanism | |
17 | # exposing values to Python. | |
18 | ||
19 | if $tracelevel then { | |
20 | strace $tracelevel | |
21 | } | |
22 | ||
23 | # Start with a fresh gdb. | |
24 | ||
25 | gdb_exit | |
26 | gdb_start | |
27 | gdb_reinitialize_dir $srcdir/$subdir | |
28 | ||
29 | gdb_test_multiple "python print 23" "verify python support" { | |
30 | -re "not supported.*$gdb_prompt $" { | |
31 | unsupported "python support is disabled" | |
32 | return -1 | |
33 | } | |
34 | -re "$gdb_prompt $" {} | |
35 | } | |
36 | ||
37 | # Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... | |
38 | # Run a test named NAME, consisting of multiple lines of input. | |
39 | # After each input line INPUT, search for result line RESULT. | |
40 | # Succeed if all results are seen; fail otherwise. | |
41 | proc gdb_py_test_multiple {name args} { | |
42 | global gdb_prompt | |
43 | foreach {input result} $args { | |
44 | if {[gdb_test_multiple $input "$name - $input" { | |
45 | -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { | |
46 | pass "$name - $input" | |
47 | } | |
48 | }]} { | |
49 | return 1 | |
50 | } | |
51 | } | |
52 | return 0 | |
53 | } | |
54 | ||
55 | gdb_py_test_multiple "multi-line python command" \ | |
56 | "python" "" \ | |
57 | "print 23" "" \ | |
58 | "end" "23" | |
59 | ||
60 | gdb_py_test_multiple "show python command" \ | |
61 | "define zzq" "Type commands for definition of .* just \"end\"\\.*" \ | |
62 | "python" "" \ | |
63 | "print 23" "" \ | |
64 | "end" "" \ | |
65 | "end" "" \ | |
adb483fe | 66 | "show user zzq" "User command \"zzq\":.* python.*print 23.* end" |
311a4e6b TJB |
67 | |
68 | gdb_py_test_multiple "indented multi-line python command" \ | |
69 | "python" "" \ | |
70 | "def foo ():" "" \ | |
71 | " print 'hello, world!'" "" \ | |
72 | "foo ()" "" \ | |
73 | "end" "hello, world!" |