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 set test "run \"$testfile\" with no args"
39 if [istarget "*-*-vxworks*"] then {
40 gdb_test "" "usage: factorial <number>.*" $test
42 gdb_test_multiple "" $test {
43 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.\r\n$gdb_prompt $" {
45 pass "no spurious messages at program exit"
47 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.*$gdb_prompt $" {
49 fail "no spurious messages at program exit"
51 -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.\r\n$gdb_prompt $" {
52 pass "$test (exit wrapper)"
53 pass "no spurious messages at program exit"
55 -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.*$gdb_prompt $" {
56 pass "$test (exit wrapper)"
57 fail "no spurious messages at program exit"
62 # The remaining tests don't work for targets can't take arguments...
64 if [target_info exists noargs] then {
65 verbose "Skipping rest of a2-run.exp because of noargs."
69 # Now run with some arguments
70 if [istarget "*-*-vxworks*"] then {
71 send_gdb "run vxmain \"5\"\n"
72 gdb_expect -re "run vxmain \"5\"\r\n" {}
74 verbose "Timeout is now $timeout seconds" 2
76 "$inferior_exited_re normally" {
77 unresolved "run \"$testfile\" with arg"
80 pass "run \"$testfile\" with arg"
83 fail "(timeout) run \"$testfile\" with arg"
87 verbose "Timeout is now $timeout seconds" 2
88 gdb_expect -re "$gdb_prompt $" {}
90 setup_xfail "arm-*-coff"
92 gdb_test "" "120.*" "run \"$testfile\" with arg"
95 # Run again with same arguments.
98 if [istarget "*-*-vxworks*"] then {
100 verbose "Timeout is now $timeout seconds" 2
102 "$inferior_exited_re normally" {
103 unresolved "run \"$testfile\" again with same args"
105 "120" { pass "run \"$testfile\" again with same args" }
106 timeout { fail "(timeout) run \"$testfile\" again with same args" }
109 verbose "Timeout is now $timeout seconds" 2
110 gdb_expect -re "$gdb_prompt $" {}
112 setup_xfail "arm-*-coff"
113 gdb_test "" "120.*" "run \"$testfile\" again with same args"
116 # Use "set args" command to specify no arguments as default and run again.
117 if [istarget "*-*-vxworks*"] then {
118 gdb_test_no_output "set args main"
120 gdb_test_no_output "set args"
125 if [istarget "*-*-vxworks*"] then {
127 verbose "Timeout is now $timeout seconds" 2
129 "$inferior_exited_re normally" {
130 unresolved "run after setting args to nil"
132 "usage: factorial <number>" {
133 pass "run after setting args to nil"
136 fail "(timeout) run after setting args to nil"
140 verbose "Timeout is now $timeout seconds" 2
141 gdb_expect -re "$gdb_prompt $" {}
143 gdb_test "" "usage: factorial <number>.*" "run after setting args to nil"
146 # Use "set args" command to specify an argument and run again.
147 if [istarget "*-*-vxworks*"] then {
148 gdb_test_no_output "set args vxmain \"6\""
150 gdb_test_no_output "set args 6"
155 if [istarget "*-*-vxworks*"] then {
157 verbose "Timeout is now $timeout seconds" 2
159 "$inferior_exited_re normally" {
160 unresolved "run \"$testfile\" again after setting args"
163 pass "run \"$testfile\" again after setting args"
166 fail "(timeout) run \"$testfile\" again after setting args"
170 verbose "Timeout is now $timeout seconds" 2
171 gdb_expect -re "$gdb_prompt $" {}
173 setup_xfail "arm-*-coff"
174 gdb_test "" "720.*" "run \"$testfile\" again after setting args"
177 # GOAL: Test that shell is being used with "run". For remote debugging
178 # targets, there is no guarantee that a "shell" (whatever that is) is used.
179 if ![is_remote target] then {
180 gdb_test "run `echo 8`" \
181 "Starting program.*40320.*" \
182 "run \"$testfile\" with shell"
185 # Reset the default arguments for VxWorks
186 if [istarget "*-*-vxworks*"] then {
187 gdb_test_no_output "set args main"