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