]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/interrupt.exp
Fix for PR gdb/1543.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / interrupt.exp
CommitLineData
9b254dd1 1# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2007, 2008
b6ba6518 2# Free Software Foundation, Inc.
c906108c
SS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
eecf4bed
JB
17if [target_info exists gdb,nointerrupts] {
18 verbose "Skipping interrupt.exp because of nointerrupts."
19 continue
c906108c
SS
20}
21
22if [target_info exists gdb,noinferiorio] {
23 verbose "Skipping interrupt.exp because of noinferiorio."
24 return
25}
26
27if $tracelevel then {
28 strace $tracelevel
29}
30
31set prms_id 0
32set bug_id 0
33
34set testfile interrupt
35set srcfile ${testfile}.c
36set binfile ${objdir}/${subdir}/${testfile}
37if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
38 untested interrupt.exp
39 return -1
c906108c
SS
40}
41
42gdb_start
43
44
45if ![file exists $binfile] then {
46 perror "$binfile does not exist."
47 return 0
48} else {
49 gdb_reinitialize_dir $srcdir/$subdir
50 gdb_load $binfile
51 # Hope this is unix :-)
52 gdb_test "shell stty intr '^C'" "" \
53 "set interrupt character in interrupt.exp"
54 if [runto_main] then {
55 send_gdb "continue\n"
56 gdb_expect {
57 -re "\r\ntalk to me baby\r\n$" {
58 pass "child process is alive"
59 }
60 timeout { fail "run (timeout)" }
61 eof { fail "run (eof)" }
62 }
63 # This should appear twice, once for the echo and once for the
64 # program's output. Under dejagnu (but not interactively) for
65 # SunOS4, it only appears once. Don't worry about it, I imagine
66 # dejagnu has just done something to the tty modes.
67 send_gdb "a\n"
68 gdb_expect {
69 -re "^a\r\n(|a\r\n)$" {
70 pass "child process ate our char"
71 }
72 timeout { fail "echo a (timeout)" }
73 eof { fail "echo a (eof)" }
74 }
75 # Wait until the program is in the read system call again.
76 sleep 2
77
78 # Cntrl-c may fail for simulator targets running on a BSD host.
79 # This is the result of a combination of the read syscall
80 # being restarted and gdb capturing the cntrl-c signal.
81
82 # Cntrl-c may fail for simulator targets on slow hosts.
83 # This is because there is a race condition between entering
84 # the read and delivering the cntrl-c.
85
86 send_gdb "\003"
87 gdb_expect {
88 -re "Program received signal SIGINT.*$gdb_prompt $" {
89 pass "send_gdb control C"
90 }
91 -re ".*$gdb_prompt $" { fail "send_gdb control C" }
92 timeout { fail "send_gdb control C (timeout)" }
93 eof { fail "send_gdb control C (eof)" }
94 }
95
96 send_gdb "p func1 ()\n"
97 gdb_expect {
98 -re " = 4.*$gdb_prompt $" { pass "call function when asleep" }
92b8ae91 99 -re ".*Program received signal SIG(SEGV|ILL).*$gdb_prompt $" {
c906108c
SS
100 setup_xfail "i*86-pc-linux*-gnu*"
101 fail "child died when we called func1, skipped rest of tests"
102 return
103 }
085dd6e6
JM
104 -re "$gdb_prompt $" {
105 # On HPUX-11.0 'send "p func1 ()"' above
106 # terminates the program. A defect is pending on this
107 # issue [defect #DTS CHFts24203]. Hence calling setup_xfail
108 # below.
a0b3c4fd 109 setup_xfail "hppa*-*-*11*" CHFts24203
085dd6e6
JM
110 fail "call function when asleep (wrong output)"
111 }
c906108c
SS
112 default {
113
114 # This fail probably happens whenever we use /proc (we
115 # don't use PRSABORT), but apparently also happens on
116 # other machines as well.
117
118 setup_xfail "sparc*-*-solaris2*"
119 setup_xfail "mips-*-ultrix*"
c906108c
SS
120 setup_xfail "i*86-*-solaris2*"
121 setup_xfail "*-*-sysv4*"
122 setup_xfail "vax-*-*"
123 setup_xfail "alpha-*-*"
8afa723e 124 setup_xfail "*-*-*bsd*"
c906108c
SS
125 setup_xfail "*-*-irix*"
126 setup_xfail "*-*-hpux*"
127 setup_xfail "*-*-*lynx*"
128 fail "call function when asleep (stays asleep)"
129 # Send_Gdb a newline to wake it up
130 send_gdb "\n"
131 gdb_test "" " = 4" "call function after waking it"
132 }
133# eof { fail "call function when asleep (eof)" }
134 }
135
136 # Now try calling the function again.
137 gdb_test "p func1 ()" " = 4" "call function a second time"
138
139 # And the program should still be doing the same thing.
140 # The optional trailing \r\n is in case we sent a newline above
141 # to wake the program, in which case the program now sends it
142 # back. We check for it either here or in the next gdb_expect
143 # command, because which one it ends up in is timing dependent.
144 send_gdb "continue\n"
145 # For some reason, i386-*-sysv4 gdb fails to issue the Continuing
146 # message, but otherwise appears normal (FIXME).
147 gdb_expect {
148 -re "^continue\r\nContinuing.\r\n(\r\n|)$" { pass "continue" }
149 -re "^continue\r\n\r\n" { fail "continue (missing Continuing.)" }
150 -re "$gdb_prompt $" { fail "continue" }
151 timeout { fail "continue (timeout)" }
152 eof { fail "continue (eof)" }
153 }
154
155 send_gdb "data\n"
156 # The optional leading \r\n is in case we sent a newline above
157 # to wake the program, in which case the program now sends it
158 # back.
085dd6e6
JM
159 # FIXME: The pattern below leads to an expected success on HPUX-11.0
160 # but the success is spurious. Need to provide the right reg.expr.
161 # here.
c906108c
SS
162 gdb_expect {
163 -re "^(\r\n|)data\r\n(|data\r\n)$" { pass "echo data" }
164 timeout { fail "echo data (timeout)" }
165 eof { fail "echo data (eof)" }
166 }
167
168 setup_xfail "i*86-pc-linux*-gnu*"
169 send_gdb "\004"
170 gdb_expect {
171 -re "end of file.*Program exited normally.*$gdb_prompt $" {
89cb06a2 172 pass "send end of file"
c906108c
SS
173 }
174 -re "$gdb_prompt $" { fail "send end of file" }
175 timeout { fail "send end of file (timeout)" }
176 eof { fail "send end of file (eof)" }
177 }
178 }
179}
180return 0