gdb/
[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,
7b6bb8da 2# 2007, 2008, 2009, 2010, 2011 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 {
fda326dd 45 "$inferior_exited_re normally" {
c906108c
SS
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 {
fda326dd 60 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.\r\n$gdb_prompt $" {
154189a4
FF
61 pass "run \"$testfile\" with no args"
62 pass "no spurious messages at program exit"
63 }
fda326dd 64 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.*$gdb_prompt $" {
c906108c 65 pass "run \"$testfile\" with no args"
154189a4
FF
66 fail "no spurious messages at program exit"
67 }
fda326dd 68 -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.\r\n$gdb_prompt $" {
154189a4
FF
69 pass "run \"$testfile\" with no args (exit wrapper)"
70 pass "no spurious messages at program exit"
c906108c 71 }
fda326dd 72 -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.*$gdb_prompt $" {
f1c47eb2 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 {
fda326dd 100 "$inferior_exited_re normally" {
c906108c
SS
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 {
4d393d60 114 setup_xfail "mips-idt-*" "arm-*-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 {
fda326dd 132 "$inferior_exited_re normally" {
c906108c
SS
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 {
4d393d60 142 setup_xfail "arm-*-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 {
6acb16a2 153 gdb_test_no_output "set args main"
c906108c 154} else {
6acb16a2 155 gdb_test_no_output "set args"
c906108c 156}
c906108c
SS
157
158gdb_run_cmd
159
160if [istarget "*-*-vxworks*"] then {
161 set timeout 120
162 verbose "Timeout is now $timeout seconds" 2
163 gdb_expect {
fda326dd 164 "$inferior_exited_re normally" {
c906108c
SS
165 unresolved "run after setting args to nil"
166 }
167 "usage: factorial <number>" {
168 pass "run after setting args to nil"
169 }
170 timeout {
171 fail "(timeout) run after setting args to nil"
172 }
173 }
174 set timeout 10
175 verbose "Timeout is now $timeout seconds" 2
176 gdb_expect -re "$gdb_prompt $" {}
177} else {
178 gdb_expect {
179 -re ".*usage: factorial <number>.*$gdb_prompt $" {
180 pass "run after setting args to nil"
181 }
182 -re ".*$gdb_prompt $" {
183 fail "run after setting args to nil"
184 }
185 timeout {
186 fail "(timeout) run after setting args to nil"
187 }
188 }
189}
190
191# Use "set args" command to specify an argument and run again.
192setup_xfail "mips-idt-*"
193if [istarget "*-*-vxworks*"] then {
6acb16a2 194 gdb_test_no_output "set args vxmain \"6\""
c906108c 195} else {
6acb16a2 196 gdb_test_no_output "set args 6"
c906108c 197}
6acb16a2 198
c906108c
SS
199gdb_run_cmd
200
201if [istarget "*-*-vxworks*"] then {
202 set timeout 120
203 verbose "Timeout is now $timeout seconds" 2
204 gdb_expect {
fda326dd 205 "$inferior_exited_re normally" {
c906108c
SS
206 unresolved "run \"$testfile\" again after setting args"
207 }
208 "720" {
209 pass "run \"$testfile\" again after setting args"
210 }
211 timeout {
212 fail "(timeout) run \"$testfile\" again after setting args"
213 }
214 }
215 set timeout 10
216 verbose "Timeout is now $timeout seconds" 2
217 gdb_expect -re "$gdb_prompt $" {}
218} else {
4d393d60 219 setup_xfail "arm-*-coff"
c906108c
SS
220 gdb_expect {
221 -re ".*720.*$gdb_prompt $" {
222 pass "run \"$testfile\" again after setting args"
223 }
224 -re ".*$gdb_prompt $" {
225 fail "run \"$testfile\" again after setting args"
226 }
227 timeout {
228 fail "(timeout) run \"$testfile\" again after setting args"
229 }
230 }
231}
232
233# GOAL: Test that shell is being used with "run". For remote debugging
234# targets, there is no guarantee that a "shell" (whatever that is) is used.
676a0442 235if ![is_remote target] then {
6acb16a2
MS
236 gdb_test "run `echo 8`" \
237 "Starting program.*40320.*" \
238 "run \"$testfile\" with shell"
c906108c
SS
239}
240
241# Reset the default arguments for VxWorks
242if [istarget "*-*-vxworks*"] then {
6acb16a2 243 gdb_test_no_output "set args main"
c906108c 244}
This page took 1.090485 seconds and 4 git commands to generate.