]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/a2-run.exp
Updated copyright notices for most files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / a2-run.exp
CommitLineData
9b254dd1
DJ
1# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2000,
2# 2007, 2008 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
SS
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
958a4e4c
MS
22# Can't do this test without stdio support.
23if [gdb_skip_stdio_test "a2run.exp"] {
c906108c
SS
24 return
25}
26
27if $tracelevel then {
28 strace $tracelevel
29}
30
31#
32# test running programs
33#
34set prms_id 0
35set bug_id 0
36
37set testfile "run"
38set srcfile ${testfile}.c
39set binfile ${objdir}/${subdir}/${testfile}
40if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
41 untested a2-run.exp
42 return -1
c906108c
SS
43}
44
45gdb_exit
46gdb_start
47gdb_reinitialize_dir $srcdir/$subdir
48gdb_load ${binfile}
49
50# Run with no arguments.
51# On VxWorks this justs make sure the program was run.
52gdb_run_cmd
53
54if [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 {
154189a4
FF
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 }
c906108c
SS
77 -re ".*usage: factorial <number>.*Program exited with code 01.*$gdb_prompt $" {
78 pass "run \"$testfile\" with no args"
154189a4
FF
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"
c906108c 84 }
f1c47eb2
MS
85 -re ".*usage: factorial <number>.* EXIT code 1.*Program exited normally.*$gdb_prompt $" {
86 pass "run \"$testfile\" with no args (exit wrapper)"
154189a4 87 fail "no spurious messages at program exit"
f1c47eb2 88 }
c906108c
SS
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}
154189a4
FF
98
99# The remaining tests don't work for targets can't take arguments...
100
101if [target_info exists noargs] then {
102 verbose "Skipping rest of a2-run.exp because of noargs."
103 return
104}
105
c906108c
SS
106# Now run with some arguments
107if [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 {
7a292a7a 127 setup_xfail "mips-idt-*" "arm-*-coff strongarm-*-coff"
c906108c
SS
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.
138setup_xfail "mips-idt-*"
139gdb_run_cmd
140
141if [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 {
7a292a7a 155 setup_xfail "arm-*-coff strongarm-*-coff"
c906108c
SS
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.
165if [istarget "*-*-vxworks*"] then {
166 send_gdb "set args main\n"
167} else {
168 send_gdb "set args\n"
169}
170gdb_expect -re "$gdb_prompt $"
171
172gdb_run_cmd
173
174if [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.
206setup_xfail "mips-idt-*"
207if [istarget "*-*-vxworks*"] then {
208 send_gdb "set args vxmain \"6\"\n"
209} else {
210 send_gdb "set args 6\n"
211}
212gdb_expect -re "$gdb_prompt $"
213gdb_run_cmd
214
215if [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 {
7a292a7a 233 setup_xfail "arm-*-coff strongarm-*-coff"
c906108c
SS
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.
676a0442 249if ![is_remote target] then {
c906108c
SS
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
265if [istarget "*-*-vxworks*"] then {
266 send_gdb "set args main\n"
267 gdb_expect -re ".*$gdb_prompt $" {}
268}