1 # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2007
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}] != "" } {
48 gdb_reinitialize_dir $srcdir/$subdir
51 # Run with no arguments.
52 # On VxWorks this justs make sure the program was run.
55 if [istarget "*-*-vxworks*"] then {
57 verbose "Timeout is now $timeout seconds" 2
59 "Program exited normally" {
60 unresolved "run \"$testfile\" with no args"
62 -re "usage: factorial <number>" {
63 pass "run \"$testfile\" with no args"
66 fail "(timeout) run \"$testfile\" with no args"
70 verbose "Timeout is now $timeout seconds" 2
71 gdb_expect -re "$gdb_prompt $" {}
74 -re ".*usage: factorial <number>.*Program exited with code 01\.\r\n$gdb_prompt $" {
75 pass "run \"$testfile\" with no args"
76 pass "no spurious messages at program exit"
78 -re ".*usage: factorial <number>.*Program exited with code 01.*$gdb_prompt $" {
79 pass "run \"$testfile\" with no args"
80 fail "no spurious messages at program exit"
82 -re ".*usage: factorial <number>.* EXIT code 1.*Program exited normally\.\r\n$gdb_prompt $" {
83 pass "run \"$testfile\" with no args (exit wrapper)"
84 pass "no spurious messages at program exit"
86 -re ".*usage: factorial <number>.* EXIT code 1.*Program exited normally.*$gdb_prompt $" {
87 pass "run \"$testfile\" with no args (exit wrapper)"
88 fail "no spurious messages at program exit"
90 -re ".*$gdb_prompt $" {
91 fail "run \"$testfile\" with no args"
92 verbose "expect_out is $expect_out(buffer)" 2
95 fail "(timeout) run \"$testfile\" no args"
100 # The remaining tests don't work for targets can't take arguments...
102 if [target_info exists noargs] then {
103 verbose "Skipping rest of a2-run.exp because of noargs."
107 # Now run with some arguments
108 if [istarget "*-*-vxworks*"] then {
109 send_gdb "run vxmain \"5\"\n"
110 gdb_expect -re "run vxmain \"5\"\r\n" {}
112 verbose "Timeout is now $timeout seconds" 2
114 "Program exited normally" {
115 unresolved "run \"$testfile\" with arg"
118 pass "run \"$testfile\" with arg"
121 fail "(timeout) run \"$testfile\" with arg"
125 verbose "Timeout is now $timeout seconds" 2
126 gdb_expect -re "$gdb_prompt $" {}
128 setup_xfail "mips-idt-*" "arm-*-coff strongarm-*-coff"
131 -re ".*120.*$gdb_prompt $"\
132 { pass "run \"$testfile\" with arg" }
133 -re ".*$gdb_prompt $" { fail "run \"$testfile\" with arg" }
134 timeout { fail "(timeout) run \"$testfile\" with arg" }
138 # Run again with same arguments.
139 setup_xfail "mips-idt-*"
142 if [istarget "*-*-vxworks*"] then {
144 verbose "Timeout is now $timeout seconds" 2
146 "Program exited normally" {
147 unresolved "run \"$testfile\" again with same args"
149 "120" { pass "run \"$testfile\" again with same args" }
150 timeout { fail "(timeout) run \"$testfile\" again with same args" }
153 verbose "Timeout is now $timeout seconds" 2
154 gdb_expect -re "$gdb_prompt $" {}
156 setup_xfail "arm-*-coff strongarm-*-coff"
158 -re ".*120.*$gdb_prompt $"\
159 { pass "run \"$testfile\" again with same args" }
160 -re ".*$gdb_prompt $" { fail "run \"$testfile\" again with same args" }
161 timeout { fail "(timeout) run \"$testfile\" again with same args" }
165 # Use "set args" command to specify no arguments as default and run again.
166 if [istarget "*-*-vxworks*"] then {
167 send_gdb "set args main\n"
169 send_gdb "set args\n"
171 gdb_expect -re "$gdb_prompt $"
175 if [istarget "*-*-vxworks*"] then {
177 verbose "Timeout is now $timeout seconds" 2
179 "Program exited normally" {
180 unresolved "run after setting args to nil"
182 "usage: factorial <number>" {
183 pass "run after setting args to nil"
186 fail "(timeout) run after setting args to nil"
190 verbose "Timeout is now $timeout seconds" 2
191 gdb_expect -re "$gdb_prompt $" {}
194 -re ".*usage: factorial <number>.*$gdb_prompt $" {
195 pass "run after setting args to nil"
197 -re ".*$gdb_prompt $" {
198 fail "run after setting args to nil"
201 fail "(timeout) run after setting args to nil"
206 # Use "set args" command to specify an argument and run again.
207 setup_xfail "mips-idt-*"
208 if [istarget "*-*-vxworks*"] then {
209 send_gdb "set args vxmain \"6\"\n"
211 send_gdb "set args 6\n"
213 gdb_expect -re "$gdb_prompt $"
216 if [istarget "*-*-vxworks*"] then {
218 verbose "Timeout is now $timeout seconds" 2
220 "Program exited normally" {
221 unresolved "run \"$testfile\" again after setting args"
224 pass "run \"$testfile\" again after setting args"
227 fail "(timeout) run \"$testfile\" again after setting args"
231 verbose "Timeout is now $timeout seconds" 2
232 gdb_expect -re "$gdb_prompt $" {}
234 setup_xfail "arm-*-coff strongarm-*-coff"
236 -re ".*720.*$gdb_prompt $" {
237 pass "run \"$testfile\" again after setting args"
239 -re ".*$gdb_prompt $" {
240 fail "run \"$testfile\" again after setting args"
243 fail "(timeout) run \"$testfile\" again after setting args"
248 # GOAL: Test that shell is being used with "run". For remote debugging
249 # targets, there is no guarantee that a "shell" (whatever that is) is used.
250 if ![is_remote target] then {
251 send_gdb "run `echo 8`\n"
253 -re "Starting program.*40320.*$gdb_prompt $" {
254 pass "run \"$testfile\" with shell"
256 -re ".*$gdb_prompt $" {
257 fail "run \"$testfile\" with shell"
260 fail "(timeout) run \"$testfile\" with shell"
265 # Reset the default arguments for VxWorks
266 if [istarget "*-*-vxworks*"] then {
267 send_gdb "set args main\n"
268 gdb_expect -re ".*$gdb_prompt $" {}