OLD | NEW |
1 # Copyright (C) 2010-2012 Free Software Foundation, Inc. | 1 # Copyright (C) 2010-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. | 16 # This file is part of the GDB testsuite. |
17 # It tests the types.py module. | 17 # It tests the types.py module. |
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 set testfile "lib-types" | 21 standard_testfile .cc |
26 set srcfile ${testfile}.cc | 22 |
27 set binfile ${objdir}/${subdir}/${testfile} | 23 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { |
28 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
g c++}] != "" } { | |
29 untested "Couldn't compile ${srcfile}" | |
30 return -1 | 24 return -1 |
31 } | 25 } |
32 | 26 |
33 # Start with a fresh gdb. | |
34 gdb_exit | |
35 gdb_start | |
36 gdb_reinitialize_dir $srcdir/$subdir | |
37 gdb_load ${binfile} | |
38 | |
39 # Skip all tests if Python scripting is not enabled. | 27 # Skip all tests if Python scripting is not enabled. |
40 if { [skip_python_tests] } { continue } | 28 if { [skip_python_tests] } { continue } |
41 | 29 |
42 if ![runto_main] then { | 30 if ![runto_main] then { |
43 fail "Can't run to main" | 31 fail "Can't run to main" |
44 return 0 | 32 return 0 |
45 } | 33 } |
46 | 34 |
47 gdb_test_no_output "python import gdb.types" | 35 gdb_test_no_output "python import gdb.types" |
48 | 36 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 gdb_test_no_output "python enum1_obj = gdb.parse_and_eval ('enum1_obj')" | 124 gdb_test_no_output "python enum1_obj = gdb.parse_and_eval ('enum1_obj')" |
137 gdb_test_no_output "python enum1_dict = gdb.types.make_enum_dict (enum1_obj.type
)" | 125 gdb_test_no_output "python enum1_dict = gdb.types.make_enum_dict (enum1_obj.type
)" |
138 gdb_test_no_output "python enum1_list = enum1_dict.items ()" | 126 gdb_test_no_output "python enum1_list = enum1_dict.items ()" |
139 gdb_test_no_output "python enum1_list.sort ()" | 127 gdb_test_no_output "python enum1_list.sort ()" |
140 gdb_test "python print enum1_list" {\[\('A', 0L\), \('B', 1L\), \('C', 2L\)\]} | 128 gdb_test "python print enum1_list" {\[\('A', 0L\), \('B', 1L\), \('C', 2L\)\]} |
141 | 129 |
142 # test deep_items | 130 # test deep_items |
143 gdb_test_no_output "python struct_a = gdb.lookup_type ('struct A')" | 131 gdb_test_no_output "python struct_a = gdb.lookup_type ('struct A')" |
144 gdb_test "python print struct_a.keys ()" {\['a', '', 'c', ''\]} | 132 gdb_test "python print struct_a.keys ()" {\['a', '', 'c', ''\]} |
145 gdb_test "python print \[k for k,v in gdb.types.deep_items(struct_a)\]" {\['a',
'b0', 'b1', 'bb0', 'bb1', 'bbb0', 'bbb1', 'c', 'dd0', 'dd1', 'd2', 'd3'\]} | 133 gdb_test "python print \[k for k,v in gdb.types.deep_items(struct_a)\]" {\['a',
'b0', 'b1', 'bb0', 'bb1', 'bbb0', 'bbb1', 'c', 'dd0', 'dd1', 'd2', 'd3'\]} |
OLD | NEW |