]>
Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 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 | # [email protected] | |
20 | ||
21 | # This file was written by Rob Savoye. ([email protected]) | |
22 | ||
958a4e4c MS |
23 | # Can't do this test without stdio support. |
24 | if [gdb_skip_stdio_test "a2run.exp"] { | |
c906108c SS |
25 | return |
26 | } | |
27 | ||
28 | if $tracelevel then { | |
29 | strace $tracelevel | |
30 | } | |
31 | ||
32 | # | |
33 | # test running programs | |
34 | # | |
35 | set prms_id 0 | |
36 | set bug_id 0 | |
37 | ||
38 | set testfile "run" | |
39 | set srcfile ${testfile}.c | |
40 | set binfile ${objdir}/${subdir}/${testfile} | |
41 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
b60f0898 JB |
42 | untested a2-run.exp |
43 | return -1 | |
c906108c SS |
44 | } |
45 | ||
46 | gdb_exit | |
47 | gdb_start | |
48 | gdb_reinitialize_dir $srcdir/$subdir | |
49 | gdb_load ${binfile} | |
50 | ||
51 | # Run with no arguments. | |
52 | # On VxWorks this justs make sure the program was run. | |
53 | gdb_run_cmd | |
54 | ||
55 | if [istarget "*-*-vxworks*"] then { | |
56 | set timeout 120 | |
57 | verbose "Timeout is now $timeout seconds" 2 | |
58 | gdb_expect { | |
59 | "Program exited normally" { | |
60 | unresolved "run \"$testfile\" with no args" | |
61 | } | |
62 | -re "usage: factorial <number>" { | |
63 | pass "run \"$testfile\" with no args" | |
64 | } | |
65 | timeout { | |
66 | fail "(timeout) run \"$testfile\" with no args" | |
67 | } | |
68 | } | |
69 | set timeout 10 | |
70 | verbose "Timeout is now $timeout seconds" 2 | |
71 | gdb_expect -re "$gdb_prompt $" {} | |
72 | } else { | |
73 | gdb_expect { | |
154189a4 FF |
74 | -re ".*usage: factorial <number>.*Program exited with code 01\.\r\n$gdb_prompt $" { |
75 | pass "run \"$testfile\" with no args" | |
76 | pass "no spurious messages at program exit" | |
77 | } | |
c906108c SS |
78 | -re ".*usage: factorial <number>.*Program exited with code 01.*$gdb_prompt $" { |
79 | pass "run \"$testfile\" with no args" | |
154189a4 FF |
80 | fail "no spurious messages at program exit" |
81 | } | |
82 | -re ".*usage: factorial <number>.* EXIT code 1.*Program exited normally\.\r\n$gdb_prompt $" { | |
83 | pass "run \"$testfile\" with no args (exit wrapper)" | |
84 | pass "no spurious messages at program exit" | |
c906108c | 85 | } |
f1c47eb2 MS |
86 | -re ".*usage: factorial <number>.* EXIT code 1.*Program exited normally.*$gdb_prompt $" { |
87 | pass "run \"$testfile\" with no args (exit wrapper)" | |
154189a4 | 88 | fail "no spurious messages at program exit" |
f1c47eb2 | 89 | } |
c906108c SS |
90 | -re ".*$gdb_prompt $" { |
91 | fail "run \"$testfile\" with no args" | |
92 | verbose "expect_out is $expect_out(buffer)" 2 | |
93 | } | |
94 | timeout { | |
95 | fail "(timeout) run \"$testfile\" no args" | |
96 | } | |
97 | } | |
98 | } | |
154189a4 FF |
99 | |
100 | # The remaining tests don't work for targets can't take arguments... | |
101 | ||
102 | if [target_info exists noargs] then { | |
103 | verbose "Skipping rest of a2-run.exp because of noargs." | |
104 | return | |
105 | } | |
106 | ||
c906108c SS |
107 | # Now run with some arguments |
108 | if [istarget "*-*-vxworks*"] then { | |
109 | send_gdb "run vxmain \"5\"\n" | |
110 | gdb_expect -re "run vxmain \"5\"\r\n" {} | |
111 | set timeout 120 | |
112 | verbose "Timeout is now $timeout seconds" 2 | |
113 | gdb_expect { | |
114 | "Program exited normally" { | |
115 | unresolved "run \"$testfile\" with arg" | |
116 | } | |
117 | "120" { | |
118 | pass "run \"$testfile\" with arg" | |
119 | } | |
120 | timeout { | |
121 | fail "(timeout) run \"$testfile\" with arg" | |
122 | } | |
123 | } | |
124 | set timeout 10 | |
125 | verbose "Timeout is now $timeout seconds" 2 | |
126 | gdb_expect -re "$gdb_prompt $" {} | |
127 | } else { | |
7a292a7a | 128 | setup_xfail "mips-idt-*" "arm-*-coff strongarm-*-coff" |
c906108c SS |
129 | gdb_run_cmd 5 |
130 | gdb_expect { | |
131 | -re ".*120.*$gdb_prompt $"\ | |
132 | { pass "run \"$testfile\" with arg" } | |
133 | -re ".*$gdb_prompt $" { fail "run \"$testfile\" with arg" } | |
134 | timeout { fail "(timeout) run \"$testfile\" with arg" } | |
135 | } | |
136 | } | |
137 | ||
138 | # Run again with same arguments. | |
139 | setup_xfail "mips-idt-*" | |
140 | gdb_run_cmd | |
141 | ||
142 | if [istarget "*-*-vxworks*"] then { | |
143 | set timeout 120 | |
144 | verbose "Timeout is now $timeout seconds" 2 | |
145 | gdb_expect { | |
146 | "Program exited normally" { | |
147 | unresolved "run \"$testfile\" again with same args" | |
148 | } | |
149 | "120" { pass "run \"$testfile\" again with same args" } | |
150 | timeout { fail "(timeout) run \"$testfile\" again with same args" } | |
151 | } | |
152 | set timeout 10 | |
153 | verbose "Timeout is now $timeout seconds" 2 | |
154 | gdb_expect -re "$gdb_prompt $" {} | |
155 | } else { | |
7a292a7a | 156 | setup_xfail "arm-*-coff strongarm-*-coff" |
c906108c SS |
157 | gdb_expect { |
158 | -re ".*120.*$gdb_prompt $"\ | |
159 | { pass "run \"$testfile\" again with same args" } | |
160 | -re ".*$gdb_prompt $" { fail "run \"$testfile\" again with same args" } | |
161 | timeout { fail "(timeout) run \"$testfile\" again with same args" } | |
162 | } | |
163 | } | |
164 | ||
165 | # Use "set args" command to specify no arguments as default and run again. | |
166 | if [istarget "*-*-vxworks*"] then { | |
167 | send_gdb "set args main\n" | |
168 | } else { | |
169 | send_gdb "set args\n" | |
170 | } | |
171 | gdb_expect -re "$gdb_prompt $" | |
172 | ||
173 | gdb_run_cmd | |
174 | ||
175 | if [istarget "*-*-vxworks*"] then { | |
176 | set timeout 120 | |
177 | verbose "Timeout is now $timeout seconds" 2 | |
178 | gdb_expect { | |
179 | "Program exited normally" { | |
180 | unresolved "run after setting args to nil" | |
181 | } | |
182 | "usage: factorial <number>" { | |
183 | pass "run after setting args to nil" | |
184 | } | |
185 | timeout { | |
186 | fail "(timeout) run after setting args to nil" | |
187 | } | |
188 | } | |
189 | set timeout 10 | |
190 | verbose "Timeout is now $timeout seconds" 2 | |
191 | gdb_expect -re "$gdb_prompt $" {} | |
192 | } else { | |
193 | gdb_expect { | |
194 | -re ".*usage: factorial <number>.*$gdb_prompt $" { | |
195 | pass "run after setting args to nil" | |
196 | } | |
197 | -re ".*$gdb_prompt $" { | |
198 | fail "run after setting args to nil" | |
199 | } | |
200 | timeout { | |
201 | fail "(timeout) run after setting args to nil" | |
202 | } | |
203 | } | |
204 | } | |
205 | ||
206 | # Use "set args" command to specify an argument and run again. | |
207 | setup_xfail "mips-idt-*" | |
208 | if [istarget "*-*-vxworks*"] then { | |
209 | send_gdb "set args vxmain \"6\"\n" | |
210 | } else { | |
211 | send_gdb "set args 6\n" | |
212 | } | |
213 | gdb_expect -re "$gdb_prompt $" | |
214 | gdb_run_cmd | |
215 | ||
216 | if [istarget "*-*-vxworks*"] then { | |
217 | set timeout 120 | |
218 | verbose "Timeout is now $timeout seconds" 2 | |
219 | gdb_expect { | |
220 | "Program exited normally" { | |
221 | unresolved "run \"$testfile\" again after setting args" | |
222 | } | |
223 | "720" { | |
224 | pass "run \"$testfile\" again after setting args" | |
225 | } | |
226 | timeout { | |
227 | fail "(timeout) run \"$testfile\" again after setting args" | |
228 | } | |
229 | } | |
230 | set timeout 10 | |
231 | verbose "Timeout is now $timeout seconds" 2 | |
232 | gdb_expect -re "$gdb_prompt $" {} | |
233 | } else { | |
7a292a7a | 234 | setup_xfail "arm-*-coff strongarm-*-coff" |
c906108c SS |
235 | gdb_expect { |
236 | -re ".*720.*$gdb_prompt $" { | |
237 | pass "run \"$testfile\" again after setting args" | |
238 | } | |
239 | -re ".*$gdb_prompt $" { | |
240 | fail "run \"$testfile\" again after setting args" | |
241 | } | |
242 | timeout { | |
243 | fail "(timeout) run \"$testfile\" again after setting args" | |
244 | } | |
245 | } | |
246 | } | |
247 | ||
248 | # GOAL: Test that shell is being used with "run". For remote debugging | |
249 | # targets, there is no guarantee that a "shell" (whatever that is) is used. | |
676a0442 | 250 | if ![is_remote target] then { |
c906108c SS |
251 | send_gdb "run `echo 8`\n" |
252 | gdb_expect { | |
253 | -re "Starting program.*40320.*$gdb_prompt $" { | |
254 | pass "run \"$testfile\" with shell" | |
255 | } | |
256 | -re ".*$gdb_prompt $" { | |
257 | fail "run \"$testfile\" with shell" | |
258 | } | |
259 | timeout { | |
260 | fail "(timeout) run \"$testfile\" with shell" | |
261 | } | |
262 | } | |
263 | } | |
264 | ||
265 | # Reset the default arguments for VxWorks | |
266 | if [istarget "*-*-vxworks*"] then { | |
267 | send_gdb "set args main\n" | |
268 | gdb_expect -re ".*$gdb_prompt $" {} | |
269 | } |