2012-01-16 Pedro Alves <palves@redhat.com>
[platform/upstream/binutils.git] / gdb / testsuite / gdb.python / py-evthreads.exp
1 # Copyright (C) 2010-2012 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 if {[is_remote target]} {
17     # RuntimeError: Could not find event thread
18     kfail "python/12966" "Run to breakpoint 1"
19     return -1
20 }
21
22 if { ![support_displaced_stepping] } { 
23     unsupported "displaced stepping"
24     return -1
25 }
26
27 load_lib gdb-python.exp
28
29 set testfile "py-evthreads"
30 set srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32 set pyfile ${srcdir}/${subdir}/py-events.py
33
34 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
35     return -1
36 }
37 clean_restart $testfile
38
39 if { [skip_python_tests] } { continue }
40
41 gdb_test_no_output "python execfile ('${pyfile}')" ""
42
43 gdb_test "Test_Events" "Event testers registered."
44 gdb_test_no_output "set non-stop on"
45 gdb_test_no_output "set target-async on"
46
47 gdb_breakpoint "main"
48 gdb_breakpoint "thread2"
49 gdb_breakpoint "thread3"
50
51 gdb_run_cmd
52 set test "Run to breakpoint 1"
53 gdb_test_multiple "" $test {
54     -re "event type: stop\r\nstop reason: breakpoint\r\nfirst breakpoint number: 1\r\nbreakpoint number: 1\r\nthread num: 1\r\n$gdb_prompt $" {
55         pass $test
56     }
57     -re "The target does not support running in non-stop mode" {
58         unsupported "non-stop mode is unsupported"
59         return
60     }
61 }
62
63 gdb_test "next" "event type: stop\r\nstop reason: breakpoint\r\nfirst breakpoint number: 2\r\nbreakpoint number: 2\r\nthread num: 2" "reached breakpoint 2"
64
65 gdb_test "thread 2" {\[Switching to thread 2 .*}
66
67 gdb_test "next" "event type: stop\r\nstop reason: breakpoint\r\nfirst breakpoint number: 3\r\nbreakpoint number: 3\r\nthread num: 3" "reached breakpoint 3"
68
69 gdb_test "thread 3" {\[Switching to thread 3 .*}
70
71 set test "continue thread 1"
72 gdb_test_multiple "continue&" $test {
73     -re "event type: continue\r\nthread num: 3\r\n$gdb_prompt " {
74         # This expect string must not expect the end-of-buffer '$'.
75         pass $test
76     }
77 }
78
79 set test "thread 3 was signaled"
80 gdb_test_multiple "" $test {
81     -re "event type: stop\r\nstop reason: signal\r\nstop signal: SIGUSR1\r\nthread num: 3\r\nevent type: stop\r\n$" {
82         pass $test
83     }
84 }