Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.base / a2-run.exp
blobfbc704470cb3820e847d3751630acf47b3290ad6
1 # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2000
2 # 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 2 of the License, or
7 # (at your option) any later version.
8 #
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, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
21 # This file was written by Rob Savoye. (rob@cygnus.com)
23 # These tests don't work for targets can't take arguments...
25 if [target_info exists noargs] then {
26 verbose "Skipping a2-run.exp because of noargs."
27 return
30 # Can't do this test without stdio support.
31 if [gdb_skip_stdio_test "a2run.exp"] {
32 return
35 if $tracelevel then {
36 strace $tracelevel
40 # test running programs
42 set prms_id 0
43 set bug_id 0
45 set testfile "run"
46 set srcfile ${testfile}.c
47 set binfile ${objdir}/${subdir}/${testfile}
48 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
49 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
52 gdb_exit
53 gdb_start
54 gdb_reinitialize_dir $srcdir/$subdir
55 gdb_load ${binfile}
57 # Run with no arguments.
58 # On VxWorks this justs make sure the program was run.
59 gdb_run_cmd
61 if [istarget "*-*-vxworks*"] then {
62 set timeout 120
63 verbose "Timeout is now $timeout seconds" 2
64 gdb_expect {
65 "Program exited normally" {
66 unresolved "run \"$testfile\" with no args"
68 -re "usage: factorial <number>" {
69 pass "run \"$testfile\" with no args"
71 timeout {
72 fail "(timeout) run \"$testfile\" with no args"
75 set timeout 10
76 verbose "Timeout is now $timeout seconds" 2
77 gdb_expect -re "$gdb_prompt $" {}
78 } else {
79 gdb_expect {
80 -re ".*usage: factorial <number>.*Program exited with code 01.*$gdb_prompt $" {
81 pass "run \"$testfile\" with no args"
83 -re ".*usage: factorial <number>.* EXIT code 1.*Program exited normally.*$gdb_prompt $" {
84 pass "run \"$testfile\" with no args (exit wrapper)"
86 -re ".*$gdb_prompt $" {
87 fail "run \"$testfile\" with no args"
88 verbose "expect_out is $expect_out(buffer)" 2
90 timeout {
91 fail "(timeout) run \"$testfile\" no args"
95 # Now run with some arguments
96 if [istarget "*-*-vxworks*"] then {
97 send_gdb "run vxmain \"5\"\n"
98 gdb_expect -re "run vxmain \"5\"\r\n" {}
99 set timeout 120
100 verbose "Timeout is now $timeout seconds" 2
101 gdb_expect {
102 "Program exited normally" {
103 unresolved "run \"$testfile\" with arg"
105 "120" {
106 pass "run \"$testfile\" with arg"
108 timeout {
109 fail "(timeout) run \"$testfile\" with arg"
112 set timeout 10
113 verbose "Timeout is now $timeout seconds" 2
114 gdb_expect -re "$gdb_prompt $" {}
115 } else {
116 setup_xfail "mips-idt-*" "arm-*-coff strongarm-*-coff"
117 gdb_run_cmd 5
118 gdb_expect {
119 -re ".*120.*$gdb_prompt $"\
120 { pass "run \"$testfile\" with arg" }
121 -re ".*$gdb_prompt $" { fail "run \"$testfile\" with arg" }
122 timeout { fail "(timeout) run \"$testfile\" with arg" }
126 # Run again with same arguments.
127 setup_xfail "mips-idt-*"
128 gdb_run_cmd
130 if [istarget "*-*-vxworks*"] then {
131 set timeout 120
132 verbose "Timeout is now $timeout seconds" 2
133 gdb_expect {
134 "Program exited normally" {
135 unresolved "run \"$testfile\" again with same args"
137 "120" { pass "run \"$testfile\" again with same args" }
138 timeout { fail "(timeout) run \"$testfile\" again with same args" }
140 set timeout 10
141 verbose "Timeout is now $timeout seconds" 2
142 gdb_expect -re "$gdb_prompt $" {}
143 } else {
144 setup_xfail "arm-*-coff strongarm-*-coff"
145 gdb_expect {
146 -re ".*120.*$gdb_prompt $"\
147 { pass "run \"$testfile\" again with same args" }
148 -re ".*$gdb_prompt $" { fail "run \"$testfile\" again with same args" }
149 timeout { fail "(timeout) run \"$testfile\" again with same args" }
153 # Use "set args" command to specify no arguments as default and run again.
154 if [istarget "*-*-vxworks*"] then {
155 send_gdb "set args main\n"
156 } else {
157 send_gdb "set args\n"
159 gdb_expect -re "$gdb_prompt $"
161 gdb_run_cmd
163 if [istarget "*-*-vxworks*"] then {
164 set timeout 120
165 verbose "Timeout is now $timeout seconds" 2
166 gdb_expect {
167 "Program exited normally" {
168 unresolved "run after setting args to nil"
170 "usage: factorial <number>" {
171 pass "run after setting args to nil"
173 timeout {
174 fail "(timeout) run after setting args to nil"
177 set timeout 10
178 verbose "Timeout is now $timeout seconds" 2
179 gdb_expect -re "$gdb_prompt $" {}
180 } else {
181 gdb_expect {
182 -re ".*usage: factorial <number>.*$gdb_prompt $" {
183 pass "run after setting args to nil"
185 -re ".*$gdb_prompt $" {
186 fail "run after setting args to nil"
188 timeout {
189 fail "(timeout) run after setting args to nil"
194 # Use "set args" command to specify an argument and run again.
195 setup_xfail "mips-idt-*"
196 if [istarget "*-*-vxworks*"] then {
197 send_gdb "set args vxmain \"6\"\n"
198 } else {
199 send_gdb "set args 6\n"
201 gdb_expect -re "$gdb_prompt $"
202 gdb_run_cmd
204 if [istarget "*-*-vxworks*"] then {
205 set timeout 120
206 verbose "Timeout is now $timeout seconds" 2
207 gdb_expect {
208 "Program exited normally" {
209 unresolved "run \"$testfile\" again after setting args"
211 "720" {
212 pass "run \"$testfile\" again after setting args"
214 timeout {
215 fail "(timeout) run \"$testfile\" again after setting args"
218 set timeout 10
219 verbose "Timeout is now $timeout seconds" 2
220 gdb_expect -re "$gdb_prompt $" {}
221 } else {
222 setup_xfail "arm-*-coff strongarm-*-coff"
223 gdb_expect {
224 -re ".*720.*$gdb_prompt $" {
225 pass "run \"$testfile\" again after setting args"
227 -re ".*$gdb_prompt $" {
228 fail "run \"$testfile\" again after setting args"
230 timeout {
231 fail "(timeout) run \"$testfile\" again after setting args"
236 # GOAL: Test that shell is being used with "run". For remote debugging
237 # targets, there is no guarantee that a "shell" (whatever that is) is used.
238 if ![is_remote target] then {
239 send_gdb "run `echo 8`\n"
240 gdb_expect {
241 -re "Starting program.*40320.*$gdb_prompt $" {
242 pass "run \"$testfile\" with shell"
244 -re ".*$gdb_prompt $" {
245 fail "run \"$testfile\" with shell"
247 timeout {
248 fail "(timeout) run \"$testfile\" with shell"
253 # Reset the default arguments for VxWorks
254 if [istarget "*-*-vxworks*"] then {
255 send_gdb "set args main\n"
256 gdb_expect -re ".*$gdb_prompt $" {}