gdb/testsuite/
[platform/upstream/binutils.git] / gdb / testsuite / gdb.python / py-evthreads.exp
1 # Copyright (C) 2010, 2011 Free Software Foundation, Inc.
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 Python-based
17 # pretty-printing for the CLI.
18
19 # Skip all tests if Python scripting is not enabled.
20
21 if $tracelevel then {
22     strace $tracelevel
23 }
24
25 if { ![support_displaced_stepping] } { 
26     unsupported "displaced stepping"
27     return -1
28 }
29
30 load_lib gdb-python.exp
31
32 set testfile "py-evthreads"
33 set srcfile ${testfile}.c
34 set binfile ${objdir}/${subdir}/${testfile}
35 set pyfile ${srcdir}/${subdir}/py-events.py
36
37 gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}
38 clean_restart $testfile
39
40 if { [skip_python_tests] } { continue }
41
42 gdb_test_no_output "python execfile ('${pyfile}')" ""
43
44 gdb_test "Test_Events" "Event testers registered."
45 gdb_test_no_output "set non-stop on"
46 gdb_test_no_output "set target-async on"
47
48 gdb_breakpoint "main"
49 gdb_breakpoint "thread2"
50 gdb_breakpoint "thread3"
51
52 send_gdb "run\n"
53 gdb_expect {
54     -re "event type: stop.*
55 .*stop reason: breakpoint.*
56 .*breakpoint number: 1.*
57 .*thread num: 1.*" {
58         pass "reached breakpoint 1"
59     }
60     timeout {
61             fail "did not reach breakpoint 1"
62         }
63 }
64
65 send_gdb "next\n"
66 gdb_expect {
67     -re "event type: stop.*
68 .*stop reason: breakpoint.*
69 .*breakpoint number: 2.*
70 .*thread num: 2.*" {
71         pass "reached breakpoint 2"
72     }
73     timeout {
74             fail "did not reach breakpoint 2"
75         }
76 }
77
78 send_gdb "next\n"
79 gdb_expect {
80     -re "event type: stop.*
81 .*stop reason: breakpoint.*
82 .*breakpoint number: 3.*
83 .*thread num: 3.*" {
84         pass "reached breakpoint 3"
85     }
86     timeout {
87             fail "did not reach breakpoint 3"
88         }
89 }
90
91 send_gdb "continue&\n"
92 gdb_expect {
93     -re ".*event type: continue.*
94 .*thread num: 1.*\r\n$gdb_prompt $" {
95         pass "continue thread 1"
96     }
97     timeout {
98             fail "continue thread 1 failed"
99         }
100 }
101
102 gdb_test "thread 2" ".*Switching to thread 2.*"
103 send_gdb "continue&\n"
104 gdb_expect {
105     -re ".*event type: continue.*
106 .*thread num: 2.*" {
107         pass "continue thread 2"
108     }
109     timeout {
110             fail "continue thread 2 failed"
111         }
112 }
113
114 send_gdb "continue -a\n"
115 gdb_expect {
116     -re ".*stop reason: signal.*
117 .*stop signal: SIGSEGV.*
118 .*thread num: 3.*" {
119         pass "thread 3 was signalled"
120     }
121     timeout {
122             fail "thread 3 was not signalled"
123         }
124 }