This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / interrupt.exp
1 # Copyright (C) 1994, 1995 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 if [host_info exists name] {
21 if [board_info host exists gdb,nointerrupts] {
22 verbose "Skipping interrupt.exp because of nointerrupts."
23 continue
24 }
25 }
26
27 if $tracelevel then {
28 strace $tracelevel
29 }
30
31 set prms_id 0
32 set bug_id 0
33
34 set testfile interrupt
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
38 perror "Couldn't compile ${srcfile}"
39 return -1
40 }
41
42 if [target_info exists gdb,noinferiorio] {
43 verbose "Skipping interrupt.exp because of noinferiorio."
44 return
45 }
46
47 gdb_start
48
49
50 if ![file exists $binfile] then {
51 perror "$binfile does not exist."
52 return 0
53 } else {
54 gdb_reinitialize_dir $srcdir/$subdir
55 gdb_load $binfile
56 # Hope this is unix :-)
57 gdb_test "shell stty intr '^C'" "" \
58 "set interrupt character in interrupt.exp"
59 if [runto_main] then {
60 send_gdb "continue\n"
61 expect {
62 -re "\r\ntalk to me baby\r\n$" {
63 pass "child process is alive"
64 }
65 timeout { fail "run (timeout)" }
66 eof { fail "run (eof)" }
67 }
68 # This should appear twice, once for the echo and once for the
69 # program's output. Under dejagnu (but not interactively) for
70 # SunOS4, it only appears once. Don't worry about it, I imagine
71 # dejagnu has just done something to the tty modes.
72 send_gdb "a\n"
73 expect {
74 -re "^a\r\n(|a\r\n)$" {
75 pass "child process ate our char"
76 }
77 timeout { fail "echo a (timeout)" }
78 eof { fail "echo a (eof)" }
79 }
80 # Wait until the program is in the read system call again.
81 sleep 2
82
83 send_gdb "\003"
84 expect {
85 -re "Program received signal SIGINT.*$gdb_prompt $" {
86 pass "send_gdb control C"
87 }
88 -re ".*$gdb_prompt $" { fail "send_gdb control C" }
89 timeout { fail "send_gdb control C (timeout)" }
90 eof { fail "send_gdb control C (eof)" }
91 }
92
93 send_gdb "p func1 ()\n"
94 expect {
95 -re " = 4.*$gdb_prompt $" { pass "call function when asleep" }
96 -re ".*Program received signal SIGSEGV.*$gdb_prompt $" {
97 setup_xfail "i*86-pc-linux*-gnu"
98 fail "child died when we called func1, skipped rest of tests"
99 return
100 }
101 -re "$gdb_prompt $" { fail "call function when asleep (wrong output)" }
102 default {
103
104 # This fail probably happens whenever we use /proc (we
105 # don't use PRSABORT), but apparently also happens on
106 # other machines as well.
107
108 setup_xfail "sparc*-*-solaris2*"
109 setup_xfail "mips-*-ultrix*"
110 setup_xfail "hppa*-*-*"
111 setup_xfail "i386*-*-bsd*"
112 setup_xfail "*-*-sysv4*"
113 setup_xfail "vax-*-*"
114 setup_xfail "alpha-*-*"
115 setup_xfail "*-*-irix*"
116 setup_xfail "*-*-hpux*"
117 setup_xfail "*-*-*lynx*"
118 fail "call function when asleep (stays asleep)"
119 # Send_Gdb a newline to wake it up
120 send_gdb "\n"
121 gdb_test "" " = 4" "call function after waking it"
122 }
123 # eof { fail "call function when asleep (eof)" }
124 }
125
126 # Now try calling the function again.
127 gdb_test "p func1 ()" " = 4" "call function a second time"
128
129 # And the program should still be doing the same thing.
130 # The optional trailing \r\n is in case we sent a newline above
131 # to wake the program, in which case the program now sends it
132 # back. We check for it either here or in the next expect
133 # command, because which one it ends up in is timing dependent.
134 send_gdb "continue\n"
135 # For some reason, i386-*-sysv4 gdb fails to issue the Continuing
136 # message, but otherwise appears normal (FIXME).
137 expect {
138 -re "^continue\r\nContinuing.\r\n(\r\n|)$" { pass "continue" }
139 -re "^continue\r\n\r\n" { fail "continue (missing Continuing.)" }
140 -re "$gdb_prompt $" { fail "continue" }
141 timeout { fail "continue (timeout)" }
142 eof { fail "continue (eof)" }
143 }
144
145 send_gdb "data\n"
146 # The optional leading \r\n is in case we sent a newline above
147 # to wake the program, in which case the program now sends it
148 # back.
149 expect {
150 -re "^(\r\n|)data\r\n(|data\r\n)$" { pass "echo data" }
151 timeout { fail "echo data (timeout)" }
152 eof { fail "echo data (eof)" }
153 }
154
155 setup_xfail "i*86-pc-linux*-gnu"
156 send_gdb "\004"
157 expect {
158 -re "end of file.*Program exited normally.*$gdb_prompt $" {
159 pass "send_gdb end of file"
160 }
161 -re "$gdb_prompt $" { fail "send end of file" }
162 timeout { fail "send end of file (timeout)" }
163 eof { fail "send end of file (eof)" }
164 }
165 }
166 }
167 return 0
This page took 0.033679 seconds and 5 git commands to generate.