1 # Copyright
1998, 1999 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
2 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
, write to the Free Software
15 # Foundation
, Inc.
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
17 # Please email
any bugs
, comments
, and
/or additions to this file to
:
18 # bug
-gdb@prep.ai.mit.edu
20 # This file was written by Elena Zannoni
(ezannoni@cygnus.com
)
22 # This file is part of the gdb testsuite
24 # tests
for arithmetic
, logical and relational operators
35 # test running programs
40 set testfile
"all-types"
41 set srcfile $
{testfile
}.c
42 set binfile $
{objdir
}/$
{subdir
}/$
{testfile
}
44 if { [gdb_compile
"${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
45 gdb_suppress_entire_file
"Testcase compile failed, so all tests in this file will automatically fail."
48 if [get_compiler_info $
{binfile
}] {
54 gdb_reinitialize_dir $srcdir
/$subdir
59 #
set it up at a breakpoint so we can play with the
variable values
62 if ![runto_main
] then {
63 perror
"couldn't run to breakpoint"
67 gdb_test
"next" "return 0;" "continuing after dummy()"
69 send_gdb
"print v_int+v_char\n"
71 -re
".*71.*$gdb_prompt $" {
72 pass
"print value of v_int+v_char"
74 -re
".*$gdb_prompt $" { fail "print value of v_int+v_char" }
75 timeout
{ fail
"(timeout) print value of v_int+v_char" }
78 send_gdb
"print v_int+v_short\n"
80 -re
".*9.*$gdb_prompt $" {
81 pass
"print value of v_int+v_short"
83 -re
".*$gdb_prompt $" { fail "print value of v_int+v_short" }
84 timeout
{ fail
"(timeout) print value of v_int+v_short" }
88 send_gdb
"print v_int+v_signed_char\n"
90 -re
".*72.*$gdb_prompt $" {
91 pass
"print value of v_int+v_signed_char"
93 -re
".*$gdb_prompt $" { fail "print value of v_int+v_signed_char" }
94 timeout
{ fail
"(timeout) print value of v_int+v_signed_char" }
98 send_gdb
"print v_int+v_unsigned_char\n"
100 -re
".*73.*$gdb_prompt $" {
101 pass
"print value of v_int+v_unsigned_char"
103 -re
".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_char" }
104 timeout
{ fail
"(timeout) print value of v_int+v_unsigned_char" }
108 send_gdb
"print v_int+v_signed_short\n"
110 -re
".*10.*$gdb_prompt $" {
111 pass
"print value of v_int+v_signed_short"
113 -re
".*$gdb_prompt $" { fail "print value of v_int+v_signed_short" }
114 timeout
{ fail
"(timeout) print value of v_int+v_signed_short" }
118 send_gdb
"print v_int+v_unsigned_short\n"
120 -re
".*11.*$gdb_prompt $" {
121 pass
"print value of v_int+v_unsigned_short"
123 -re
".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_short" }
124 timeout
{ fail
"(timeout) print value of v_int+v_unsigned_short" }
128 send_gdb
"print v_int+v_signed_int\n"
130 -re
".*13.*$gdb_prompt $" {
131 pass
"print value of v_int+v_signed_int"
133 -re
".*$gdb_prompt $" { fail "print value of v_int+v_signed_int" }
134 timeout
{ fail
"(timeout) print value of v_int+v_signed_int" }
138 send_gdb
"print v_int+v_unsigned_int\n"
140 -re
".*14.*$gdb_prompt $" {
141 pass
"print value of v_int+v_unsigned_int"
143 -re
".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_int" }
144 timeout
{ fail
"(timeout) print value of v_int+v_unsigned_int" }
148 send_gdb
"print v_int+v_long\n"
150 -re
".*15.*$gdb_prompt $" {
151 pass
"print value of v_int+v_long"
153 -re
".*$gdb_prompt $" { fail "print value of v_int+v_long" }
154 timeout
{ fail
"(timeout) print value of v_int+v_long" }
158 send_gdb
"print v_int+v_signed_long\n"
160 -re
".*16.*$gdb_prompt $" {
161 pass
"print value of v_int+v_signed_long"
163 -re
".*$gdb_prompt $" { fail "print value of v_int+v_signed_long" }
164 timeout
{ fail
"(timeout) print value of v_int+v_signed_long" }
168 send_gdb
"print v_int+v_unsigned_long\n"
170 -re
".*17.*$gdb_prompt $" {
171 pass
"print value of v_int+v_unsigned_long"
173 -re
".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_long" }
174 timeout
{ fail
"(timeout) print value of v_int+v_unsigned_long" }
178 send_gdb
"print v_int+v_float\n"
180 -re
".*106.34343.*$gdb_prompt $" {
181 pass
"print value of v_int+v_float"
183 -re
".*$gdb_prompt $" { fail "print value of v_int+v_float" }
184 timeout
{ fail
"(timeout) print value of v_int+v_float" }
188 send_gdb
"print v_int+v_double\n"
190 -re
".*206.565.*$gdb_prompt $" {
191 pass
"print value of v_int+v_double"
193 -re
".*$gdb_prompt $" { fail "print value of v_int+v_double" }
194 timeout
{ fail
"(timeout) print value of v_int+v_double" }
199 # test the relational operators with mixed types
202 send_gdb
"print v_int <= v_char\n"
204 -re
".*1.*$gdb_prompt $" {
205 pass
"print value of v_int<=v_char"
207 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_char" }
208 timeout
{ fail
"(timeout) print value of v_int<=v_char" }
211 send_gdb
"print v_int <= v_short\n"
213 -re
".*$false.*$gdb_prompt $" {
214 pass
"print value of v_int<=v_short"
216 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_short" }
217 timeout
{ fail
"(timeout) print value of v_int<=v_short" }
221 send_gdb
"print v_int <= v_signed_char\n"
223 -re
".*1.*$gdb_prompt $" {
224 pass
"print value of v_int<=v_signed_char"
226 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_signed_char" }
227 timeout
{ fail
"(timeout) print value of v_int<=v_signed_char" }
231 send_gdb
"print v_int <= v_unsigned_char\n"
233 -re
".*1.*$gdb_prompt $" {
234 pass
"print value of v_int<=v_unsigned_char"
236 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_char" }
237 timeout
{ fail
"(timeout) print value of v_int<=v_unsigned_char" }
241 send_gdb
"print v_int <= v_signed_short\n"
243 -re
".*$false.*$gdb_prompt $" {
244 pass
"print value of v_int<=v_signed_short"
246 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_signed_short" }
247 timeout
{ fail
"(timeout) print value of v_int<=v_signed_short" }
251 send_gdb
"print v_int <= v_unsigned_short\n"
253 -re
".*$false.*$gdb_prompt $" {
254 pass
"print value of v_int<=v_unsigned_short"
256 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_short" }
257 timeout
{ fail
"(timeout) print value of v_int<=v_unsigned_short" }
261 send_gdb
"print v_int <= v_signed_int\n"
263 -re
".*$true.*$gdb_prompt $" {
264 pass
"print value of v_int<=v_signed_int"
266 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_signed_int" }
267 timeout
{ fail
"(timeout) print value of v_int<=v_signed_int" }
271 send_gdb
"print v_int <= v_unsigned_int\n"
273 -re
".*$true.*$gdb_prompt $" {
274 pass
"print value of v_int<=v_unsigned_int"
276 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_int" }
277 timeout
{ fail
"(timeout) print value of v_int<=v_unsigned_int" }
281 send_gdb
"print v_int <= v_long\n"
283 -re
".*$true.*$gdb_prompt $" {
284 pass
"print value of v_int<=v_long"
286 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_long" }
287 timeout
{ fail
"(timeout) print value of v_int<=v_long" }
291 send_gdb
"print v_int <= v_signed_long\n"
293 -re
".*$true.*$gdb_prompt $" {
294 pass
"print value of v_int<=v_signed_long"
296 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_signed_long" }
297 timeout
{ fail
"(timeout) print value of v_int<=v_signed_long" }
301 send_gdb
"print v_int <= v_unsigned_long\n"
303 -re
".*$true.*$gdb_prompt $" {
304 pass
"print value of v_int<=v_unsigned_long"
306 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_long" }
307 timeout
{ fail
"(timeout) print value of v_int<=v_unsigned_long" }
311 send_gdb
"print v_int <= v_float\n"
313 -re
".*$true.*$gdb_prompt $" {
314 pass
"print value of v_int<=v_float"
316 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_float" }
317 timeout
{ fail
"(timeout) print value of v_int<=v_float" }
321 send_gdb
"print v_int <= v_double\n"
323 -re
".*$true.*$gdb_prompt $" {
324 pass
"print value of v_int<=v_double"
326 -re
".*$gdb_prompt $" { fail "print value of v_int<=v_double" }
327 timeout
{ fail
"(timeout) print value of v_int<=v_double" }
333 # test the logical operators with mixed types
336 gdb_test
"set variable v_char=0" "" "set v_char=0"
337 gdb_test
"set variable v_double=0.0" "" "set v_double=0"
338 gdb_test
"set variable v_unsigned_long=0" "" "set v_unsigned_long=0"
340 send_gdb
"print v_int && v_char\n"
342 -re
".*$false.*$gdb_prompt $" {
343 pass
"print value of v_int&&v_char"
345 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_char" }
346 timeout
{ fail
"(timeout) print value of v_int&&v_char" }
349 send_gdb
"print v_int && v_short\n"
351 -re
".*$true.*$gdb_prompt $" {
352 pass
"print value of v_int&&v_short"
354 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_short" }
355 timeout
{ fail
"(timeout) print value of v_int&&v_short" }
359 send_gdb
"print v_int && v_signed_char\n"
361 -re
".*$true.*$gdb_prompt $" {
362 pass
"print value of v_int&&v_signed_char"
364 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_signed_char" }
365 timeout
{ fail
"(timeout) print value of v_int&&v_signed_char" }
369 send_gdb
"print v_int && v_unsigned_char\n"
371 -re
".*$true.*$gdb_prompt $" {
372 pass
"print value of v_int&&v_unsigned_char"
374 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_char" }
375 timeout
{ fail
"(timeout) print value of v_int&&v_unsigned_char" }
379 send_gdb
"print v_int && v_signed_short\n"
381 -re
".*$true.*$gdb_prompt $" {
382 pass
"print value of v_int&&v_signed_short"
384 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_signed_short" }
385 timeout
{ fail
"(timeout) print value of v_int&&v_signed_short" }
389 send_gdb
"print v_int && v_unsigned_short\n"
391 -re
".*$true.*$gdb_prompt $" {
392 pass
"print value of v_int&&v_unsigned_short"
394 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_short" }
395 timeout
{ fail
"(timeout) print value of v_int&&v_unsigned_short" }
399 send_gdb
"print v_int && v_signed_int\n"
401 -re
".*$true.*$gdb_prompt $" {
402 pass
"print value of v_int&&v_signed_int"
404 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_signed_int" }
405 timeout
{ fail
"(timeout) print value of v_int&&v_signed_int" }
409 send_gdb
"print v_int && v_unsigned_int\n"
411 -re
".*$true.*$gdb_prompt $" {
412 pass
"print value of v_int&&v_unsigned_int"
414 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_int" }
415 timeout
{ fail
"(timeout) print value of v_int&&v_unsigned_int" }
419 send_gdb
"print v_int && v_long\n"
421 -re
".*$true.*$gdb_prompt $" {
422 pass
"print value of v_int&&v_long"
424 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_long" }
425 timeout
{ fail
"(timeout) print value of v_int&&v_long" }
429 send_gdb
"print v_int && v_signed_long\n"
431 -re
".*$true.*$gdb_prompt $" {
432 pass
"print value of v_int&&v_signed_long"
434 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_signed_long" }
435 timeout
{ fail
"(timeout) print value of v_int&&v_signed_long" }
439 send_gdb
"print v_int && v_unsigned_long\n"
441 -re
".*$false.*$gdb_prompt $" {
442 pass
"print value of v_int&&v_unsigned_long"
444 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_long" }
445 timeout
{ fail
"(timeout) print value of v_int&&v_unsigned_long" }
449 send_gdb
"print v_int && v_float\n"
451 -re
".*$true.*$gdb_prompt $" {
452 pass
"print value of v_int&&v_float"
454 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_float" }
455 timeout
{ fail
"(timeout) print value of v_int&&v_float" }
459 send_gdb
"print v_int && v_double\n"
461 -re
".*$false.*$gdb_prompt $" {
462 pass
"print value of v_int&&v_double"
464 -re
".*$gdb_prompt $" { fail "print value of v_int&&v_double" }
465 timeout
{ fail
"(timeout) print value of v_int&&v_double" }