Commit | Line | Data |
---|---|---|
0b302171 JB |
1 | # Copyright 1988, 1990-1992, 1994-1997, 1999-2000, 2007-2012 Free |
2 | # 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. (rob@cygnus.com) |
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 | ||
c906108c SS |
24 | # |
25 | # test running programs | |
26 | # | |
c906108c | 27 | |
aa81e255 JK |
28 | set testfile a2-run |
29 | if { [prepare_for_testing ${testfile}.exp $testfile run.c] } { | |
b60f0898 | 30 | return -1 |
c906108c SS |
31 | } |
32 | ||
c906108c SS |
33 | # Run with no arguments. |
34 | # On VxWorks this justs make sure the program was run. | |
35 | gdb_run_cmd | |
36 | ||
37 | if [istarget "*-*-vxworks*"] then { | |
38 | set timeout 120 | |
39 | verbose "Timeout is now $timeout seconds" 2 | |
40 | gdb_expect { | |
fda326dd | 41 | "$inferior_exited_re normally" { |
c906108c SS |
42 | unresolved "run \"$testfile\" with no args" |
43 | } | |
44 | -re "usage: factorial <number>" { | |
45 | pass "run \"$testfile\" with no args" | |
46 | } | |
47 | timeout { | |
48 | fail "(timeout) run \"$testfile\" with no args" | |
49 | } | |
50 | } | |
51 | set timeout 10 | |
52 | verbose "Timeout is now $timeout seconds" 2 | |
53 | gdb_expect -re "$gdb_prompt $" {} | |
54 | } else { | |
55 | gdb_expect { | |
fda326dd | 56 | -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.\r\n$gdb_prompt $" { |
154189a4 FF |
57 | pass "run \"$testfile\" with no args" |
58 | pass "no spurious messages at program exit" | |
59 | } | |
fda326dd | 60 | -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.*$gdb_prompt $" { |
c906108c | 61 | pass "run \"$testfile\" with no args" |
154189a4 FF |
62 | fail "no spurious messages at program exit" |
63 | } | |
fda326dd | 64 | -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.\r\n$gdb_prompt $" { |
154189a4 FF |
65 | pass "run \"$testfile\" with no args (exit wrapper)" |
66 | pass "no spurious messages at program exit" | |
c906108c | 67 | } |
fda326dd | 68 | -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.*$gdb_prompt $" { |
f1c47eb2 | 69 | pass "run \"$testfile\" with no args (exit wrapper)" |
154189a4 | 70 | fail "no spurious messages at program exit" |
f1c47eb2 | 71 | } |
c906108c SS |
72 | -re ".*$gdb_prompt $" { |
73 | fail "run \"$testfile\" with no args" | |
74 | verbose "expect_out is $expect_out(buffer)" 2 | |
75 | } | |
76 | timeout { | |
77 | fail "(timeout) run \"$testfile\" no args" | |
78 | } | |
79 | } | |
80 | } | |
154189a4 FF |
81 | |
82 | # The remaining tests don't work for targets can't take arguments... | |
83 | ||
84 | if [target_info exists noargs] then { | |
85 | verbose "Skipping rest of a2-run.exp because of noargs." | |
86 | return | |
87 | } | |
88 | ||
c906108c SS |
89 | # Now run with some arguments |
90 | if [istarget "*-*-vxworks*"] then { | |
91 | send_gdb "run vxmain \"5\"\n" | |
92 | gdb_expect -re "run vxmain \"5\"\r\n" {} | |
93 | set timeout 120 | |
94 | verbose "Timeout is now $timeout seconds" 2 | |
95 | gdb_expect { | |
fda326dd | 96 | "$inferior_exited_re normally" { |
c906108c SS |
97 | unresolved "run \"$testfile\" with arg" |
98 | } | |
99 | "120" { | |
100 | pass "run \"$testfile\" with arg" | |
101 | } | |
102 | timeout { | |
103 | fail "(timeout) run \"$testfile\" with arg" | |
104 | } | |
105 | } | |
106 | set timeout 10 | |
107 | verbose "Timeout is now $timeout seconds" 2 | |
108 | gdb_expect -re "$gdb_prompt $" {} | |
109 | } else { | |
cc30c4bd | 110 | setup_xfail "arm-*-coff" |
c906108c SS |
111 | gdb_run_cmd 5 |
112 | gdb_expect { | |
113 | -re ".*120.*$gdb_prompt $"\ | |
114 | { pass "run \"$testfile\" with arg" } | |
115 | -re ".*$gdb_prompt $" { fail "run \"$testfile\" with arg" } | |
116 | timeout { fail "(timeout) run \"$testfile\" with arg" } | |
117 | } | |
118 | } | |
119 | ||
120 | # Run again with same arguments. | |
c906108c SS |
121 | gdb_run_cmd |
122 | ||
123 | if [istarget "*-*-vxworks*"] then { | |
124 | set timeout 120 | |
125 | verbose "Timeout is now $timeout seconds" 2 | |
126 | gdb_expect { | |
fda326dd | 127 | "$inferior_exited_re normally" { |
c906108c SS |
128 | unresolved "run \"$testfile\" again with same args" |
129 | } | |
130 | "120" { pass "run \"$testfile\" again with same args" } | |
131 | timeout { fail "(timeout) run \"$testfile\" again with same args" } | |
132 | } | |
133 | set timeout 10 | |
134 | verbose "Timeout is now $timeout seconds" 2 | |
135 | gdb_expect -re "$gdb_prompt $" {} | |
136 | } else { | |
4d393d60 | 137 | setup_xfail "arm-*-coff" |
c906108c SS |
138 | gdb_expect { |
139 | -re ".*120.*$gdb_prompt $"\ | |
140 | { pass "run \"$testfile\" again with same args" } | |
141 | -re ".*$gdb_prompt $" { fail "run \"$testfile\" again with same args" } | |
142 | timeout { fail "(timeout) run \"$testfile\" again with same args" } | |
143 | } | |
144 | } | |
145 | ||
146 | # Use "set args" command to specify no arguments as default and run again. | |
147 | if [istarget "*-*-vxworks*"] then { | |
6acb16a2 | 148 | gdb_test_no_output "set args main" |
c906108c | 149 | } else { |
6acb16a2 | 150 | gdb_test_no_output "set args" |
c906108c | 151 | } |
c906108c SS |
152 | |
153 | gdb_run_cmd | |
154 | ||
155 | if [istarget "*-*-vxworks*"] then { | |
156 | set timeout 120 | |
157 | verbose "Timeout is now $timeout seconds" 2 | |
158 | gdb_expect { | |
fda326dd | 159 | "$inferior_exited_re normally" { |
c906108c SS |
160 | unresolved "run after setting args to nil" |
161 | } | |
162 | "usage: factorial <number>" { | |
163 | pass "run after setting args to nil" | |
164 | } | |
165 | timeout { | |
166 | fail "(timeout) run after setting args to nil" | |
167 | } | |
168 | } | |
169 | set timeout 10 | |
170 | verbose "Timeout is now $timeout seconds" 2 | |
171 | gdb_expect -re "$gdb_prompt $" {} | |
172 | } else { | |
173 | gdb_expect { | |
174 | -re ".*usage: factorial <number>.*$gdb_prompt $" { | |
175 | pass "run after setting args to nil" | |
176 | } | |
177 | -re ".*$gdb_prompt $" { | |
178 | fail "run after setting args to nil" | |
179 | } | |
180 | timeout { | |
181 | fail "(timeout) run after setting args to nil" | |
182 | } | |
183 | } | |
184 | } | |
185 | ||
186 | # Use "set args" command to specify an argument and run again. | |
c906108c | 187 | if [istarget "*-*-vxworks*"] then { |
6acb16a2 | 188 | gdb_test_no_output "set args vxmain \"6\"" |
c906108c | 189 | } else { |
6acb16a2 | 190 | gdb_test_no_output "set args 6" |
c906108c | 191 | } |
6acb16a2 | 192 | |
c906108c SS |
193 | gdb_run_cmd |
194 | ||
195 | if [istarget "*-*-vxworks*"] then { | |
196 | set timeout 120 | |
197 | verbose "Timeout is now $timeout seconds" 2 | |
198 | gdb_expect { | |
fda326dd | 199 | "$inferior_exited_re normally" { |
c906108c SS |
200 | unresolved "run \"$testfile\" again after setting args" |
201 | } | |
202 | "720" { | |
203 | pass "run \"$testfile\" again after setting args" | |
204 | } | |
205 | timeout { | |
206 | fail "(timeout) run \"$testfile\" again after setting args" | |
207 | } | |
208 | } | |
209 | set timeout 10 | |
210 | verbose "Timeout is now $timeout seconds" 2 | |
211 | gdb_expect -re "$gdb_prompt $" {} | |
212 | } else { | |
4d393d60 | 213 | setup_xfail "arm-*-coff" |
c906108c SS |
214 | gdb_expect { |
215 | -re ".*720.*$gdb_prompt $" { | |
216 | pass "run \"$testfile\" again after setting args" | |
217 | } | |
218 | -re ".*$gdb_prompt $" { | |
219 | fail "run \"$testfile\" again after setting args" | |
220 | } | |
221 | timeout { | |
222 | fail "(timeout) run \"$testfile\" again after setting args" | |
223 | } | |
224 | } | |
225 | } | |
226 | ||
227 | # GOAL: Test that shell is being used with "run". For remote debugging | |
228 | # targets, there is no guarantee that a "shell" (whatever that is) is used. | |
676a0442 | 229 | if ![is_remote target] then { |
6acb16a2 MS |
230 | gdb_test "run `echo 8`" \ |
231 | "Starting program.*40320.*" \ | |
232 | "run \"$testfile\" with shell" | |
c906108c SS |
233 | } |
234 | ||
235 | # Reset the default arguments for VxWorks | |
236 | if [istarget "*-*-vxworks*"] then { | |
6acb16a2 | 237 | gdb_test_no_output "set args main" |
c906108c | 238 | } |