1 # Copyright 1998, 1999, 2007 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}] != "" } {
49 if [get_compiler_info ${binfile}] {
55 gdb_reinitialize_dir $srcdir/$subdir
60 # set it up at a breakpoint so we can play with the variable values
63 if ![runto_main] then {
64 perror "couldn't run to breakpoint"
68 gdb_test "next" "return 0;" "continuing after dummy()"
70 send_gdb "print v_int+v_char\n"
72 -re ".*71.*$gdb_prompt $" {
73 pass "print value of v_int+v_char"
75 -re ".*$gdb_prompt $" { fail "print value of v_int+v_char" }
76 timeout { fail "(timeout) print value of v_int+v_char" }
79 send_gdb "print v_int+v_short\n"
81 -re ".*9.*$gdb_prompt $" {
82 pass "print value of v_int+v_short"
84 -re ".*$gdb_prompt $" { fail "print value of v_int+v_short" }
85 timeout { fail "(timeout) print value of v_int+v_short" }
89 send_gdb "print v_int+v_signed_char\n"
91 -re ".*72.*$gdb_prompt $" {
92 pass "print value of v_int+v_signed_char"
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" }
99 send_gdb "print v_int+v_unsigned_char\n"
101 -re ".*73.*$gdb_prompt $" {
102 pass "print value of v_int+v_unsigned_char"
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" }
109 send_gdb "print v_int+v_signed_short\n"
111 -re ".*10.*$gdb_prompt $" {
112 pass "print value of v_int+v_signed_short"
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" }
119 send_gdb "print v_int+v_unsigned_short\n"
121 -re ".*11.*$gdb_prompt $" {
122 pass "print value of v_int+v_unsigned_short"
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" }
129 send_gdb "print v_int+v_signed_int\n"
131 -re ".*13.*$gdb_prompt $" {
132 pass "print value of v_int+v_signed_int"
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" }
139 send_gdb "print v_int+v_unsigned_int\n"
141 -re ".*14.*$gdb_prompt $" {
142 pass "print value of v_int+v_unsigned_int"
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" }
149 send_gdb "print v_int+v_long\n"
151 -re ".*15.*$gdb_prompt $" {
152 pass "print value of v_int+v_long"
154 -re ".*$gdb_prompt $" { fail "print value of v_int+v_long" }
155 timeout { fail "(timeout) print value of v_int+v_long" }
159 send_gdb "print v_int+v_signed_long\n"
161 -re ".*16.*$gdb_prompt $" {
162 pass "print value of v_int+v_signed_long"
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" }
169 send_gdb "print v_int+v_unsigned_long\n"
171 -re ".*17.*$gdb_prompt $" {
172 pass "print value of v_int+v_unsigned_long"
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" }
179 send_gdb "print v_int+v_float\n"
181 -re ".*106.34343.*$gdb_prompt $" {
182 pass "print value of v_int+v_float"
184 -re ".*$gdb_prompt $" { fail "print value of v_int+v_float" }
185 timeout { fail "(timeout) print value of v_int+v_float" }
189 send_gdb "print v_int+v_double\n"
191 -re ".*206.565.*$gdb_prompt $" {
192 pass "print value of v_int+v_double"
194 -re ".*$gdb_prompt $" { fail "print value of v_int+v_double" }
195 timeout { fail "(timeout) print value of v_int+v_double" }
200 # test the relational operators with mixed types
203 send_gdb "print v_int <= v_char\n"
205 -re ".*1.*$gdb_prompt $" {
206 pass "print value of v_int<=v_char"
208 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_char" }
209 timeout { fail "(timeout) print value of v_int<=v_char" }
212 send_gdb "print v_int <= v_short\n"
214 -re ".*$false.*$gdb_prompt $" {
215 pass "print value of v_int<=v_short"
217 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_short" }
218 timeout { fail "(timeout) print value of v_int<=v_short" }
222 send_gdb "print v_int <= v_signed_char\n"
224 -re ".*1.*$gdb_prompt $" {
225 pass "print value of v_int<=v_signed_char"
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" }
232 send_gdb "print v_int <= v_unsigned_char\n"
234 -re ".*1.*$gdb_prompt $" {
235 pass "print value of v_int<=v_unsigned_char"
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" }
242 send_gdb "print v_int <= v_signed_short\n"
244 -re ".*$false.*$gdb_prompt $" {
245 pass "print value of v_int<=v_signed_short"
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" }
252 send_gdb "print v_int <= v_unsigned_short\n"
254 -re ".*$false.*$gdb_prompt $" {
255 pass "print value of v_int<=v_unsigned_short"
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" }
262 send_gdb "print v_int <= v_signed_int\n"
264 -re ".*$true.*$gdb_prompt $" {
265 pass "print value of v_int<=v_signed_int"
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" }
272 send_gdb "print v_int <= v_unsigned_int\n"
274 -re ".*$true.*$gdb_prompt $" {
275 pass "print value of v_int<=v_unsigned_int"
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" }
282 send_gdb "print v_int <= v_long\n"
284 -re ".*$true.*$gdb_prompt $" {
285 pass "print value of v_int<=v_long"
287 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_long" }
288 timeout { fail "(timeout) print value of v_int<=v_long" }
292 send_gdb "print v_int <= v_signed_long\n"
294 -re ".*$true.*$gdb_prompt $" {
295 pass "print value of v_int<=v_signed_long"
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" }
302 send_gdb "print v_int <= v_unsigned_long\n"
304 -re ".*$true.*$gdb_prompt $" {
305 pass "print value of v_int<=v_unsigned_long"
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" }
312 send_gdb "print v_int <= v_float\n"
314 -re ".*$true.*$gdb_prompt $" {
315 pass "print value of v_int<=v_float"
317 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_float" }
318 timeout { fail "(timeout) print value of v_int<=v_float" }
322 send_gdb "print v_int <= v_double\n"
324 -re ".*$true.*$gdb_prompt $" {
325 pass "print value of v_int<=v_double"
327 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_double" }
328 timeout { fail "(timeout) print value of v_int<=v_double" }
334 # test the logical operators with mixed types
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"
341 send_gdb "print v_int && v_char\n"
343 -re ".*$false.*$gdb_prompt $" {
344 pass "print value of v_int&&v_char"
346 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_char" }
347 timeout { fail "(timeout) print value of v_int&&v_char" }
350 send_gdb "print v_int && v_short\n"
352 -re ".*$true.*$gdb_prompt $" {
353 pass "print value of v_int&&v_short"
355 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_short" }
356 timeout { fail "(timeout) print value of v_int&&v_short" }
360 send_gdb "print v_int && v_signed_char\n"
362 -re ".*$true.*$gdb_prompt $" {
363 pass "print value of v_int&&v_signed_char"
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" }
370 send_gdb "print v_int && v_unsigned_char\n"
372 -re ".*$true.*$gdb_prompt $" {
373 pass "print value of v_int&&v_unsigned_char"
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" }
380 send_gdb "print v_int && v_signed_short\n"
382 -re ".*$true.*$gdb_prompt $" {
383 pass "print value of v_int&&v_signed_short"
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" }
390 send_gdb "print v_int && v_unsigned_short\n"
392 -re ".*$true.*$gdb_prompt $" {
393 pass "print value of v_int&&v_unsigned_short"
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" }
400 send_gdb "print v_int && v_signed_int\n"
402 -re ".*$true.*$gdb_prompt $" {
403 pass "print value of v_int&&v_signed_int"
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" }
410 send_gdb "print v_int && v_unsigned_int\n"
412 -re ".*$true.*$gdb_prompt $" {
413 pass "print value of v_int&&v_unsigned_int"
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" }
420 send_gdb "print v_int && v_long\n"
422 -re ".*$true.*$gdb_prompt $" {
423 pass "print value of v_int&&v_long"
425 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_long" }
426 timeout { fail "(timeout) print value of v_int&&v_long" }
430 send_gdb "print v_int && v_signed_long\n"
432 -re ".*$true.*$gdb_prompt $" {
433 pass "print value of v_int&&v_signed_long"
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" }
440 send_gdb "print v_int && v_unsigned_long\n"
442 -re ".*$false.*$gdb_prompt $" {
443 pass "print value of v_int&&v_unsigned_long"
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" }
450 send_gdb "print v_int && v_float\n"
452 -re ".*$true.*$gdb_prompt $" {
453 pass "print value of v_int&&v_float"
455 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_float" }
456 timeout { fail "(timeout) print value of v_int&&v_float" }
460 send_gdb "print v_int && v_double\n"
462 -re ".*$false.*$gdb_prompt $" {
463 pass "print value of v_int&&v_double"
465 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_double" }
466 timeout { fail "(timeout) print value of v_int&&v_double" }