1 # Copyright 1988-2014 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 3 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, see <http://www.gnu.org/licenses/>.
16 # This file was written by Rob Savoye. (rob@cygnus.com)
18 # Can't do this test without stdio support.
19 if [gdb_skip_stdio_test "a2run.exp"] {
24 # test running programs
27 standard_testfile run.c
29 if { [prepare_for_testing ${testfile}.exp $testfile $srcfile] } {
33 # Run with no arguments.
34 # On VxWorks this justs make sure the program was run.
37 if [istarget "*-*-vxworks*"] then {
39 verbose "Timeout is now $timeout seconds" 2
41 "$inferior_exited_re normally" {
42 unresolved "run \"$testfile\" with no args"
44 -re "usage: factorial <number>" {
45 pass "run \"$testfile\" with no args"
48 fail "(timeout) run \"$testfile\" with no args"
52 verbose "Timeout is now $timeout seconds" 2
53 gdb_expect -re "$gdb_prompt $" {}
56 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.\r\n$gdb_prompt $" {
57 pass "run \"$testfile\" with no args"
58 pass "no spurious messages at program exit"
60 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.*$gdb_prompt $" {
61 pass "run \"$testfile\" with no args"
62 fail "no spurious messages at program exit"
64 -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.\r\n$gdb_prompt $" {
65 pass "run \"$testfile\" with no args (exit wrapper)"
66 pass "no spurious messages at program exit"
68 -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.*$gdb_prompt $" {
69 pass "run \"$testfile\" with no args (exit wrapper)"
70 fail "no spurious messages at program exit"
72 -re ".*$gdb_prompt $" {
73 fail "run \"$testfile\" with no args"
74 verbose "expect_out is $expect_out(buffer)" 2
77 fail "(timeout) run \"$testfile\" no args"
82 # The remaining tests don't work for targets can't take arguments...
84 if [target_info exists noargs] then {
85 verbose "Skipping rest of a2-run.exp because of noargs."
89 # Now run with some arguments
90 if [istarget "*-*-vxworks*"] then {
91 send_gdb "run vxmain \"5\"\n"
92 gdb_expect -re "run vxmain \"5\"\r\n" {}
94 verbose "Timeout is now $timeout seconds" 2
96 "$inferior_exited_re normally" {
97 unresolved "run \"$testfile\" with arg"
100 pass "run \"$testfile\" with arg"
103 fail "(timeout) run \"$testfile\" with arg"
107 verbose "Timeout is now $timeout seconds" 2
108 gdb_expect -re "$gdb_prompt $" {}
110 setup_xfail "arm-*-coff"
113 -re ".*120.*$gdb_prompt $"\
114 { pass "run \"$testfile\" with arg" }
115 -re ".*$gdb_prompt $" { fail "run \"$testfile\" with arg" }
116 timeout { fail "(timeout) run \"$testfile\" with arg" }
120 # Run again with same arguments.
123 if [istarget "*-*-vxworks*"] then {
125 verbose "Timeout is now $timeout seconds" 2
127 "$inferior_exited_re normally" {
128 unresolved "run \"$testfile\" again with same args"
130 "120" { pass "run \"$testfile\" again with same args" }
131 timeout { fail "(timeout) run \"$testfile\" again with same args" }
134 verbose "Timeout is now $timeout seconds" 2
135 gdb_expect -re "$gdb_prompt $" {}
137 setup_xfail "arm-*-coff"
139 -re ".*120.*$gdb_prompt $"\
140 { pass "run \"$testfile\" again with same args" }
141 -re ".*$gdb_prompt $" { fail "run \"$testfile\" again with same args" }
142 timeout { fail "(timeout) run \"$testfile\" again with same args" }
146 # Use "set args" command to specify no arguments as default and run again.
147 if [istarget "*-*-vxworks*"] then {
148 gdb_test_no_output "set args main"
150 gdb_test_no_output "set args"
155 if [istarget "*-*-vxworks*"] then {
157 verbose "Timeout is now $timeout seconds" 2
159 "$inferior_exited_re normally" {
160 unresolved "run after setting args to nil"
162 "usage: factorial <number>" {
163 pass "run after setting args to nil"
166 fail "(timeout) run after setting args to nil"
170 verbose "Timeout is now $timeout seconds" 2
171 gdb_expect -re "$gdb_prompt $" {}
174 -re ".*usage: factorial <number>.*$gdb_prompt $" {
175 pass "run after setting args to nil"
177 -re ".*$gdb_prompt $" {
178 fail "run after setting args to nil"
181 fail "(timeout) run after setting args to nil"
186 # Use "set args" command to specify an argument and run again.
187 if [istarget "*-*-vxworks*"] then {
188 gdb_test_no_output "set args vxmain \"6\""
190 gdb_test_no_output "set args 6"
195 if [istarget "*-*-vxworks*"] then {
197 verbose "Timeout is now $timeout seconds" 2
199 "$inferior_exited_re normally" {
200 unresolved "run \"$testfile\" again after setting args"
203 pass "run \"$testfile\" again after setting args"
206 fail "(timeout) run \"$testfile\" again after setting args"
210 verbose "Timeout is now $timeout seconds" 2
211 gdb_expect -re "$gdb_prompt $" {}
213 setup_xfail "arm-*-coff"
215 -re ".*720.*$gdb_prompt $" {
216 pass "run \"$testfile\" again after setting args"
218 -re ".*$gdb_prompt $" {
219 fail "run \"$testfile\" again after setting args"
222 fail "(timeout) run \"$testfile\" again after setting args"
227 # GOAL: Test that shell is being used with "run". For remote debugging
228 # targets, there is no guarantee that a "shell" (whatever that is) is used.
229 if ![is_remote target] then {
230 gdb_test "run `echo 8`" \
231 "Starting program.*40320.*" \
232 "run \"$testfile\" with shell"
235 # Reset the default arguments for VxWorks
236 if [istarget "*-*-vxworks*"] then {
237 gdb_test_no_output "set args main"