* elf-bfd.h (struct elf_backend_data): Add rela_normal.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / a2-run.exp
CommitLineData
b6ba6518
KB
1# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2000
2# Free Software Foundation, Inc.
c906108c
SS
3
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.
13#
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.
17
18# Please email any bugs, comments, and/or additions to this file to:
19# bug-gdb@prep.ai.mit.edu
20
21# This file was written by Rob Savoye. (rob@cygnus.com)
22
23# These tests don't work for targets can't take arguments...
24
25if [target_info exists noargs] then {
26 verbose "Skipping a2-run.exp because of noargs."
27 return
28}
29
958a4e4c
MS
30# Can't do this test without stdio support.
31if [gdb_skip_stdio_test "a2run.exp"] {
c906108c
SS
32 return
33}
34
35if $tracelevel then {
36 strace $tracelevel
37}
38
39#
40# test running programs
41#
42set prms_id 0
43set bug_id 0
44
45set testfile "run"
46set srcfile ${testfile}.c
47set binfile ${objdir}/${subdir}/${testfile}
48if { [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."
50}
51
52gdb_exit
53gdb_start
54gdb_reinitialize_dir $srcdir/$subdir
55gdb_load ${binfile}
56
57# Run with no arguments.
58# On VxWorks this justs make sure the program was run.
59gdb_run_cmd
60
61if [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"
67 }
68 -re "usage: factorial <number>" {
69 pass "run \"$testfile\" with no args"
70 }
71 timeout {
72 fail "(timeout) run \"$testfile\" with no args"
73 }
74 }
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"
82 }
83 -re ".*$gdb_prompt $" {
84 fail "run \"$testfile\" with no args"
85 verbose "expect_out is $expect_out(buffer)" 2
86 }
87 timeout {
88 fail "(timeout) run \"$testfile\" no args"
89 }
90 }
91}
92# Now run with some arguments
93if [istarget "*-*-vxworks*"] then {
94 send_gdb "run vxmain \"5\"\n"
95 gdb_expect -re "run vxmain \"5\"\r\n" {}
96 set timeout 120
97 verbose "Timeout is now $timeout seconds" 2
98 gdb_expect {
99 "Program exited normally" {
100 unresolved "run \"$testfile\" with arg"
101 }
102 "120" {
103 pass "run \"$testfile\" with arg"
104 }
105 timeout {
106 fail "(timeout) run \"$testfile\" with arg"
107 }
108 }
109 set timeout 10
110 verbose "Timeout is now $timeout seconds" 2
111 gdb_expect -re "$gdb_prompt $" {}
112} else {
7a292a7a 113 setup_xfail "mips-idt-*" "arm-*-coff strongarm-*-coff"
c906108c
SS
114 gdb_run_cmd 5
115 gdb_expect {
116 -re ".*120.*$gdb_prompt $"\
117 { pass "run \"$testfile\" with arg" }
118 -re ".*$gdb_prompt $" { fail "run \"$testfile\" with arg" }
119 timeout { fail "(timeout) run \"$testfile\" with arg" }
120 }
121}
122
123# Run again with same arguments.
124setup_xfail "mips-idt-*"
125gdb_run_cmd
126
127if [istarget "*-*-vxworks*"] then {
128 set timeout 120
129 verbose "Timeout is now $timeout seconds" 2
130 gdb_expect {
131 "Program exited normally" {
132 unresolved "run \"$testfile\" again with same args"
133 }
134 "120" { pass "run \"$testfile\" again with same args" }
135 timeout { fail "(timeout) run \"$testfile\" again with same args" }
136 }
137 set timeout 10
138 verbose "Timeout is now $timeout seconds" 2
139 gdb_expect -re "$gdb_prompt $" {}
140} else {
7a292a7a 141 setup_xfail "arm-*-coff strongarm-*-coff"
c906108c
SS
142 gdb_expect {
143 -re ".*120.*$gdb_prompt $"\
144 { pass "run \"$testfile\" again with same args" }
145 -re ".*$gdb_prompt $" { fail "run \"$testfile\" again with same args" }
146 timeout { fail "(timeout) run \"$testfile\" again with same args" }
147 }
148}
149
150# Use "set args" command to specify no arguments as default and run again.
151if [istarget "*-*-vxworks*"] then {
152 send_gdb "set args main\n"
153} else {
154 send_gdb "set args\n"
155}
156gdb_expect -re "$gdb_prompt $"
157
158gdb_run_cmd
159
160if [istarget "*-*-vxworks*"] then {
161 set timeout 120
162 verbose "Timeout is now $timeout seconds" 2
163 gdb_expect {
164 "Program exited normally" {
165 unresolved "run after setting args to nil"
166 }
167 "usage: factorial <number>" {
168 pass "run after setting args to nil"
169 }
170 timeout {
171 fail "(timeout) run after setting args to nil"
172 }
173 }
174 set timeout 10
175 verbose "Timeout is now $timeout seconds" 2
176 gdb_expect -re "$gdb_prompt $" {}
177} else {
178 gdb_expect {
179 -re ".*usage: factorial <number>.*$gdb_prompt $" {
180 pass "run after setting args to nil"
181 }
182 -re ".*$gdb_prompt $" {
183 fail "run after setting args to nil"
184 }
185 timeout {
186 fail "(timeout) run after setting args to nil"
187 }
188 }
189}
190
191# Use "set args" command to specify an argument and run again.
192setup_xfail "mips-idt-*"
193if [istarget "*-*-vxworks*"] then {
194 send_gdb "set args vxmain \"6\"\n"
195} else {
196 send_gdb "set args 6\n"
197}
198gdb_expect -re "$gdb_prompt $"
199gdb_run_cmd
200
201if [istarget "*-*-vxworks*"] then {
202 set timeout 120
203 verbose "Timeout is now $timeout seconds" 2
204 gdb_expect {
205 "Program exited normally" {
206 unresolved "run \"$testfile\" again after setting args"
207 }
208 "720" {
209 pass "run \"$testfile\" again after setting args"
210 }
211 timeout {
212 fail "(timeout) run \"$testfile\" again after setting args"
213 }
214 }
215 set timeout 10
216 verbose "Timeout is now $timeout seconds" 2
217 gdb_expect -re "$gdb_prompt $" {}
218} else {
7a292a7a 219 setup_xfail "arm-*-coff strongarm-*-coff"
c906108c
SS
220 gdb_expect {
221 -re ".*720.*$gdb_prompt $" {
222 pass "run \"$testfile\" again after setting args"
223 }
224 -re ".*$gdb_prompt $" {
225 fail "run \"$testfile\" again after setting args"
226 }
227 timeout {
228 fail "(timeout) run \"$testfile\" again after setting args"
229 }
230 }
231}
232
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.
676a0442 235if ![is_remote target] then {
c906108c
SS
236 send_gdb "run `echo 8`\n"
237 gdb_expect {
238 -re "Starting program.*40320.*$gdb_prompt $" {
239 pass "run \"$testfile\" with shell"
240 }
241 -re ".*$gdb_prompt $" {
242 fail "run \"$testfile\" with shell"
243 }
244 timeout {
245 fail "(timeout) run \"$testfile\" with shell"
246 }
247 }
248}
249
250# Reset the default arguments for VxWorks
251if [istarget "*-*-vxworks*"] then {
252 send_gdb "set args main\n"
253 gdb_expect -re ".*$gdb_prompt $" {}
254}
This page took 0.239615 seconds and 4 git commands to generate.