1 # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2000
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
21 # This file was written by Rob Savoye. (rob@cygnus.com)
23 # Can't do this test without stdio support.
24 if [gdb_skip_stdio_test "a2run.exp"] {
33 # test running programs
39 set srcfile ${testfile}.c
40 set binfile ${objdir}/${subdir}/${testfile}
41 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
42 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
47 gdb_reinitialize_dir $srcdir/$subdir
50 # Run with no arguments.
51 # On VxWorks this justs make sure the program was run.
54 if [istarget "*-*-vxworks*"] then {
56 verbose "Timeout is now $timeout seconds" 2
58 "Program exited normally" {
59 unresolved "run \"$testfile\" with no args"
61 -re "usage: factorial <number>" {
62 pass "run \"$testfile\" with no args"
65 fail "(timeout) run \"$testfile\" with no args"
69 verbose "Timeout is now $timeout seconds" 2
70 gdb_expect -re "$gdb_prompt $" {}
73 -re ".*usage: factorial <number>.*Program exited with code 01\.\r\n$gdb_prompt $" {
74 pass "run \"$testfile\" with no args"
75 pass "no spurious messages at program exit"
77 -re ".*usage: factorial <number>.*Program exited with code 01.*$gdb_prompt $" {
78 pass "run \"$testfile\" with no args"
79 fail "no spurious messages at program exit"
81 -re ".*usage: factorial <number>.* EXIT code 1.*Program exited normally\.\r\n$gdb_prompt $" {
82 pass "run \"$testfile\" with no args (exit wrapper)"
83 pass "no spurious messages at program exit"
85 -re ".*usage: factorial <number>.* EXIT code 1.*Program exited normally.*$gdb_prompt $" {
86 pass "run \"$testfile\" with no args (exit wrapper)"
87 fail "no spurious messages at program exit"
89 -re ".*$gdb_prompt $" {
90 fail "run \"$testfile\" with no args"
91 verbose "expect_out is $expect_out(buffer)" 2
94 fail "(timeout) run \"$testfile\" no args"
99 # The remaining tests don't work for targets can't take arguments...
101 if [target_info exists noargs] then {
102 verbose "Skipping rest of a2-run.exp because of noargs."
106 # Now run with some arguments
107 if [istarget "*-*-vxworks*"] then {
108 send_gdb "run vxmain \"5\"\n"
109 gdb_expect -re "run vxmain \"5\"\r\n" {}
111 verbose "Timeout is now $timeout seconds" 2
113 "Program exited normally" {
114 unresolved "run \"$testfile\" with arg"
117 pass "run \"$testfile\" with arg"
120 fail "(timeout) run \"$testfile\" with arg"
124 verbose "Timeout is now $timeout seconds" 2
125 gdb_expect -re "$gdb_prompt $" {}
127 setup_xfail "mips-idt-*" "arm-*-coff strongarm-*-coff"
130 -re ".*120.*$gdb_prompt $"\
131 { pass "run \"$testfile\" with arg" }
132 -re ".*$gdb_prompt $" { fail "run \"$testfile\" with arg" }
133 timeout { fail "(timeout) run \"$testfile\" with arg" }
137 # Run again with same arguments.
138 setup_xfail "mips-idt-*"
141 if [istarget "*-*-vxworks*"] then {
143 verbose "Timeout is now $timeout seconds" 2
145 "Program exited normally" {
146 unresolved "run \"$testfile\" again with same args"
148 "120" { pass "run \"$testfile\" again with same args" }
149 timeout { fail "(timeout) run \"$testfile\" again with same args" }
152 verbose "Timeout is now $timeout seconds" 2
153 gdb_expect -re "$gdb_prompt $" {}
155 setup_xfail "arm-*-coff strongarm-*-coff"
157 -re ".*120.*$gdb_prompt $"\
158 { pass "run \"$testfile\" again with same args" }
159 -re ".*$gdb_prompt $" { fail "run \"$testfile\" again with same args" }
160 timeout { fail "(timeout) run \"$testfile\" again with same args" }
164 # Use "set args" command to specify no arguments as default and run again.
165 if [istarget "*-*-vxworks*"] then {
166 send_gdb "set args main\n"
168 send_gdb "set args\n"
170 gdb_expect -re "$gdb_prompt $"
174 if [istarget "*-*-vxworks*"] then {
176 verbose "Timeout is now $timeout seconds" 2
178 "Program exited normally" {
179 unresolved "run after setting args to nil"
181 "usage: factorial <number>" {
182 pass "run after setting args to nil"
185 fail "(timeout) run after setting args to nil"
189 verbose "Timeout is now $timeout seconds" 2
190 gdb_expect -re "$gdb_prompt $" {}
193 -re ".*usage: factorial <number>.*$gdb_prompt $" {
194 pass "run after setting args to nil"
196 -re ".*$gdb_prompt $" {
197 fail "run after setting args to nil"
200 fail "(timeout) run after setting args to nil"
205 # Use "set args" command to specify an argument and run again.
206 setup_xfail "mips-idt-*"
207 if [istarget "*-*-vxworks*"] then {
208 send_gdb "set args vxmain \"6\"\n"
210 send_gdb "set args 6\n"
212 gdb_expect -re "$gdb_prompt $"
215 if [istarget "*-*-vxworks*"] then {
217 verbose "Timeout is now $timeout seconds" 2
219 "Program exited normally" {
220 unresolved "run \"$testfile\" again after setting args"
223 pass "run \"$testfile\" again after setting args"
226 fail "(timeout) run \"$testfile\" again after setting args"
230 verbose "Timeout is now $timeout seconds" 2
231 gdb_expect -re "$gdb_prompt $" {}
233 setup_xfail "arm-*-coff strongarm-*-coff"
235 -re ".*720.*$gdb_prompt $" {
236 pass "run \"$testfile\" again after setting args"
238 -re ".*$gdb_prompt $" {
239 fail "run \"$testfile\" again after setting args"
242 fail "(timeout) run \"$testfile\" again after setting args"
247 # GOAL: Test that shell is being used with "run". For remote debugging
248 # targets, there is no guarantee that a "shell" (whatever that is) is used.
249 if ![is_remote target] then {
250 send_gdb "run `echo 8`\n"
252 -re "Starting program.*40320.*$gdb_prompt $" {
253 pass "run \"$testfile\" with shell"
255 -re ".*$gdb_prompt $" {
256 fail "run \"$testfile\" with shell"
259 fail "(timeout) run \"$testfile\" with shell"
264 # Reset the default arguments for VxWorks
265 if [istarget "*-*-vxworks*"] then {
266 send_gdb "set args main\n"
267 gdb_expect -re ".*$gdb_prompt $" {}