1 # Copyright 1998, 1999, 2007, 2008, 2009 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 3 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, see <http://www.gnu.org/licenses/>.
16 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
18 # This file is part of the gdb testsuite
20 # tests for arithmetic, logical and relational operators
31 # test running programs
36 set testfile "all-types"
37 set srcfile ${testfile}.c
38 set binfile ${objdir}/${subdir}/${testfile}
40 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
45 if [get_compiler_info ${binfile}] {
51 gdb_reinitialize_dir $srcdir/$subdir
56 # set it up at a breakpoint so we can play with the variable values
59 if ![runto_main] then {
60 perror "couldn't run to breakpoint"
64 gdb_test "next" "return 0;" "continuing after dummy()"
66 send_gdb "print v_int+v_char\n"
68 -re ".*71.*$gdb_prompt $" {
69 pass "print value of v_int+v_char"
71 -re ".*$gdb_prompt $" { fail "print value of v_int+v_char" }
72 timeout { fail "(timeout) print value of v_int+v_char" }
75 send_gdb "print v_int+v_short\n"
77 -re ".*9.*$gdb_prompt $" {
78 pass "print value of v_int+v_short"
80 -re ".*$gdb_prompt $" { fail "print value of v_int+v_short" }
81 timeout { fail "(timeout) print value of v_int+v_short" }
85 send_gdb "print v_int+v_signed_char\n"
87 -re ".*72.*$gdb_prompt $" {
88 pass "print value of v_int+v_signed_char"
90 -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_char" }
91 timeout { fail "(timeout) print value of v_int+v_signed_char" }
95 send_gdb "print v_int+v_unsigned_char\n"
97 -re ".*73.*$gdb_prompt $" {
98 pass "print value of v_int+v_unsigned_char"
100 -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_char" }
101 timeout { fail "(timeout) print value of v_int+v_unsigned_char" }
105 send_gdb "print v_int+v_signed_short\n"
107 -re ".*10.*$gdb_prompt $" {
108 pass "print value of v_int+v_signed_short"
110 -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_short" }
111 timeout { fail "(timeout) print value of v_int+v_signed_short" }
115 send_gdb "print v_int+v_unsigned_short\n"
117 -re ".*11.*$gdb_prompt $" {
118 pass "print value of v_int+v_unsigned_short"
120 -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_short" }
121 timeout { fail "(timeout) print value of v_int+v_unsigned_short" }
125 send_gdb "print v_int+v_signed_int\n"
127 -re ".*13.*$gdb_prompt $" {
128 pass "print value of v_int+v_signed_int"
130 -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_int" }
131 timeout { fail "(timeout) print value of v_int+v_signed_int" }
135 send_gdb "print v_int+v_unsigned_int\n"
137 -re ".*14.*$gdb_prompt $" {
138 pass "print value of v_int+v_unsigned_int"
140 -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_int" }
141 timeout { fail "(timeout) print value of v_int+v_unsigned_int" }
145 send_gdb "print v_int+v_long\n"
147 -re ".*15.*$gdb_prompt $" {
148 pass "print value of v_int+v_long"
150 -re ".*$gdb_prompt $" { fail "print value of v_int+v_long" }
151 timeout { fail "(timeout) print value of v_int+v_long" }
155 send_gdb "print v_int+v_signed_long\n"
157 -re ".*16.*$gdb_prompt $" {
158 pass "print value of v_int+v_signed_long"
160 -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_long" }
161 timeout { fail "(timeout) print value of v_int+v_signed_long" }
165 send_gdb "print v_int+v_unsigned_long\n"
167 -re ".*17.*$gdb_prompt $" {
168 pass "print value of v_int+v_unsigned_long"
170 -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_long" }
171 timeout { fail "(timeout) print value of v_int+v_unsigned_long" }
175 send_gdb "print v_int+v_float\n"
177 -re ".*106.34343.*$gdb_prompt $" {
178 pass "print value of v_int+v_float"
180 -re ".*$gdb_prompt $" { fail "print value of v_int+v_float" }
181 timeout { fail "(timeout) print value of v_int+v_float" }
185 send_gdb "print v_int+v_double\n"
187 -re ".*206.565.*$gdb_prompt $" {
188 pass "print value of v_int+v_double"
190 -re ".*$gdb_prompt $" { fail "print value of v_int+v_double" }
191 timeout { fail "(timeout) print value of v_int+v_double" }
196 # test the relational operators with mixed types
199 send_gdb "print v_int <= v_char\n"
201 -re ".*1.*$gdb_prompt $" {
202 pass "print value of v_int<=v_char"
204 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_char" }
205 timeout { fail "(timeout) print value of v_int<=v_char" }
208 send_gdb "print v_int <= v_short\n"
210 -re ".*$false.*$gdb_prompt $" {
211 pass "print value of v_int<=v_short"
213 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_short" }
214 timeout { fail "(timeout) print value of v_int<=v_short" }
218 send_gdb "print v_int <= v_signed_char\n"
220 -re ".*1.*$gdb_prompt $" {
221 pass "print value of v_int<=v_signed_char"
223 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_char" }
224 timeout { fail "(timeout) print value of v_int<=v_signed_char" }
228 send_gdb "print v_int <= v_unsigned_char\n"
230 -re ".*1.*$gdb_prompt $" {
231 pass "print value of v_int<=v_unsigned_char"
233 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_char" }
234 timeout { fail "(timeout) print value of v_int<=v_unsigned_char" }
238 send_gdb "print v_int <= v_signed_short\n"
240 -re ".*$false.*$gdb_prompt $" {
241 pass "print value of v_int<=v_signed_short"
243 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_short" }
244 timeout { fail "(timeout) print value of v_int<=v_signed_short" }
248 send_gdb "print v_int <= v_unsigned_short\n"
250 -re ".*$false.*$gdb_prompt $" {
251 pass "print value of v_int<=v_unsigned_short"
253 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_short" }
254 timeout { fail "(timeout) print value of v_int<=v_unsigned_short" }
258 send_gdb "print v_int <= v_signed_int\n"
260 -re ".*$true.*$gdb_prompt $" {
261 pass "print value of v_int<=v_signed_int"
263 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_int" }
264 timeout { fail "(timeout) print value of v_int<=v_signed_int" }
268 send_gdb "print v_int <= v_unsigned_int\n"
270 -re ".*$true.*$gdb_prompt $" {
271 pass "print value of v_int<=v_unsigned_int"
273 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_int" }
274 timeout { fail "(timeout) print value of v_int<=v_unsigned_int" }
278 send_gdb "print v_int <= v_long\n"
280 -re ".*$true.*$gdb_prompt $" {
281 pass "print value of v_int<=v_long"
283 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_long" }
284 timeout { fail "(timeout) print value of v_int<=v_long" }
288 send_gdb "print v_int <= v_signed_long\n"
290 -re ".*$true.*$gdb_prompt $" {
291 pass "print value of v_int<=v_signed_long"
293 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_long" }
294 timeout { fail "(timeout) print value of v_int<=v_signed_long" }
298 send_gdb "print v_int <= v_unsigned_long\n"
300 -re ".*$true.*$gdb_prompt $" {
301 pass "print value of v_int<=v_unsigned_long"
303 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_long" }
304 timeout { fail "(timeout) print value of v_int<=v_unsigned_long" }
308 send_gdb "print v_int <= v_float\n"
310 -re ".*$true.*$gdb_prompt $" {
311 pass "print value of v_int<=v_float"
313 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_float" }
314 timeout { fail "(timeout) print value of v_int<=v_float" }
318 send_gdb "print v_int <= v_double\n"
320 -re ".*$true.*$gdb_prompt $" {
321 pass "print value of v_int<=v_double"
323 -re ".*$gdb_prompt $" { fail "print value of v_int<=v_double" }
324 timeout { fail "(timeout) print value of v_int<=v_double" }
330 # test the logical operators with mixed types
333 gdb_test "set variable v_char=0" "" "set v_char=0"
334 gdb_test "set variable v_double=0.0" "" "set v_double=0"
335 gdb_test "set variable v_unsigned_long=0" "" "set v_unsigned_long=0"
337 send_gdb "print v_int && v_char\n"
339 -re ".*$false.*$gdb_prompt $" {
340 pass "print value of v_int&&v_char"
342 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_char" }
343 timeout { fail "(timeout) print value of v_int&&v_char" }
346 send_gdb "print v_int && v_short\n"
348 -re ".*$true.*$gdb_prompt $" {
349 pass "print value of v_int&&v_short"
351 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_short" }
352 timeout { fail "(timeout) print value of v_int&&v_short" }
356 send_gdb "print v_int && v_signed_char\n"
358 -re ".*$true.*$gdb_prompt $" {
359 pass "print value of v_int&&v_signed_char"
361 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_char" }
362 timeout { fail "(timeout) print value of v_int&&v_signed_char" }
366 send_gdb "print v_int && v_unsigned_char\n"
368 -re ".*$true.*$gdb_prompt $" {
369 pass "print value of v_int&&v_unsigned_char"
371 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_char" }
372 timeout { fail "(timeout) print value of v_int&&v_unsigned_char" }
376 send_gdb "print v_int && v_signed_short\n"
378 -re ".*$true.*$gdb_prompt $" {
379 pass "print value of v_int&&v_signed_short"
381 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_short" }
382 timeout { fail "(timeout) print value of v_int&&v_signed_short" }
386 send_gdb "print v_int && v_unsigned_short\n"
388 -re ".*$true.*$gdb_prompt $" {
389 pass "print value of v_int&&v_unsigned_short"
391 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_short" }
392 timeout { fail "(timeout) print value of v_int&&v_unsigned_short" }
396 send_gdb "print v_int && v_signed_int\n"
398 -re ".*$true.*$gdb_prompt $" {
399 pass "print value of v_int&&v_signed_int"
401 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_int" }
402 timeout { fail "(timeout) print value of v_int&&v_signed_int" }
406 send_gdb "print v_int && v_unsigned_int\n"
408 -re ".*$true.*$gdb_prompt $" {
409 pass "print value of v_int&&v_unsigned_int"
411 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_int" }
412 timeout { fail "(timeout) print value of v_int&&v_unsigned_int" }
416 send_gdb "print v_int && v_long\n"
418 -re ".*$true.*$gdb_prompt $" {
419 pass "print value of v_int&&v_long"
421 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_long" }
422 timeout { fail "(timeout) print value of v_int&&v_long" }
426 send_gdb "print v_int && v_signed_long\n"
428 -re ".*$true.*$gdb_prompt $" {
429 pass "print value of v_int&&v_signed_long"
431 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_long" }
432 timeout { fail "(timeout) print value of v_int&&v_signed_long" }
436 send_gdb "print v_int && v_unsigned_long\n"
438 -re ".*$false.*$gdb_prompt $" {
439 pass "print value of v_int&&v_unsigned_long"
441 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_long" }
442 timeout { fail "(timeout) print value of v_int&&v_unsigned_long" }
446 send_gdb "print v_int && v_float\n"
448 -re ".*$true.*$gdb_prompt $" {
449 pass "print value of v_int&&v_float"
451 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_float" }
452 timeout { fail "(timeout) print value of v_int&&v_float" }
456 send_gdb "print v_int && v_double\n"
458 -re ".*$false.*$gdb_prompt $" {
459 pass "print value of v_int&&v_double"
461 -re ".*$gdb_prompt $" { fail "print value of v_int&&v_double" }
462 timeout { fail "(timeout) print value of v_int&&v_double" }