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