]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/a2-run.exp
c8467dc31b56c4fd43c8790ecc365bbdec40e340
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / a2-run.exp
1 # Copyright 1988-2013 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 # This file was written by Rob Savoye. (rob@cygnus.com)
17
18 # Can't do this test without stdio support.
19 if [gdb_skip_stdio_test "a2run.exp"] {
20 return
21 }
22
23 #
24 # test running programs
25 #
26
27 standard_testfile run.c
28
29 if { [prepare_for_testing ${testfile}.exp $testfile $srcfile] } {
30 return -1
31 }
32
33 # Run with no arguments.
34 # On VxWorks this justs make sure the program was run.
35 gdb_run_cmd
36
37 if [istarget "*-*-vxworks*"] then {
38 set timeout 120
39 verbose "Timeout is now $timeout seconds" 2
40 gdb_expect {
41 "$inferior_exited_re normally" {
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 {
56 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.\r\n$gdb_prompt $" {
57 pass "run \"$testfile\" with no args"
58 pass "no spurious messages at program exit"
59 }
60 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.*$gdb_prompt $" {
61 pass "run \"$testfile\" with no args"
62 fail "no spurious messages at program exit"
63 }
64 -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.\r\n$gdb_prompt $" {
65 pass "run \"$testfile\" with no args (exit wrapper)"
66 pass "no spurious messages at program exit"
67 }
68 -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.*$gdb_prompt $" {
69 pass "run \"$testfile\" with no args (exit wrapper)"
70 fail "no spurious messages at program exit"
71 }
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 }
81
82 # The remaining tests don't work for targets can't take arguments...
83
84 if [target_info exists noargs] then {
85 verbose "Skipping rest of a2-run.exp because of noargs."
86 return
87 }
88
89 # Now run with some arguments
90 if [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 {
96 "$inferior_exited_re normally" {
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 {
110 setup_xfail "arm-*-coff"
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.
121 gdb_run_cmd
122
123 if [istarget "*-*-vxworks*"] then {
124 set timeout 120
125 verbose "Timeout is now $timeout seconds" 2
126 gdb_expect {
127 "$inferior_exited_re normally" {
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 {
137 setup_xfail "arm-*-coff"
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.
147 if [istarget "*-*-vxworks*"] then {
148 gdb_test_no_output "set args main"
149 } else {
150 gdb_test_no_output "set args"
151 }
152
153 gdb_run_cmd
154
155 if [istarget "*-*-vxworks*"] then {
156 set timeout 120
157 verbose "Timeout is now $timeout seconds" 2
158 gdb_expect {
159 "$inferior_exited_re normally" {
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.
187 if [istarget "*-*-vxworks*"] then {
188 gdb_test_no_output "set args vxmain \"6\""
189 } else {
190 gdb_test_no_output "set args 6"
191 }
192
193 gdb_run_cmd
194
195 if [istarget "*-*-vxworks*"] then {
196 set timeout 120
197 verbose "Timeout is now $timeout seconds" 2
198 gdb_expect {
199 "$inferior_exited_re normally" {
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 {
213 setup_xfail "arm-*-coff"
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.
229 if ![is_remote target] then {
230 gdb_test "run `echo 8`" \
231 "Starting program.*40320.*" \
232 "run \"$testfile\" with shell"
233 }
234
235 # Reset the default arguments for VxWorks
236 if [istarget "*-*-vxworks*"] then {
237 gdb_test_no_output "set args main"
238 }