This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / a2-run.exp
1 # Copyright (C) 1988, 1990, 1991, 1992, 1994 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
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
22 # These tests don't work for targets can't take arguments...
23
24 if [target_info exists gdb,noargs] then {
25 verbose "Skipping a2-run.exp because of noargs."
26 return
27 }
28
29 if [target_info exists gdb,noinferiorio] {
30 verbose "Skipping a2-run.exp because of noinferiorio."
31 return
32 }
33
34 if $tracelevel then {
35 strace $tracelevel
36 }
37
38 #
39 # test running programs
40 #
41 set prms_id 0
42 set bug_id 0
43
44 set testfile "run"
45 set srcfile ${testfile}.c
46 set binfile ${objdir}/${subdir}/${testfile}
47 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
48 perror "Couldn't compile ${srcfile}"
49 return -1
50 }
51
52 gdb_exit
53 gdb_start
54 gdb_reinitialize_dir $srcdir/$subdir
55 gdb_load ${binfile}
56
57 # Run with no arguments.
58 # On VxWorks this justs make sure the program was run.
59 gdb_run_cmd
60
61 if [istarget "*-*-vxworks*"] then {
62 set timeout 120
63 verbose "Timeout is now $timeout seconds" 2
64 expect {
65 -i $gdb_spawn_id "Program exited normally" {
66 unresolved "run \"$testfile\" with no args"
67 }
68 -i $gdb_spawn_id -re "usage: factorial <number>" {
69 pass "run \"$testfile\" with no args"
70 }
71 timeout {
72 fail "(timeout) run \"$testfile\" with no args"
73 }
74 }
75 set timeout 10
76 verbose "Timeout is now $timeout seconds" 2
77 expect -re "$gdb_prompt $" {}
78 } else {
79 expect {
80 -re ".*usage: factorial <number>.*Program exited with code 01.*$gdb_prompt $" {
81 pass "run \"$testfile\" with no args"
82 }
83 -re ".*$gdb_prompt $" {
84 fail "run \"$testfile\" with no args"
85 verbose "expect_out is $expect_out(buffer)" 2
86 }
87 timeout {
88 fail "(timeout) run \"$testfile\" no args"
89 }
90 }
91 }
92 # Now run with some arguments
93 if [istarget "*-*-vxworks*"] then {
94 send_gdb "run vxmain \"5\"\n"
95 expect -re "run vxmain \"5\"\r\n" {}
96 set timeout 120
97 verbose "Timeout is now $timeout seconds" 2
98 expect {
99 -i $shell_id "Program exited normally" {
100 unresolved "run \"$testfile\" with arg"
101 }
102 -i $shell_id "120" {
103 pass "run \"$testfile\" with arg"
104 }
105 timeout {
106 fail "(timeout) run \"$testfile\" with arg"
107 }
108 }
109 set timeout 10
110 verbose "Timeout is now $timeout seconds" 2
111 expect -re "$gdb_prompt $" {}
112 } else {
113 setup_xfail "mips-idt-*"
114 gdb_run_cmd 5
115 expect {
116 -re ".*120.*$gdb_prompt $"\
117 { pass "run \"$testfile\" with arg" }
118 -re ".*$gdb_prompt $" { fail "run \"$testfile\" with arg" }
119 timeout { fail "(timeout) run \"$testfile\" with arg" }
120 }
121 }
122
123 # Run again with same arguments.
124 setup_xfail "mips-idt-*"
125 gdb_run_cmd
126
127 if [istarget "*-*-vxworks*"] then {
128 set timeout 120
129 verbose "Timeout is now $timeout seconds" 2
130 expect {
131 -i $shell_id "Program exited normally" {
132 unresolved "run \"$testfile\" again with same args"
133 }
134 -i $shell_id "120" { pass "run \"$testfile\" again with same args" }
135 timeout { fail "(timeout) run \"$testfile\" again with same args" }
136 }
137 set timeout 10
138 verbose "Timeout is now $timeout seconds" 2
139 expect -re "$gdb_prompt $" {}
140 } else {
141 expect {
142 -re ".*120.*$gdb_prompt $"\
143 { pass "run \"$testfile\" again with same args" }
144 -re ".*$gdb_prompt $" { fail "run \"$testfile\" again with same args" }
145 timeout { fail "(timeout) run \"$testfile\" again with same args" }
146 }
147 }
148
149 # Use "set args" command to specify no arguments as default and run again.
150 if [istarget "*-*-vxworks*"] then {
151 send_gdb "set args main\n"
152 } else {
153 send_gdb "set args\n"
154 }
155 expect -re "$gdb_prompt $"
156
157 gdb_run_cmd
158
159 if [istarget "*-*-vxworks*"] then {
160 set timeout 120
161 verbose "Timeout is now $timeout seconds" 2
162 expect {
163 -i $shell_id "Program exited normally" {
164 unresolved "run after setting args to nil"
165 }
166 -i $shell_id "usage: factorial <number>" {
167 pass "run after setting args to nil"
168 }
169 timeout {
170 fail "(timeout) run after setting args to nil"
171 }
172 }
173 set timeout 10
174 verbose "Timeout is now $timeout seconds" 2
175 expect -re "$gdb_prompt $" {}
176 } else {
177 expect {
178 -re ".*usage: factorial <number>.*$gdb_prompt $" {
179 pass "run after setting args to nil"
180 }
181 -re ".*$gdb_prompt $" {
182 fail "run after setting args to nil"
183 }
184 timeout {
185 fail "(timeout) run after setting args to nil"
186 }
187 }
188 }
189
190 # Use "set args" command to specify an argument and run again.
191 setup_xfail "mips-idt-*"
192 if [istarget "*-*-vxworks*"] then {
193 send_gdb "set args vxmain \"6\"\n"
194 } else {
195 send_gdb "set args 6\n"
196 }
197 expect -re "$gdb_prompt $"
198 gdb_run_cmd
199
200 if [istarget "*-*-vxworks*"] then {
201 set timeout 120
202 verbose "Timeout is now $timeout seconds" 2
203 expect {
204 -i $shell_id "Program exited normally" {
205 unresolved "run \"$testfile\" again after setting args"
206 }
207 -i $shell_id "720" {
208 pass "run \"$testfile\" again after setting args"
209 }
210 timeout {
211 fail "(timeout) run \"$testfile\" again after setting args"
212 }
213 }
214 set timeout 10
215 verbose "Timeout is now $timeout seconds" 2
216 expect -re "$gdb_prompt $" {}
217 } else {
218 expect {
219 -re ".*720.*$gdb_prompt $" {
220 pass "run \"$testfile\" again after setting args"
221 }
222 -re ".*$gdb_prompt $" {
223 fail "run \"$testfile\" again after setting args"
224 }
225 timeout {
226 fail "(timeout) run \"$testfile\" again after setting args"
227 }
228 }
229 }
230
231 # GOAL: Test that shell is being used with "run". For remote debugging
232 # targets, there is no guarantee that a "shell" (whatever that is) is used.
233 if [isnative] then {
234 send_gdb "run `echo 8`\n"
235 expect {
236 -re "Starting program.*40320.*$gdb_prompt $" {
237 pass "run \"$testfile\" with shell"
238 }
239 -re ".*$gdb_prompt $" {
240 fail "run \"$testfile\" with shell"
241 }
242 timeout {
243 fail "(timeout) run \"$testfile\" with shell"
244 }
245 }
246 }
247
248 # Reset the default arguments for VxWorks
249 if [istarget "*-*-vxworks*"] then {
250 send_gdb "set args main\n"
251 expect -re ".*$gdb_prompt $" {}
252 }
This page took 0.036343 seconds and 5 git commands to generate.