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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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...
24 if [target_info exists gdb,noargs] then {
25 verbose "Skipping a2-run.exp because of noargs."
29 if [target_info exists gdb,noinferiorio] {
30 verbose "Skipping a2-run.exp because of noinferiorio."
39 # test running programs
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}"
54 gdb_reinitialize_dir $srcdir/$subdir
57 # Run with no arguments.
58 # On VxWorks this justs make sure the program was run.
61 if [istarget "*-*-vxworks*"] then {
63 verbose "Timeout is now $timeout seconds" 2
65 -i $gdb_spawn_id "Program exited normally" {
66 unresolved "run \"$testfile\" with no args"
68 -i $gdb_spawn_id -re "usage: factorial <number>" {
69 pass "run \"$testfile\" with no args"
72 fail "(timeout) run \"$testfile\" with no args"
76 verbose "Timeout is now $timeout seconds" 2
77 expect -re "$gdb_prompt $" {}
80 -re ".*usage: factorial <number>.*Program exited with code 01.*$gdb_prompt $" {
81 pass "run \"$testfile\" with no args"
83 -re ".*$gdb_prompt $" {
84 fail "run \"$testfile\" with no args"
85 verbose "expect_out is $expect_out(buffer)" 2
88 fail "(timeout) run \"$testfile\" no args"
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" {}
97 verbose "Timeout is now $timeout seconds" 2
99 -i $shell_id "Program exited normally" {
100 unresolved "run \"$testfile\" with arg"
103 pass "run \"$testfile\" with arg"
106 fail "(timeout) run \"$testfile\" with arg"
110 verbose "Timeout is now $timeout seconds" 2
111 expect -re "$gdb_prompt $" {}
113 setup_xfail "mips-idt-*"
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" }
123 # Run again with same arguments.
124 setup_xfail "mips-idt-*"
127 if [istarget "*-*-vxworks*"] then {
129 verbose "Timeout is now $timeout seconds" 2
131 -i $shell_id "Program exited normally" {
132 unresolved "run \"$testfile\" again with same args"
134 -i $shell_id "120" { pass "run \"$testfile\" again with same args" }
135 timeout { fail "(timeout) run \"$testfile\" again with same args" }
138 verbose "Timeout is now $timeout seconds" 2
139 expect -re "$gdb_prompt $" {}
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" }
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"
153 send_gdb "set args\n"
155 expect -re "$gdb_prompt $"
159 if [istarget "*-*-vxworks*"] then {
161 verbose "Timeout is now $timeout seconds" 2
163 -i $shell_id "Program exited normally" {
164 unresolved "run after setting args to nil"
166 -i $shell_id "usage: factorial <number>" {
167 pass "run after setting args to nil"
170 fail "(timeout) run after setting args to nil"
174 verbose "Timeout is now $timeout seconds" 2
175 expect -re "$gdb_prompt $" {}
178 -re ".*usage: factorial <number>.*$gdb_prompt $" {
179 pass "run after setting args to nil"
181 -re ".*$gdb_prompt $" {
182 fail "run after setting args to nil"
185 fail "(timeout) run after setting args to nil"
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"
195 send_gdb "set args 6\n"
197 expect -re "$gdb_prompt $"
200 if [istarget "*-*-vxworks*"] then {
202 verbose "Timeout is now $timeout seconds" 2
204 -i $shell_id "Program exited normally" {
205 unresolved "run \"$testfile\" again after setting args"
208 pass "run \"$testfile\" again after setting args"
211 fail "(timeout) run \"$testfile\" again after setting args"
215 verbose "Timeout is now $timeout seconds" 2
216 expect -re "$gdb_prompt $" {}
219 -re ".*720.*$gdb_prompt $" {
220 pass "run \"$testfile\" again after setting args"
222 -re ".*$gdb_prompt $" {
223 fail "run \"$testfile\" again after setting args"
226 fail "(timeout) run \"$testfile\" again after setting args"
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.
234 send_gdb "run `echo 8`\n"
236 -re "Starting program.*40320.*$gdb_prompt $" {
237 pass "run \"$testfile\" with shell"
239 -re ".*$gdb_prompt $" {
240 fail "run \"$testfile\" with shell"
243 fail "(timeout) run \"$testfile\" with shell"
248 # Reset the default arguments for VxWorks
249 if [istarget "*-*-vxworks*"] then {
250 send_gdb "set args main\n"
251 expect -re ".*$gdb_prompt $" {}