[Committing the `catch syscall' patch for ARM, from Samuel Bronson.]
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / a2-run.exp
CommitLineData
28e7fd62 1# Copyright 1988-2013 Free Software Foundation, Inc.
c906108c
SS
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 15
c906108c
SS
16# This file was written by Rob Savoye. (rob@cygnus.com)
17
958a4e4c
MS
18# Can't do this test without stdio support.
19if [gdb_skip_stdio_test "a2run.exp"] {
c906108c
SS
20 return
21}
22
c906108c
SS
23#
24# test running programs
25#
c906108c 26
a64d2530
TT
27standard_testfile run.c
28
29if { [prepare_for_testing ${testfile}.exp $testfile $srcfile] } {
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.
35gdb_run_cmd
36
37if [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
84if [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
90if [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
121gdb_run_cmd
122
123if [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.
147if [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
153gdb_run_cmd
154
155if [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 187if [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
193gdb_run_cmd
194
195if [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 229if ![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
236if [istarget "*-*-vxworks*"] then {
6acb16a2 237 gdb_test_no_output "set args main"
c906108c 238}
This page took 1.366881 seconds and 4 git commands to generate.