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 | } | |
108 | -re "$gdb_prompt $" { fail "call function when asleep (wrong output)" } | |
109 | default { | |
110 | ||
111 | # This fail probably happens whenever we use /proc (we | |
112 | # don't use PRSABORT), but apparently also happens on | |
113 | # other machines as well. | |
114 | ||
115 | setup_xfail "sparc*-*-solaris2*" | |
116 | setup_xfail "mips-*-ultrix*" | |
117 | setup_xfail "hppa*-*-*" | |
118 | setup_xfail "i386*-*-bsd*" | |
119 | setup_xfail "i*86-*-solaris2*" | |
120 | setup_xfail "*-*-sysv4*" | |
121 | setup_xfail "vax-*-*" | |
122 | setup_xfail "alpha-*-*" | |
123 | setup_xfail "*-*-irix*" | |
124 | setup_xfail "*-*-hpux*" | |
125 | setup_xfail "*-*-*lynx*" | |
126 | fail "call function when asleep (stays asleep)" | |
127 | # Send_Gdb a newline to wake it up | |
128 | send_gdb "\n" | |
129 | gdb_test "" " = 4" "call function after waking it" | |
130 | } | |
131 | # eof { fail "call function when asleep (eof)" } | |
132 | } | |
133 | ||
134 | # Now try calling the function again. | |
135 | gdb_test "p func1 ()" " = 4" "call function a second time" | |
136 | ||
137 | # And the program should still be doing the same thing. | |
138 | # The optional trailing \r\n is in case we sent a newline above | |
139 | # to wake the program, in which case the program now sends it | |
140 | # back. We check for it either here or in the next gdb_expect | |
141 | # command, because which one it ends up in is timing dependent. | |
142 | send_gdb "continue\n" | |
143 | # For some reason, i386-*-sysv4 gdb fails to issue the Continuing | |
144 | # message, but otherwise appears normal (FIXME). | |
145 | gdb_expect { | |
146 | -re "^continue\r\nContinuing.\r\n(\r\n|)$" { pass "continue" } | |
147 | -re "^continue\r\n\r\n" { fail "continue (missing Continuing.)" } | |
148 | -re "$gdb_prompt $" { fail "continue" } | |
149 | timeout { fail "continue (timeout)" } | |
150 | eof { fail "continue (eof)" } | |
151 | } | |
152 | ||
153 | send_gdb "data\n" | |
154 | # The optional leading \r\n is in case we sent a newline above | |
155 | # to wake the program, in which case the program now sends it | |
156 | # back. | |
157 | gdb_expect { | |
158 | -re "^(\r\n|)data\r\n(|data\r\n)$" { pass "echo data" } | |
159 | timeout { fail "echo data (timeout)" } | |
160 | eof { fail "echo data (eof)" } | |
161 | } | |
162 | ||
163 | setup_xfail "i*86-pc-linux*-gnu*" | |
164 | send_gdb "\004" | |
165 | gdb_expect { | |
166 | -re "end of file.*Program exited normally.*$gdb_prompt $" { | |
167 | pass "send_gdb end of file" | |
168 | } | |
169 | -re "$gdb_prompt $" { fail "send end of file" } | |
170 | timeout { fail "send end of file (timeout)" } | |
171 | eof { fail "send end of file (eof)" } | |
172 | } | |
173 | } | |
174 | } | |
175 | return 0 |