* gdb.base/a2-run.exp: Change messages to be more explicit about
[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., 675 Mass Ave, Cambridge, MA 02139, 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 $noargs then {
25 verbose "Skipping a2-run.exp because of noargs."
26 continue
27 }
28
29 if $tracelevel then {
30 strace $tracelevel
31 }
32
33 #
34 # test running programs
35 #
36 set prms_id 0
37 set bug_id 0
38
39 set binfile "run"
40
41 if ![file exists $objdir/$subdir/$binfile] then {
42 perror "$objdir/$subdir/$binfile does not exist."
43 return 0
44 }
45
46 gdb_exit
47 gdb_start
48 gdb_reinitialize_dir $srcdir/$subdir
49 gdb_load $objdir/$subdir/$binfile
50
51 # Run with no arguments.
52 # On VxWorks this justs make sure the program was run.
53 send "run\n"
54 expect -re "run\[\r\n\]+" {}
55 if [istarget "*-*-vxworks*"] then {
56 set timeout 120
57 expect {
58 -i $shell_id "Program exited normally" {
59 unresolved "run \"$binfile\" with no args"
60 }
61 -i $shell_id -re "usage: factorial <number>" {
62 pass "run \"$binfile\" with no args"
63 }
64 timeout {
65 fail "(timeout) run \"$binfile\" with no args"
66 }
67 }
68 set timeout 10
69 expect -re "$prompt $" {}
70 } else {
71 expect {
72 -re "Starting program.*usage: factorial <number>.*Program exited with code 01.*$prompt $" {
73 pass "run \"$binfile\" with no args"
74 }
75 -re ".*$prompt $" {
76 fail "run \"$binfile\" with no args"
77 }
78 timeout {
79 fail "(timeout) run \"$binfile\" no args"
80 }
81 }
82 }
83
84 # Now run with some arguments
85 if [istarget "*-*-vxworks*"] then {
86 send "run vxmain \"5\"\n"
87 expect -re "run vxmain \"5\"\r\n" {}
88 set timeout 120
89 expect {
90 -i $shell_id "Program exited normally" {
91 unresolved "run \"$binfile\" with arg"
92 }
93 -i $shell_id "120" {
94 pass "run \"$binfile\" with arg"
95 }
96 timeout {
97 fail "(timeout) run \"$binfile\" with arg"
98 }
99 }
100 set timeout 10
101 expect -re "$prompt $" {}
102 } else {
103 setup_xfail "mips-idt-*"
104 send "run 5\n"
105 expect {
106 -re "Starting program.*$binfile.*120.*$prompt $"\
107 { pass "run \"$binfile\" with arg" }
108 -re ".*$prompt $" { fail "run \"$binfile\" with arg" }
109 timeout { fail "(timeout) run \"$binfile\" with arg" }
110 }
111 }
112
113 # Run again with same arguments.
114 setup_xfail "mips-idt-*"
115 send "run\n"
116 expect -re "run\[\r\n\]+" {}
117 if [istarget "*-*-vxworks*"] then {
118 set timeout 120
119 expect {
120 -i $shell_id "Program exited normally" {
121 unresolved "run \"$binfile\" again with same args"
122 }
123 -i $shell_id "120" { pass "run \"$binfile\" again with same args" }
124 timeout { fail "(timeout) run \"$binfile\" again with same args" }
125 }
126 set timeout 10
127 expect -re "$prompt $" {}
128 } else {
129 expect {
130 -re "Starting program.*120.*$prompt $"\
131 { pass "run \"$binfile\" again with same args" }
132 -re ".*$prompt $" { fail "run \"$binfile\" again with same args" }
133 timeout { fail "(timeout) run \"$binfile\" again with same args" }
134 }
135 }
136
137 # Use "set args" command to specify no arguments as default and run again.
138 if [istarget "*-*-vxworks*"] then {
139 send "set args main\n"
140 } else {
141 send "set args\n"
142 }
143 expect -re "$prompt $"
144
145 send "run\n"
146 expect -re "run\[\r\n\]+" {}
147 if [istarget "*-*-vxworks*"] then {
148 set timeout 120
149 expect {
150 -i $shell_id "Program exited normally" {
151 unresolved "run after setting args to nil"
152 }
153 -i $shell_id "usage: factorial <number>" {
154 pass "run after setting args to nil"
155 }
156 timeout {
157 fail "(timeout) run after setting args to nil"
158 }
159 }
160 set timeout 10
161 expect -re "$prompt $" {}
162 } else {
163 expect {
164 -re "Starting program.*usage: factorial <number>.*$prompt $" {
165 pass "run after setting args to nil"
166 }
167 -re ".*$prompt $" {
168 fail "run after setting args to nil"
169 }
170 timeout {
171 fail "(timeout) run after setting args to nil"
172 }
173 }
174 }
175
176 # Use "set args" command to specify an argument and run again.
177 setup_xfail "mips-idt-*"
178 if [istarget "*-*-vxworks*"] then {
179 send "set args vxmain \"6\"\n"
180 } else {
181 send "set args 6\n"
182 }
183 expect -re "$prompt $"
184 send "run\n"
185 expect -re "run\[\r\n\]+" {}
186 if [istarget "*-*-vxworks*"] then {
187 set timeout 120
188 expect {
189 -i $shell_id "Program exited normally" {
190 unresolved "run \"$binfile\" again after setting args"
191 }
192 -i $shell_id "720" {
193 pass "run \"$binfile\" again after setting args"
194 }
195 timeout {
196 fail "(timeout) run \"$binfile\" again after setting args"
197 }
198 }
199 set timeout 10
200 expect -re "$prompt $" {}
201 } else {
202 expect {
203 -re "Starting program.*720.*$prompt $" {
204 pass "run \"$binfile\" again after setting args"
205 }
206 -re ".*$prompt $" {
207 fail "run \"$binfile\" again after setting args"
208 }
209 timeout {
210 fail "(timeout) run \"$binfile\" again after setting args"
211 }
212 }
213 }
214
215 # GOAL: Test that shell is being used with "run". For remote debugging
216 # targets, there is no guarantee that a "shell" (whatever that is) is used.
217 if [isnative] then {
218 send "run `echo 8`\n"
219 expect {
220 -re "Starting program.*40320.*$prompt $" {
221 pass "run \"$binfile\" with shell"
222 }
223 -re ".*$prompt $" {
224 fail "run \"$binfile\" with shell"
225 }
226 timeout {
227 fail "(timeout) run \"$binfile\" with shell"
228 }
229 }
230 }
231
232 # Reset the default arguments for VxWorks
233 if [istarget "*-*-vxworks*"] then {
234 send "set args main\n"
235 expect -re ".*$prompt $" {}
236 }
237
This page took 0.042581 seconds and 5 git commands to generate.