1 # Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997 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 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 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
53 gdb_reinitialize_dir $srcdir/$subdir
56 # Run with no arguments.
57 # On VxWorks this justs make sure the program was run.
60 if [istarget "*-*-vxworks*"] then {
62 verbose "Timeout is now $timeout seconds" 2
64 "Program exited normally" {
65 unresolved "run \"$testfile\" with no args"
67 -re "usage: factorial <number>" {
68 pass "run \"$testfile\" with no args"
71 fail "(timeout) run \"$testfile\" with no args"
75 verbose "Timeout is now $timeout seconds" 2
76 gdb_expect -re "$gdb_prompt $" {}
79 -re ".*usage: factorial <number>.*Program exited with code 01.*$gdb_prompt $" {
80 pass "run \"$testfile\" with no args"
82 -re ".*$gdb_prompt $" {
83 fail "run \"$testfile\" with no args"
84 verbose "expect_out is $expect_out(buffer)" 2
87 fail "(timeout) run \"$testfile\" no args"
91 # Now run with some arguments
92 if [istarget "*-*-vxworks*"] then {
93 send_gdb "run vxmain \"5\"\n"
94 gdb_expect -re "run vxmain \"5\"\r\n" {}
96 verbose "Timeout is now $timeout seconds" 2
98 "Program exited normally" {
99 unresolved "run \"$testfile\" with arg"
102 pass "run \"$testfile\" with arg"
105 fail "(timeout) run \"$testfile\" with arg"
109 verbose "Timeout is now $timeout seconds" 2
110 gdb_expect -re "$gdb_prompt $" {}
112 setup_xfail "mips-idt-*" "arm-*-coff strongarm-*-coff"
115 -re ".*120.*$gdb_prompt $"\
116 { pass "run \"$testfile\" with arg" }
117 -re ".*$gdb_prompt $" { fail "run \"$testfile\" with arg" }
118 timeout { fail "(timeout) run \"$testfile\" with arg" }
122 # Run again with same arguments.
123 setup_xfail "mips-idt-*"
126 if [istarget "*-*-vxworks*"] then {
128 verbose "Timeout is now $timeout seconds" 2
130 "Program exited normally" {
131 unresolved "run \"$testfile\" again with same args"
133 "120" { pass "run \"$testfile\" again with same args" }
134 timeout { fail "(timeout) run \"$testfile\" again with same args" }
137 verbose "Timeout is now $timeout seconds" 2
138 gdb_expect -re "$gdb_prompt $" {}
140 setup_xfail "arm-*-coff strongarm-*-coff"
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 gdb_expect -re "$gdb_prompt $"
159 if [istarget "*-*-vxworks*"] then {
161 verbose "Timeout is now $timeout seconds" 2
163 "Program exited normally" {
164 unresolved "run after setting args to nil"
166 "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 gdb_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 gdb_expect -re "$gdb_prompt $"
200 if [istarget "*-*-vxworks*"] then {
202 verbose "Timeout is now $timeout seconds" 2
204 "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 gdb_expect -re "$gdb_prompt $" {}
218 setup_xfail "arm-*-coff strongarm-*-coff"
220 -re ".*720.*$gdb_prompt $" {
221 pass "run \"$testfile\" again after setting args"
223 -re ".*$gdb_prompt $" {
224 fail "run \"$testfile\" again after setting args"
227 fail "(timeout) run \"$testfile\" again after setting args"
232 # GOAL: Test that shell is being used with "run". For remote debugging
233 # targets, there is no guarantee that a "shell" (whatever that is) is used.
235 send_gdb "run `echo 8`\n"
237 -re "Starting program.*40320.*$gdb_prompt $" {
238 pass "run \"$testfile\" with shell"
240 -re ".*$gdb_prompt $" {
241 fail "run \"$testfile\" with shell"
244 fail "(timeout) run \"$testfile\" with shell"
249 # Reset the default arguments for VxWorks
250 if [istarget "*-*-vxworks*"] then {
251 send_gdb "set args main\n"
252 gdb_expect -re ".*$gdb_prompt $" {}