]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.python/py-infthread.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / py-infthread.exp
CommitLineData
8acc9f48 1# Copyright (C) 2009-2013 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
6c162d5e
TT
19load_lib gdb-python.exp
20
b4a58790
TT
21standard_testfile
22
595939de
PM
23if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
24 return -1
25}
26
27# Start with a fresh gdb.
28clean_restart ${testfile}
29
30# Skip all tests if Python scripting is not enabled.
31if { [skip_python_tests] } { continue }
32
33# The following tests require execution.
34
35if ![runto_main] then {
36 fail "Can't run to main"
37 return 0
38}
39
595939de
PM
40# Test basic gdb.Inferior attributes and methods.
41
42gdb_py_test_silent_cmd "python t0 = gdb.selected_thread ()" "test gdb.selected_thread" 1
9325cb04
PK
43gdb_test "python print (t0)" "\\<gdb.InferiorThread object at 0x\[\[:xdigit:\]\]+>" "verify InferiorThread object"
44gdb_test "python print ('result = %s' % t0.num)" " = \[0-9\]+" "test Inferior.num"
45gdb_test "python print ('result = %s' % str (t0.ptid))" " = \\(\[0-9\]+, \[0-9\]+, \[0-9\]+\\)" "test InferiorThread.ptid"
595939de 46
4694da01
TT
47gdb_py_test_silent_cmd "python name = gdb.selected_thread().name" \
48 "get supplied name of current thread" 1
49gdb_py_test_silent_cmd "python gdb.selected_thread().name = 'hibob'" \
50 "set name of current thread" 1
9325cb04 51gdb_test "python print (gdb.selected_thread().name)" "hibob" \
4694da01
TT
52 "check name of current thread"
53gdb_py_test_silent_cmd "python gdb.selected_thread().name = None" \
54 "reset name of current thread" 1
9325cb04 55gdb_test "python print (gdb.selected_thread().name == name)" "True" \
4694da01
TT
56 "check name of current thread again"
57
9325cb04
PK
58gdb_test "python print ('result = %s' % t0.is_stopped ())" " = True" "test InferiorThread.is_stopped"
59gdb_test "python print ('result = %s' % t0.is_running ())" " = False" "test InferiorThread.is_running"
60gdb_test "python print ('result = %s' % t0.is_exited ())" " = False" "test InferiorThread.is_exited"
29703da4
PM
61
62# Test InferiorThread is_valid. This must always be the last test in
63# this testcase as it kills the inferior.
64
9325cb04 65gdb_test "python print ('result = %s' % t0.is_valid ())" " = True" "test InferiorThread.is_valid"
29703da4 66gdb_test_no_output "kill inferior 1" "kill inferior 1"
9325cb04 67gdb_test "python print ('result = %s' % t0.is_valid ())" " = False" "test InferiorThread.is_valid"