1 # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2000,
2 # 2007, 2008 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 3 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, see <http://www.gnu.org/licenses/>.
17 # This file was written by Rob Savoye. (rob@cygnus.com)
19 # Can't do this test without stdio support.
20 if [gdb_skip_stdio_test "a2run.exp"] {
29 # test running programs
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
44 gdb_reinitialize_dir $srcdir/$subdir
47 # Run with no arguments.
48 # On VxWorks this justs make sure the program was run.
51 if [istarget "*-*-vxworks*"] then {
53 verbose "Timeout is now $timeout seconds" 2
55 "Program exited normally" {
56 unresolved "run \"$testfile\" with no args"
58 -re "usage: factorial <number>" {
59 pass "run \"$testfile\" with no args"
62 fail "(timeout) run \"$testfile\" with no args"
66 verbose "Timeout is now $timeout seconds" 2
67 gdb_expect -re "$gdb_prompt $" {}
70 -re ".*usage: factorial <number>.*Program exited with code 01\.\r\n$gdb_prompt $" {
71 pass "run \"$testfile\" with no args"
72 pass "no spurious messages at program exit"
74 -re ".*usage: factorial <number>.*Program exited with code 01.*$gdb_prompt $" {
75 pass "run \"$testfile\" with no args"
76 fail "no spurious messages at program exit"
78 -re ".*usage: factorial <number>.* EXIT code 1.*Program exited normally\.\r\n$gdb_prompt $" {
79 pass "run \"$testfile\" with no args (exit wrapper)"
80 pass "no spurious messages at program exit"
82 -re ".*usage: factorial <number>.* EXIT code 1.*Program exited normally.*$gdb_prompt $" {
83 pass "run \"$testfile\" with no args (exit wrapper)"
84 fail "no spurious messages at program exit"
86 -re ".*$gdb_prompt $" {
87 fail "run \"$testfile\" with no args"
88 verbose "expect_out is $expect_out(buffer)" 2
91 fail "(timeout) run \"$testfile\" no args"
96 # The remaining tests don't work for targets can't take arguments...
98 if [target_info exists noargs] then {
99 verbose "Skipping rest of a2-run.exp because of noargs."
103 # Now run with some arguments
104 if [istarget "*-*-vxworks*"] then {
105 send_gdb "run vxmain \"5\"\n"
106 gdb_expect -re "run vxmain \"5\"\r\n" {}
108 verbose "Timeout is now $timeout seconds" 2
110 "Program exited normally" {
111 unresolved "run \"$testfile\" with arg"
114 pass "run \"$testfile\" with arg"
117 fail "(timeout) run \"$testfile\" with arg"
121 verbose "Timeout is now $timeout seconds" 2
122 gdb_expect -re "$gdb_prompt $" {}
124 setup_xfail "mips-idt-*" "arm-*-coff strongarm-*-coff"
127 -re ".*120.*$gdb_prompt $"\
128 { pass "run \"$testfile\" with arg" }
129 -re ".*$gdb_prompt $" { fail "run \"$testfile\" with arg" }
130 timeout { fail "(timeout) run \"$testfile\" with arg" }
134 # Run again with same arguments.
135 setup_xfail "mips-idt-*"
138 if [istarget "*-*-vxworks*"] then {
140 verbose "Timeout is now $timeout seconds" 2
142 "Program exited normally" {
143 unresolved "run \"$testfile\" again with same args"
145 "120" { pass "run \"$testfile\" again with same args" }
146 timeout { fail "(timeout) run \"$testfile\" again with same args" }
149 verbose "Timeout is now $timeout seconds" 2
150 gdb_expect -re "$gdb_prompt $" {}
152 setup_xfail "arm-*-coff strongarm-*-coff"
154 -re ".*120.*$gdb_prompt $"\
155 { pass "run \"$testfile\" again with same args" }
156 -re ".*$gdb_prompt $" { fail "run \"$testfile\" again with same args" }
157 timeout { fail "(timeout) run \"$testfile\" again with same args" }
161 # Use "set args" command to specify no arguments as default and run again.
162 if [istarget "*-*-vxworks*"] then {
163 send_gdb "set args main\n"
165 send_gdb "set args\n"
167 gdb_expect -re "$gdb_prompt $"
171 if [istarget "*-*-vxworks*"] then {
173 verbose "Timeout is now $timeout seconds" 2
175 "Program exited normally" {
176 unresolved "run after setting args to nil"
178 "usage: factorial <number>" {
179 pass "run after setting args to nil"
182 fail "(timeout) run after setting args to nil"
186 verbose "Timeout is now $timeout seconds" 2
187 gdb_expect -re "$gdb_prompt $" {}
190 -re ".*usage: factorial <number>.*$gdb_prompt $" {
191 pass "run after setting args to nil"
193 -re ".*$gdb_prompt $" {
194 fail "run after setting args to nil"
197 fail "(timeout) run after setting args to nil"
202 # Use "set args" command to specify an argument and run again.
203 setup_xfail "mips-idt-*"
204 if [istarget "*-*-vxworks*"] then {
205 send_gdb "set args vxmain \"6\"\n"
207 send_gdb "set args 6\n"
209 gdb_expect -re "$gdb_prompt $"
212 if [istarget "*-*-vxworks*"] then {
214 verbose "Timeout is now $timeout seconds" 2
216 "Program exited normally" {
217 unresolved "run \"$testfile\" again after setting args"
220 pass "run \"$testfile\" again after setting args"
223 fail "(timeout) run \"$testfile\" again after setting args"
227 verbose "Timeout is now $timeout seconds" 2
228 gdb_expect -re "$gdb_prompt $" {}
230 setup_xfail "arm-*-coff strongarm-*-coff"
232 -re ".*720.*$gdb_prompt $" {
233 pass "run \"$testfile\" again after setting args"
235 -re ".*$gdb_prompt $" {
236 fail "run \"$testfile\" again after setting args"
239 fail "(timeout) run \"$testfile\" again after setting args"
244 # GOAL: Test that shell is being used with "run". For remote debugging
245 # targets, there is no guarantee that a "shell" (whatever that is) is used.
246 if ![is_remote target] then {
247 send_gdb "run `echo 8`\n"
249 -re "Starting program.*40320.*$gdb_prompt $" {
250 pass "run \"$testfile\" with shell"
252 -re ".*$gdb_prompt $" {
253 fail "run \"$testfile\" with shell"
256 fail "(timeout) run \"$testfile\" with shell"
261 # Reset the default arguments for VxWorks
262 if [istarget "*-*-vxworks*"] then {
263 send_gdb "set args main\n"
264 gdb_expect -re ".*$gdb_prompt $" {}