]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/all-bin.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / all-bin.exp
1 # Copyright 1998, 1999, 2007 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
21
22 # This file is part of the gdb testsuite
23 #
24 # tests for arithmetic, logical and relational operators
25 # with mixed types
26 #
27
28
29
30 if $tracelevel then {
31 strace $tracelevel
32 }
33
34 #
35 # test running programs
36 #
37 set prms_id 0
38 set bug_id 0
39
40 set testfile "all-types"
41 set srcfile ${testfile}.c
42 set binfile ${objdir}/${subdir}/${testfile}
43
44 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
45 untested all-bin.exp
46 return -1
47 }
48
49 if [get_compiler_info ${binfile}] {
50 return -1
51 }
52
53 gdb_exit
54 gdb_start
55 gdb_reinitialize_dir $srcdir/$subdir
56 gdb_load ${binfile}
57
58
59 #
60 # set it up at a breakpoint so we can play with the variable values
61 #
62
63 if ![runto_main] then {
64 perror "couldn't run to breakpoint"
65 continue
66 }
67
68 gdb_test "next" "return 0;" "continuing after dummy()"
69
70 send_gdb "print v_int+v_char\n"
71 gdb_expect {
72 -re ".*71.*$gdb_prompt $" {
73 pass "print value of v_int+v_char"
74 }
75 -re ".*$gdb_prompt $" { fail "print value of v_int+v_char" }
76 timeout { fail "(timeout) print value of v_int+v_char" }
77 }
78
79 send_gdb "print v_int+v_short\n"
80 gdb_expect {
81 -re ".*9.*$gdb_prompt $" {
82 pass "print value of v_int+v_short"
83 }
84 -re ".*$gdb_prompt $" { fail "print value of v_int+v_short" }
85 timeout { fail "(timeout) print value of v_int+v_short" }
86 }
87
88
89 send_gdb "print v_int+v_signed_char\n"
90 gdb_expect {
91 -re ".*72.*$gdb_prompt $" {
92 pass "print value of v_int+v_signed_char"
93 }
94 -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_char" }
95 timeout { fail "(timeout) print value of v_int+v_signed_char" }
96 }
97
98
99 send_gdb "print v_int+v_unsigned_char\n"
100 gdb_expect {
101 -re ".*73.*$gdb_prompt $" {
102 pass "print value of v_int+v_unsigned_char"
103 }
104 -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_char" }
105 timeout { fail "(timeout) print value of v_int+v_unsigned_char" }
106 }
107
108
109 send_gdb "print v_int+v_signed_short\n"
110 gdb_expect {
111 -re ".*10.*$gdb_prompt $" {
112 pass "print value of v_int+v_signed_short"
113 }
114 -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_short" }
115 timeout { fail "(timeout) print value of v_int+v_signed_short" }
116 }
117
118
119 send_gdb "print v_int+v_unsigned_short\n"
120 gdb_expect {
121 -re ".*11.*$gdb_prompt $" {
122 pass "print value of v_int+v_unsigned_short"
123 }
124 -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_short" }
125 timeout { fail "(timeout) print value of v_int+v_unsigned_short" }
126 }
127
128
129 send_gdb "print v_int+v_signed_int\n"
130 gdb_expect {
131 -re ".*13.*$gdb_prompt $" {
132 pass "print value of v_int+v_signed_int"
133 }
134 -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_int" }
135 timeout { fail "(timeout) print value of v_int+v_signed_int" }
136 }
137
138
139 send_gdb "print v_int+v_unsigned_int\n"
140 gdb_expect {
141 -re ".*14.*$gdb_prompt $" {
142 pass "print value of v_int+v_unsigned_int"
143 }
144 -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_int" }
145 timeout { fail "(timeout) print value of v_int+v_unsigned_int" }
146 }
147
148
149 send_gdb "print v_int+v_long\n"
150 gdb_expect {
151 -re ".*15.*$gdb_prompt $" {
152 pass "print value of v_int+v_long"
153 }
154 -re ".*$gdb_prompt $" { fail "print value of v_int+v_long" }
155 timeout { fail "(timeout) print value of v_int+v_long" }
156 }
157
158
159 send_gdb "print v_int+v_signed_long\n"
160 gdb_expect {
161 -re ".*16.*$gdb_prompt $" {
162 pass "print value of v_int+v_signed_long"
163 }
164 -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_long" }
165 timeout { fail "(timeout) print value of v_int+v_signed_long" }
166 }
167
168
169 send_gdb "print v_int+v_unsigned_long\n"
170 gdb_expect {
171 -re ".*17.*$gdb_prompt $" {
172 pass "print value of v_int+v_unsigned_long"
173 }
174 -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_long" }
175 timeout { fail "(timeout) print value of v_int+v_unsigned_long" }
176 }
177
178
179 send_gdb "print v_int+v_float\n"
180 gdb_expect {
181 -re ".*106.34343.*$gdb_prompt $" {
182 pass "print value of v_int+v_float"
183 }
184 -re ".*$gdb_prompt $" { fail "print value of v_int+v_float" }
185 timeout { fail "(timeout) print value of v_int+v_float" }
186 }
187
188
189 send_gdb "print v_int+v_double\n"
190 gdb_expect {
191 -re ".*206.565.*$gdb_prompt $" {
192 pass "print value of v_int+v_double"
193 }
194 -re ".*$gdb_prompt $" { fail "print value of v_int+v_double" }
195 timeout { fail "(timeout) print value of v_int+v_double" }
196 }
197
198
199 #
200 # test the relational operators with mixed types
201 #
202
203 send_gdb "print v_int <= v_char\n"
204 gdb_expect {
205 -re ".*1.*$gdb_prompt $" {
206 pass "print value of v_int<=v_char"
207 }
208 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_char" }
209 timeout { fail "(timeout) print value of v_int<=v_char" }
210 }
211
212 send_gdb "print v_int <= v_short\n"
213 gdb_expect {
214 -re ".*$false.*$gdb_prompt $" {
215 pass "print value of v_int<=v_short"
216 }
217 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_short" }
218 timeout { fail "(timeout) print value of v_int<=v_short" }
219 }
220
221
222 send_gdb "print v_int <= v_signed_char\n"
223 gdb_expect {
224 -re ".*1.*$gdb_prompt $" {
225 pass "print value of v_int<=v_signed_char"
226 }
227 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_char" }
228 timeout { fail "(timeout) print value of v_int<=v_signed_char" }
229 }
230
231
232 send_gdb "print v_int <= v_unsigned_char\n"
233 gdb_expect {
234 -re ".*1.*$gdb_prompt $" {
235 pass "print value of v_int<=v_unsigned_char"
236 }
237 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_char" }
238 timeout { fail "(timeout) print value of v_int<=v_unsigned_char" }
239 }
240
241
242 send_gdb "print v_int <= v_signed_short\n"
243 gdb_expect {
244 -re ".*$false.*$gdb_prompt $" {
245 pass "print value of v_int<=v_signed_short"
246 }
247 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_short" }
248 timeout { fail "(timeout) print value of v_int<=v_signed_short" }
249 }
250
251
252 send_gdb "print v_int <= v_unsigned_short\n"
253 gdb_expect {
254 -re ".*$false.*$gdb_prompt $" {
255 pass "print value of v_int<=v_unsigned_short"
256 }
257 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_short" }
258 timeout { fail "(timeout) print value of v_int<=v_unsigned_short" }
259 }
260
261
262 send_gdb "print v_int <= v_signed_int\n"
263 gdb_expect {
264 -re ".*$true.*$gdb_prompt $" {
265 pass "print value of v_int<=v_signed_int"
266 }
267 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_int" }
268 timeout { fail "(timeout) print value of v_int<=v_signed_int" }
269 }
270
271
272 send_gdb "print v_int <= v_unsigned_int\n"
273 gdb_expect {
274 -re ".*$true.*$gdb_prompt $" {
275 pass "print value of v_int<=v_unsigned_int"
276 }
277 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_int" }
278 timeout { fail "(timeout) print value of v_int<=v_unsigned_int" }
279 }
280
281
282 send_gdb "print v_int <= v_long\n"
283 gdb_expect {
284 -re ".*$true.*$gdb_prompt $" {
285 pass "print value of v_int<=v_long"
286 }
287 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_long" }
288 timeout { fail "(timeout) print value of v_int<=v_long" }
289 }
290
291
292 send_gdb "print v_int <= v_signed_long\n"
293 gdb_expect {
294 -re ".*$true.*$gdb_prompt $" {
295 pass "print value of v_int<=v_signed_long"
296 }
297 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_long" }
298 timeout { fail "(timeout) print value of v_int<=v_signed_long" }
299 }
300
301
302 send_gdb "print v_int <= v_unsigned_long\n"
303 gdb_expect {
304 -re ".*$true.*$gdb_prompt $" {
305 pass "print value of v_int<=v_unsigned_long"
306 }
307 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_long" }
308 timeout { fail "(timeout) print value of v_int<=v_unsigned_long" }
309 }
310
311
312 send_gdb "print v_int <= v_float\n"
313 gdb_expect {
314 -re ".*$true.*$gdb_prompt $" {
315 pass "print value of v_int<=v_float"
316 }
317 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_float" }
318 timeout { fail "(timeout) print value of v_int<=v_float" }
319 }
320
321
322 send_gdb "print v_int <= v_double\n"
323 gdb_expect {
324 -re ".*$true.*$gdb_prompt $" {
325 pass "print value of v_int<=v_double"
326 }
327 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_double" }
328 timeout { fail "(timeout) print value of v_int<=v_double" }
329 }
330
331
332
333 #
334 # test the logical operators with mixed types
335 #
336
337 gdb_test "set variable v_char=0" "" "set v_char=0"
338 gdb_test "set variable v_double=0.0" "" "set v_double=0"
339 gdb_test "set variable v_unsigned_long=0" "" "set v_unsigned_long=0"
340
341 send_gdb "print v_int && v_char\n"
342 gdb_expect {
343 -re ".*$false.*$gdb_prompt $" {
344 pass "print value of v_int&&v_char"
345 }
346 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_char" }
347 timeout { fail "(timeout) print value of v_int&&v_char" }
348 }
349
350 send_gdb "print v_int && v_short\n"
351 gdb_expect {
352 -re ".*$true.*$gdb_prompt $" {
353 pass "print value of v_int&&v_short"
354 }
355 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_short" }
356 timeout { fail "(timeout) print value of v_int&&v_short" }
357 }
358
359
360 send_gdb "print v_int && v_signed_char\n"
361 gdb_expect {
362 -re ".*$true.*$gdb_prompt $" {
363 pass "print value of v_int&&v_signed_char"
364 }
365 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_char" }
366 timeout { fail "(timeout) print value of v_int&&v_signed_char" }
367 }
368
369
370 send_gdb "print v_int && v_unsigned_char\n"
371 gdb_expect {
372 -re ".*$true.*$gdb_prompt $" {
373 pass "print value of v_int&&v_unsigned_char"
374 }
375 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_char" }
376 timeout { fail "(timeout) print value of v_int&&v_unsigned_char" }
377 }
378
379
380 send_gdb "print v_int && v_signed_short\n"
381 gdb_expect {
382 -re ".*$true.*$gdb_prompt $" {
383 pass "print value of v_int&&v_signed_short"
384 }
385 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_short" }
386 timeout { fail "(timeout) print value of v_int&&v_signed_short" }
387 }
388
389
390 send_gdb "print v_int && v_unsigned_short\n"
391 gdb_expect {
392 -re ".*$true.*$gdb_prompt $" {
393 pass "print value of v_int&&v_unsigned_short"
394 }
395 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_short" }
396 timeout { fail "(timeout) print value of v_int&&v_unsigned_short" }
397 }
398
399
400 send_gdb "print v_int && v_signed_int\n"
401 gdb_expect {
402 -re ".*$true.*$gdb_prompt $" {
403 pass "print value of v_int&&v_signed_int"
404 }
405 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_int" }
406 timeout { fail "(timeout) print value of v_int&&v_signed_int" }
407 }
408
409
410 send_gdb "print v_int && v_unsigned_int\n"
411 gdb_expect {
412 -re ".*$true.*$gdb_prompt $" {
413 pass "print value of v_int&&v_unsigned_int"
414 }
415 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_int" }
416 timeout { fail "(timeout) print value of v_int&&v_unsigned_int" }
417 }
418
419
420 send_gdb "print v_int && v_long\n"
421 gdb_expect {
422 -re ".*$true.*$gdb_prompt $" {
423 pass "print value of v_int&&v_long"
424 }
425 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_long" }
426 timeout { fail "(timeout) print value of v_int&&v_long" }
427 }
428
429
430 send_gdb "print v_int && v_signed_long\n"
431 gdb_expect {
432 -re ".*$true.*$gdb_prompt $" {
433 pass "print value of v_int&&v_signed_long"
434 }
435 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_long" }
436 timeout { fail "(timeout) print value of v_int&&v_signed_long" }
437 }
438
439
440 send_gdb "print v_int && v_unsigned_long\n"
441 gdb_expect {
442 -re ".*$false.*$gdb_prompt $" {
443 pass "print value of v_int&&v_unsigned_long"
444 }
445 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_long" }
446 timeout { fail "(timeout) print value of v_int&&v_unsigned_long" }
447 }
448
449
450 send_gdb "print v_int && v_float\n"
451 gdb_expect {
452 -re ".*$true.*$gdb_prompt $" {
453 pass "print value of v_int&&v_float"
454 }
455 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_float" }
456 timeout { fail "(timeout) print value of v_int&&v_float" }
457 }
458
459
460 send_gdb "print v_int && v_double\n"
461 gdb_expect {
462 -re ".*$false.*$gdb_prompt $" {
463 pass "print value of v_int&&v_double"
464 }
465 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_double" }
466 timeout { fail "(timeout) print value of v_int&&v_double" }
467 }
468
469
470
471
472