Commit | Line | Data |
---|---|---|
c906108c SS |
1 | # Copyright (C) 1994, 1995, 1997, 1998 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 [target_info exists gdb,noinferiorio] { | |
28 | verbose "Skipping interrupt.exp because of noinferiorio." | |
29 | return | |
30 | } | |
31 | ||
32 | if $tracelevel then { | |
33 | strace $tracelevel | |
34 | } | |
35 | ||
36 | set prms_id 0 | |
37 | set bug_id 0 | |
38 | ||
39 | set testfile interrupt | |
40 | set srcfile ${testfile}.c | |
41 | set binfile ${objdir}/${subdir}/${testfile} | |
42 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
43 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
44 | } | |
45 | ||
46 | gdb_start | |
47 | ||
48 | ||
49 | if ![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" } | |
103 | -re ".*Program received signal SIGSEGV.*$gdb_prompt $" { | |
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 "i386*-*-bsd*" |
125 | setup_xfail "i*86-*-solaris2*" | |
126 | setup_xfail "*-*-sysv4*" | |
127 | setup_xfail "vax-*-*" | |
128 | setup_xfail "alpha-*-*" | |
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 $" { | |
176 | pass "send_gdb end of file" | |
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 | } | |
184 | return 0 |