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