after gdb_run_cmd, gdb_expect -> gdb_test_multiple/gdb_test
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / a2-run.exp
1 # Copyright 1988-2014 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
16 # This file was written by Rob Savoye. (rob@cygnus.com)
17
18 # Can't do this test without stdio support.
19 if [gdb_skip_stdio_test "a2run.exp"] {
20 return
21 }
22
23 #
24 # test running programs
25 #
26
27 standard_testfile run.c
28
29 if { [prepare_for_testing ${testfile}.exp $testfile $srcfile] } {
30 return -1
31 }
32
33 # Run with no arguments.
34 # On VxWorks this justs make sure the program was run.
35 gdb_run_cmd
36
37 set test "run \"$testfile\" with no args"
38
39 if [istarget "*-*-vxworks*"] then {
40 gdb_test "" "usage: factorial <number>.*" $test
41 } else {
42 gdb_test_multiple "" $test {
43 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.\r\n$gdb_prompt $" {
44 pass $test
45 pass "no spurious messages at program exit"
46 }
47 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.*$gdb_prompt $" {
48 pass $test
49 fail "no spurious messages at program exit"
50 }
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"
54 }
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"
58 }
59 }
60 }
61
62 # The remaining tests don't work for targets can't take arguments...
63
64 if [target_info exists noargs] then {
65 verbose "Skipping rest of a2-run.exp because of noargs."
66 return
67 }
68
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" {}
73 set timeout 120
74 verbose "Timeout is now $timeout seconds" 2
75 gdb_expect {
76 "$inferior_exited_re normally" {
77 unresolved "run \"$testfile\" with arg"
78 }
79 "120" {
80 pass "run \"$testfile\" with arg"
81 }
82 timeout {
83 fail "(timeout) run \"$testfile\" with arg"
84 }
85 }
86 set timeout 10
87 verbose "Timeout is now $timeout seconds" 2
88 gdb_expect -re "$gdb_prompt $" {}
89 } else {
90 setup_xfail "arm-*-coff"
91 gdb_run_cmd 5
92 gdb_test "" "120.*" "run \"$testfile\" with arg"
93 }
94
95 # Run again with same arguments.
96 gdb_run_cmd
97
98 if [istarget "*-*-vxworks*"] then {
99 set timeout 120
100 verbose "Timeout is now $timeout seconds" 2
101 gdb_expect {
102 "$inferior_exited_re normally" {
103 unresolved "run \"$testfile\" again with same args"
104 }
105 "120" { pass "run \"$testfile\" again with same args" }
106 timeout { fail "(timeout) run \"$testfile\" again with same args" }
107 }
108 set timeout 10
109 verbose "Timeout is now $timeout seconds" 2
110 gdb_expect -re "$gdb_prompt $" {}
111 } else {
112 setup_xfail "arm-*-coff"
113 gdb_test "" "120.*" "run \"$testfile\" again with same args"
114 }
115
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"
119 } else {
120 gdb_test_no_output "set args"
121 }
122
123 gdb_run_cmd
124
125 if [istarget "*-*-vxworks*"] then {
126 set timeout 120
127 verbose "Timeout is now $timeout seconds" 2
128 gdb_expect {
129 "$inferior_exited_re normally" {
130 unresolved "run after setting args to nil"
131 }
132 "usage: factorial <number>" {
133 pass "run after setting args to nil"
134 }
135 timeout {
136 fail "(timeout) run after setting args to nil"
137 }
138 }
139 set timeout 10
140 verbose "Timeout is now $timeout seconds" 2
141 gdb_expect -re "$gdb_prompt $" {}
142 } else {
143 gdb_test "" "usage: factorial <number>.*" "run after setting args to nil"
144 }
145
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\""
149 } else {
150 gdb_test_no_output "set args 6"
151 }
152
153 gdb_run_cmd
154
155 if [istarget "*-*-vxworks*"] then {
156 set timeout 120
157 verbose "Timeout is now $timeout seconds" 2
158 gdb_expect {
159 "$inferior_exited_re normally" {
160 unresolved "run \"$testfile\" again after setting args"
161 }
162 "720" {
163 pass "run \"$testfile\" again after setting args"
164 }
165 timeout {
166 fail "(timeout) run \"$testfile\" again after setting args"
167 }
168 }
169 set timeout 10
170 verbose "Timeout is now $timeout seconds" 2
171 gdb_expect -re "$gdb_prompt $" {}
172 } else {
173 setup_xfail "arm-*-coff"
174 gdb_test "" "720.*" "run \"$testfile\" again after setting args"
175 }
176
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"
183 }
184
185 # Reset the default arguments for VxWorks
186 if [istarget "*-*-vxworks*"] then {
187 gdb_test_no_output "set args main"
188 }
This page took 0.034744 seconds and 4 git commands to generate.