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