gdb
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-infthread.exp
CommitLineData
7b6bb8da 1# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
595939de
PM
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 inferior threads to Python.
18
19if $tracelevel then {
20 strace $tracelevel
21}
22
6c162d5e
TT
23load_lib gdb-python.exp
24
595939de
PM
25set testfile "py-infthread"
26set srcfile ${testfile}.c
27if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
28 return -1
29}
30
31# Start with a fresh gdb.
32clean_restart ${testfile}
33
34# Skip all tests if Python scripting is not enabled.
35if { [skip_python_tests] } { continue }
36
37# The following tests require execution.
38
39if ![runto_main] then {
40 fail "Can't run to main"
41 return 0
42}
43
44runto [gdb_get_line_number "Break here."]
45
46# Test basic gdb.Inferior attributes and methods.
47
48gdb_py_test_silent_cmd "python t0 = gdb.selected_thread ()" "test gdb.selected_thread" 1
49gdb_test "python print t0" "\\<gdb.InferiorThread object at 0x\[\[:xdigit:\]\]+>" "verify InferiorThread object"
50gdb_test "python print 'result =', t0.num" " = \[0-9\]+" "test Inferior.num"
51gdb_test "python print 'result =', t0.ptid" " = \\(\[0-9\]+, \[0-9\]+, \[0-9\]+\\)" "test InferiorThread.ptid"
52
4694da01
TT
53gdb_py_test_silent_cmd "python name = gdb.selected_thread().name" \
54 "get supplied name of current thread" 1
55gdb_py_test_silent_cmd "python gdb.selected_thread().name = 'hibob'" \
56 "set name of current thread" 1
57gdb_test "python print gdb.selected_thread().name" "hibob" \
58 "check name of current thread"
59gdb_py_test_silent_cmd "python gdb.selected_thread().name = None" \
60 "reset name of current thread" 1
61gdb_test "python print gdb.selected_thread().name == name" "True" \
62 "check name of current thread again"
63
595939de
PM
64gdb_test "python print 'result =', t0.is_stopped ()" " = True" "test InferiorThread.is_stopped"
65gdb_test "python print 'result =', t0.is_running ()" " = False" "test InferiorThread.is_running"
66gdb_test "python print 'result =', t0.is_exited ()" " = False" "test InferiorThread.is_exited"
This page took 0.080213 seconds and 4 git commands to generate.