1 # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2000,
2 # 2007, 2008, 2009, 2010, 2011 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
33 if { [prepare_for_testing ${testfile}.exp $testfile run.c] } {
37 # Run with no arguments.
38 # On VxWorks this justs make sure the program was run.
41 if [istarget "*-*-vxworks*"] then {
43 verbose "Timeout is now $timeout seconds" 2
45 "$inferior_exited_re normally" {
46 unresolved "run \"$testfile\" with no args"
48 -re "usage: factorial <number>" {
49 pass "run \"$testfile\" with no args"
52 fail "(timeout) run \"$testfile\" with no args"
56 verbose "Timeout is now $timeout seconds" 2
57 gdb_expect -re "$gdb_prompt $" {}
60 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.\r\n$gdb_prompt $" {
61 pass "run \"$testfile\" with no args"
62 pass "no spurious messages at program exit"
64 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.*$gdb_prompt $" {
65 pass "run \"$testfile\" with no args"
66 fail "no spurious messages at program exit"
68 -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.\r\n$gdb_prompt $" {
69 pass "run \"$testfile\" with no args (exit wrapper)"
70 pass "no spurious messages at program exit"
72 -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.*$gdb_prompt $" {
73 pass "run \"$testfile\" with no args (exit wrapper)"
74 fail "no spurious messages at program exit"
76 -re ".*$gdb_prompt $" {
77 fail "run \"$testfile\" with no args"
78 verbose "expect_out is $expect_out(buffer)" 2
81 fail "(timeout) run \"$testfile\" no args"
86 # The remaining tests don't work for targets can't take arguments...
88 if [target_info exists noargs] then {
89 verbose "Skipping rest of a2-run.exp because of noargs."
93 # Now run with some arguments
94 if [istarget "*-*-vxworks*"] then {
95 send_gdb "run vxmain \"5\"\n"
96 gdb_expect -re "run vxmain \"5\"\r\n" {}
98 verbose "Timeout is now $timeout seconds" 2
100 "$inferior_exited_re normally" {
101 unresolved "run \"$testfile\" with arg"
104 pass "run \"$testfile\" with arg"
107 fail "(timeout) run \"$testfile\" with arg"
111 verbose "Timeout is now $timeout seconds" 2
112 gdb_expect -re "$gdb_prompt $" {}
114 setup_xfail "mips-idt-*" "arm-*-coff strongarm-*-coff"
117 -re ".*120.*$gdb_prompt $"\
118 { pass "run \"$testfile\" with arg" }
119 -re ".*$gdb_prompt $" { fail "run \"$testfile\" with arg" }
120 timeout { fail "(timeout) run \"$testfile\" with arg" }
124 # Run again with same arguments.
125 setup_xfail "mips-idt-*"
128 if [istarget "*-*-vxworks*"] then {
130 verbose "Timeout is now $timeout seconds" 2
132 "$inferior_exited_re normally" {
133 unresolved "run \"$testfile\" again with same args"
135 "120" { pass "run \"$testfile\" again with same args" }
136 timeout { fail "(timeout) run \"$testfile\" again with same args" }
139 verbose "Timeout is now $timeout seconds" 2
140 gdb_expect -re "$gdb_prompt $" {}
142 setup_xfail "arm-*-coff strongarm-*-coff"
144 -re ".*120.*$gdb_prompt $"\
145 { pass "run \"$testfile\" again with same args" }
146 -re ".*$gdb_prompt $" { fail "run \"$testfile\" again with same args" }
147 timeout { fail "(timeout) run \"$testfile\" again with same args" }
151 # Use "set args" command to specify no arguments as default and run again.
152 if [istarget "*-*-vxworks*"] then {
153 gdb_test_no_output "set args main"
155 gdb_test_no_output "set args"
160 if [istarget "*-*-vxworks*"] then {
162 verbose "Timeout is now $timeout seconds" 2
164 "$inferior_exited_re normally" {
165 unresolved "run after setting args to nil"
167 "usage: factorial <number>" {
168 pass "run after setting args to nil"
171 fail "(timeout) run after setting args to nil"
175 verbose "Timeout is now $timeout seconds" 2
176 gdb_expect -re "$gdb_prompt $" {}
179 -re ".*usage: factorial <number>.*$gdb_prompt $" {
180 pass "run after setting args to nil"
182 -re ".*$gdb_prompt $" {
183 fail "run after setting args to nil"
186 fail "(timeout) run after setting args to nil"
191 # Use "set args" command to specify an argument and run again.
192 setup_xfail "mips-idt-*"
193 if [istarget "*-*-vxworks*"] then {
194 gdb_test_no_output "set args vxmain \"6\""
196 gdb_test_no_output "set args 6"
201 if [istarget "*-*-vxworks*"] then {
203 verbose "Timeout is now $timeout seconds" 2
205 "$inferior_exited_re normally" {
206 unresolved "run \"$testfile\" again after setting args"
209 pass "run \"$testfile\" again after setting args"
212 fail "(timeout) run \"$testfile\" again after setting args"
216 verbose "Timeout is now $timeout seconds" 2
217 gdb_expect -re "$gdb_prompt $" {}
219 setup_xfail "arm-*-coff strongarm-*-coff"
221 -re ".*720.*$gdb_prompt $" {
222 pass "run \"$testfile\" again after setting args"
224 -re ".*$gdb_prompt $" {
225 fail "run \"$testfile\" again after setting args"
228 fail "(timeout) run \"$testfile\" again after setting args"
233 # GOAL: Test that shell is being used with "run". For remote debugging
234 # targets, there is no guarantee that a "shell" (whatever that is) is used.
235 if ![is_remote target] then {
236 gdb_test "run `echo 8`" \
237 "Starting program.*40320.*" \
238 "run \"$testfile\" with shell"
241 # Reset the default arguments for VxWorks
242 if [istarget "*-*-vxworks*"] then {
243 gdb_test_no_output "set args main"