OLD | NEW |
1 # Copyright (C) 2009-2012 Free Software Foundation, Inc. | 1 # Copyright (C) 2009-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 new GDB commands in Python. | 17 # for defining new GDB commands in Python. |
18 | 18 |
19 if $tracelevel then { | |
20 strace $tracelevel | |
21 } | |
22 | |
23 load_lib gdb-python.exp | 19 load_lib gdb-python.exp |
24 | 20 |
25 # Start with a fresh gdb. | 21 # Start with a fresh gdb. |
26 | 22 |
27 gdb_exit | 23 gdb_exit |
28 gdb_start | 24 gdb_start |
29 gdb_reinitialize_dir $srcdir/$subdir | 25 gdb_reinitialize_dir $srcdir/$subdir |
30 | 26 |
31 # Skip all tests if Python scripting is not enabled. | 27 # Skip all tests if Python scripting is not enabled. |
32 if { [skip_python_tests] } { continue } | 28 if { [skip_python_tests] } { continue } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 {\['1 2', '3'\]} \ | 131 {\['1 2', '3'\]} \ |
136 "string_to_argv (\"'1 2' 3\")" | 132 "string_to_argv (\"'1 2' 3\")" |
137 | 133 |
138 gdb_test "python print gdb.string_to_argv ('\"1 2\" 3')" \ | 134 gdb_test "python print gdb.string_to_argv ('\"1 2\" 3')" \ |
139 {\['1 2', '3'\]} \ | 135 {\['1 2', '3'\]} \ |
140 "string_to_argv ('\"1 2\" 3')" | 136 "string_to_argv ('\"1 2\" 3')" |
141 | 137 |
142 gdb_test "python print gdb.string_to_argv ('1\\ 2 3')" \ | 138 gdb_test "python print gdb.string_to_argv ('1\\ 2 3')" \ |
143 {\['1 2', '3'\]} \ | 139 {\['1 2', '3'\]} \ |
144 "string_to_argv ('1\\ 2 3')" | 140 "string_to_argv ('1\\ 2 3')" |
| 141 |
| 142 # Test user-defined python commands. |
| 143 gdb_py_test_multiple "input simple user-defined command" \ |
| 144 "python" "" \ |
| 145 "class test_help (gdb.Command):" "" \ |
| 146 " \"\"\"Docstring\"\"\"" "" \ |
| 147 " def __init__ (self):" "" \ |
| 148 " super (test_help, self).__init__ (\"test_help\", gdb.COMMAND_USER)" "" \ |
| 149 " def invoke (self, arg, from_tty):" "" \ |
| 150 " print \"test_cmd output, arg = %s\" % arg" "" \ |
| 151 "test_help ()" "" \ |
| 152 "end" "" |
| 153 |
| 154 gdb_test "test_help ugh" "test_cmd output, arg = ugh" "call simple user-defined
command" |
| 155 |
| 156 # Make sure the command shows up in `help user-defined`. |
| 157 gdb_test "help user-defined" "User-defined commands.\[\r\n\]+The commands in thi
s class are those defined by the user.\[\r\n\]+Use the \"define\" command to def
ine 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 docum
entation.\[\r\n\]+Type \"apropos word\" to search for commands related to \"word
\".\[\r\n\]+Command name abbreviations are allowed if unambiguous.\[\r\n\]+" "se
e user-defined command in `help user-defined`" |
OLD | NEW |