1 # Copyright (C) 1988, 1990, 1991, 1992, 1994 Free Software Foundation, Inc.
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.
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.
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. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Rob Savoye. (rob@cygnus.com)
22 # These tests don't work for targets can't take arguments...
25 verbose "Skipping a2-run.exp because of noargs."
34 # test running programs
41 if ![file exists $objdir/$subdir/$binfile] then {
42 perror "$objdir/$subdir/$binfile does not exist."
48 gdb_reinitialize_dir $srcdir/$subdir
49 gdb_load $objdir/$subdir/$binfile
51 # Run with no arguments.
52 # On VxWorks this justs make sure the program was run.
54 expect -re "run\[\r\n\]+" {}
55 if [istarget "*-*-vxworks*"] then {
58 -i $shell_id "Program exited normally" {
59 unresolved "run \"$binfile\" with no args"
61 -i $shell_id -re "usage: factorial <number>" {
62 pass "run \"$binfile\" with no args"
65 fail "(timeout) run \"$binfile\" with no args"
69 expect -re "$prompt $" {}
72 -re "Starting program.*usage: factorial <number>.*Program exited with code 01.*$prompt $" {
73 pass "run \"$binfile\" with no args"
76 fail "run \"$binfile\" with no args"
79 fail "(timeout) run \"$binfile\" no args"
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" {}
90 -i $shell_id "Program exited normally" {
91 unresolved "run \"$binfile\" with arg"
94 pass "run \"$binfile\" with arg"
97 fail "(timeout) run \"$binfile\" with arg"
101 expect -re "$prompt $" {}
103 setup_xfail "mips-idt-*"
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" }
113 # Run again with same arguments.
114 setup_xfail "mips-idt-*"
116 expect -re "run\[\r\n\]+" {}
117 if [istarget "*-*-vxworks*"] then {
120 -i $shell_id "Program exited normally" {
121 unresolved "run \"$binfile\" again with same args"
123 -i $shell_id "120" { pass "run \"$binfile\" again with same args" }
124 timeout { fail "(timeout) run \"$binfile\" again with same args" }
127 expect -re "$prompt $" {}
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" }
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"
143 expect -re "$prompt $"
146 expect -re "run\[\r\n\]+" {}
147 if [istarget "*-*-vxworks*"] then {
150 -i $shell_id "Program exited normally" {
151 unresolved "run after setting args to nil"
153 -i $shell_id "usage: factorial <number>" {
154 pass "run after setting args to nil"
157 fail "(timeout) run after setting args to nil"
161 expect -re "$prompt $" {}
164 -re "Starting program.*usage: factorial <number>.*$prompt $" {
165 pass "run after setting args to nil"
168 fail "run after setting args to nil"
171 fail "(timeout) run after setting args to nil"
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"
183 expect -re "$prompt $"
185 expect -re "run\[\r\n\]+" {}
186 if [istarget "*-*-vxworks*"] then {
189 -i $shell_id "Program exited normally" {
190 unresolved "run \"$binfile\" again after setting args"
193 pass "run \"$binfile\" again after setting args"
196 fail "(timeout) run \"$binfile\" again after setting args"
200 expect -re "$prompt $" {}
203 -re "Starting program.*720.*$prompt $" {
204 pass "run \"$binfile\" again after setting args"
207 fail "run \"$binfile\" again after setting args"
210 fail "(timeout) run \"$binfile\" again after setting args"
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.
218 send "run `echo 8`\n"
220 -re "Starting program.*40320.*$prompt $" {
221 pass "run \"$binfile\" with shell"
224 fail "run \"$binfile\" with shell"
227 fail "(timeout) run \"$binfile\" with shell"
232 # Reset the default arguments for VxWorks
233 if [istarget "*-*-vxworks*"] then {
234 send "set args main\n"
235 expect -re ".*$prompt $" {}