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