| 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 # exposing inferior threads to Python. | 17 # exposing inferior threads to 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 set testfile "py-infthread" | 21 standard_testfile |
| 26 set srcfile ${testfile}.c | 22 |
| 27 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { | 23 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { |
| 28 return -1 | 24 return -1 |
| 29 } | 25 } |
| 30 | 26 |
| 31 # Start with a fresh gdb. | 27 # Start with a fresh gdb. |
| 32 clean_restart ${testfile} | 28 clean_restart ${testfile} |
| 33 | 29 |
| 34 # Skip all tests if Python scripting is not enabled. | 30 # Skip all tests if Python scripting is not enabled. |
| 35 if { [skip_python_tests] } { continue } | 31 if { [skip_python_tests] } { continue } |
| 36 | 32 |
| 37 # The following tests require execution. | 33 # The following tests require execution. |
| 38 | 34 |
| 39 if ![runto_main] then { | 35 if ![runto_main] then { |
| 40 fail "Can't run to main" | 36 fail "Can't run to main" |
| 41 return 0 | 37 return 0 |
| 42 } | 38 } |
| 43 | 39 |
| 44 runto [gdb_get_line_number "Break here."] | |
| 45 | |
| 46 # Test basic gdb.Inferior attributes and methods. | 40 # Test basic gdb.Inferior attributes and methods. |
| 47 | 41 |
| 48 gdb_py_test_silent_cmd "python t0 = gdb.selected_thread ()" "test gdb.selected_t
hread" 1 | 42 gdb_py_test_silent_cmd "python t0 = gdb.selected_thread ()" "test gdb.selected_t
hread" 1 |
| 49 gdb_test "python print t0" "\\<gdb.InferiorThread object at 0x\[\[:xdigit:\]\]+>
" "verify InferiorThread object" | 43 gdb_test "python print t0" "\\<gdb.InferiorThread object at 0x\[\[:xdigit:\]\]+>
" "verify InferiorThread object" |
| 50 gdb_test "python print 'result =', t0.num" " = \[0-9\]+" "test Inferior.num" | 44 gdb_test "python print 'result =', t0.num" " = \[0-9\]+" "test Inferior.num" |
| 51 gdb_test "python print 'result =', t0.ptid" " = \\(\[0-9\]+, \[0-9\]+, \[0-9\]+\
\)" "test InferiorThread.ptid" | 45 gdb_test "python print 'result =', t0.ptid" " = \\(\[0-9\]+, \[0-9\]+, \[0-9\]+\
\)" "test InferiorThread.ptid" |
| 52 | 46 |
| 53 gdb_py_test_silent_cmd "python name = gdb.selected_thread().name" \ | 47 gdb_py_test_silent_cmd "python name = gdb.selected_thread().name" \ |
| 54 "get supplied name of current thread" 1 | 48 "get supplied name of current thread" 1 |
| 55 gdb_py_test_silent_cmd "python gdb.selected_thread().name = 'hibob'" \ | 49 gdb_py_test_silent_cmd "python gdb.selected_thread().name = 'hibob'" \ |
| 56 "set name of current thread" 1 | 50 "set name of current thread" 1 |
| 57 gdb_test "python print gdb.selected_thread().name" "hibob" \ | 51 gdb_test "python print gdb.selected_thread().name" "hibob" \ |
| 58 "check name of current thread" | 52 "check name of current thread" |
| 59 gdb_py_test_silent_cmd "python gdb.selected_thread().name = None" \ | 53 gdb_py_test_silent_cmd "python gdb.selected_thread().name = None" \ |
| 60 "reset name of current thread" 1 | 54 "reset name of current thread" 1 |
| 61 gdb_test "python print gdb.selected_thread().name == name" "True" \ | 55 gdb_test "python print gdb.selected_thread().name == name" "True" \ |
| 62 "check name of current thread again" | 56 "check name of current thread again" |
| 63 | 57 |
| 64 gdb_test "python print 'result =', t0.is_stopped ()" " = True" "test InferiorThr
ead.is_stopped" | 58 gdb_test "python print 'result =', t0.is_stopped ()" " = True" "test InferiorThr
ead.is_stopped" |
| 65 gdb_test "python print 'result =', t0.is_running ()" " = False" "test InferiorTh
read.is_running" | 59 gdb_test "python print 'result =', t0.is_running ()" " = False" "test InferiorTh
read.is_running" |
| 66 gdb_test "python print 'result =', t0.is_exited ()" " = False" "test InferiorThr
ead.is_exited" | 60 gdb_test "python print 'result =', t0.is_exited ()" " = False" "test InferiorThr
ead.is_exited" |
| 67 | 61 |
| 68 # Test InferiorThread is_valid. This must always be the last test in | 62 # Test InferiorThread is_valid. This must always be the last test in |
| 69 # this testcase as it kills the inferior. | 63 # this testcase as it kills the inferior. |
| 70 | 64 |
| 71 gdb_test "python print 'result =', t0.is_valid ()" " = True" "test InferiorThrea
d.is_valid" | 65 gdb_test "python print 'result =', t0.is_valid ()" " = True" "test InferiorThrea
d.is_valid" |
| 72 gdb_test_no_output "kill inferior 1" "kill inferior 1" | 66 gdb_test_no_output "kill inferior 1" "kill inferior 1" |
| 73 gdb_test "python print 'result =', t0.is_valid ()" " = False" "test InferiorThre
ad.is_valid" | 67 gdb_test "python print 'result =', t0.is_valid ()" " = False" "test InferiorThre
ad.is_valid" |
| OLD | NEW |