1 # Copyright 1998, 1999, 2007, 2008, 2009, 2010 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 all the assignemnt operators
21 # with mixed types and with int type variables
29 # test running programs
32 set testfile "all-types"
33 set srcfile ${testfile}.c
34 set binfile ${objdir}/${subdir}/${testfile}
36 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
45 gdb_reinitialize_dir $srcdir/$subdir
50 # set it up at a breakpoint so we can play with the variable values
53 if ![runto_main] then {
54 perror "couldn't run to breakpoint"
58 gdb_test "next" "return 0;" "continuing after dummy()"
60 send_gdb "print v_int=57\n"
62 -re ".*57.*$gdb_prompt $" {
63 send_gdb "print v_int\n"
65 -re ".*57.*$gdb_prompt $" {
68 -re ".*$gdb_prompt $" { fail "v_int=57" }
69 timeout { fail "(timeout) v_int=57" }
72 -re ".*$gdb_prompt $" { fail "v_int=57" }
73 timeout { fail "(timeout) v_int=57" }
77 gdb_test "set variable v_int = 6" "" "set v_int to 6"
80 send_gdb "print v_int+=57\n"
82 -re ".*63.*$gdb_prompt $" {
83 send_gdb "print v_int\n"
85 -re ".*63.*$gdb_prompt $" {
88 -re ".*$gdb_prompt $" { fail "v_int+=57" }
89 timeout { fail "(timeout) v_int+=57" }
92 -re ".*$gdb_prompt $" { fail "v_int+=57" }
93 timeout { fail "(timeout) v_int+=57" }
96 gdb_test "set variable v_int = 6" "" "set v_int to 6 (2)"
98 send_gdb "print v_int-=57\n"
100 -re ".*-51.*$gdb_prompt $" {
101 send_gdb "print v_int\n"
103 -re ".*-51.*$gdb_prompt $" {
106 -re ".*$gdb_prompt $" { fail "v_int-=57" }
107 timeout { fail "(timeout) v_int-=57" }
110 -re ".*$gdb_prompt $" { fail "v_int-=57" }
111 timeout { fail "(timeout) v_int-=57" }
114 gdb_test "set variable v_int = 6" "" "set v_int to 6 (3)"
116 send_gdb "print v_int*=5\n"
118 -re ".*30.*$gdb_prompt $" {
119 send_gdb "print v_int\n"
121 -re ".*30.*$gdb_prompt $" {
124 -re ".*$gdb_prompt $" { fail "v_int*=5" }
125 timeout { fail "(timeout) v_int*=5" }
128 -re ".*$gdb_prompt $" { fail "v_int*=5" }
129 timeout { fail "(timeout) v_int*=5" }
132 gdb_test "set variable v_int = 6" "" "set v_int to 6 (4)"
134 send_gdb "print v_int/=4\n"
136 -re ".*1.*$gdb_prompt $" {
137 send_gdb "print v_int\n"
139 -re ".*1.*$gdb_prompt $" {
142 -re ".*$gdb_prompt $" { fail "v_int/=4" }
143 timeout { fail "(timeout) v_int/=4" }
146 -re ".*$gdb_prompt $" { fail "v_int/=4" }
147 timeout { fail "(timeout) v_int/=4" }
152 gdb_test "set variable v_int = 6" "" "set v_int to 6 (5)"
154 send_gdb "print v_int%=4\n"
156 -re ".*2.*$gdb_prompt $" {
157 send_gdb "print v_int\n"
159 -re ".*2.*$gdb_prompt $" {
162 -re ".*$gdb_prompt $" { fail "v_int%=4" }
163 timeout { fail "(timeout) v_int%=4" }
166 -re ".*$gdb_prompt $" { fail "v_int%=4" }
167 timeout { fail "(timeout) v_int%=4" }
172 gdb_test "set variable v_int = 6" "" "set v_int to 6 (6)"
176 send_gdb "print v_int+=v_char\n"
178 -re ".*71.*$gdb_prompt $" {
179 send_gdb "print v_int\n"
181 -re ".*71.*$gdb_prompt $" {
184 -re ".*$gdb_prompt $" { fail "v_int+=v_char" }
185 timeout { fail "(timeout) v_int+=v_char" }
188 -re ".*$gdb_prompt $" { fail "v_int+=v_char" }
189 timeout { fail "(timeout) v_int+=v_char" }
193 gdb_test "set variable v_int = 6" "" "set v_int to 6 (7)"
197 send_gdb "print v_int+=v_signed_char\n"
199 -re ".*72.*$gdb_prompt $" {
200 send_gdb "print v_int\n"
202 -re ".*72.*$gdb_prompt $" {
203 pass "v_int+=signed_char"
205 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_char" }
206 timeout { fail "(timeout) v_int+=v_signed_char" }
209 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_char" }
210 timeout { fail "(timeout) v_int+=v_signed_char" }
214 gdb_test "set variable v_int = 6" "" "set v_int to 6 (8)"
218 send_gdb "print v_int+=v_unsigned_char\n"
220 -re ".*73.*$gdb_prompt $" {
221 send_gdb "print v_int\n"
223 -re ".*73.*$gdb_prompt $" {
224 pass "v_int+=unsigned_char"
226 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_char" }
227 timeout { fail "(timeout) v_int+=v_unsigned_char" }
230 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_char" }
231 timeout { fail "(timeout) v_int+=v_unsigned_char" }
235 gdb_test "set variable v_int = 6" "" "set v_int to 6 (9)"
239 send_gdb "print v_int+=v_short\n"
241 -re ".*9.*$gdb_prompt $" {
242 send_gdb "print v_int\n"
244 -re ".*9.*$gdb_prompt $" {
247 -re ".*$gdb_prompt $" { fail "v_int+=v_short" }
248 timeout { fail "(timeout) v_int+=v_short" }
251 -re ".*$gdb_prompt $" { fail "v_int+=v_short" }
252 timeout { fail "(timeout) v_int+=v_short" }
256 gdb_test "set variable v_int = 6" "" "set v_int to 6 (10)"
260 send_gdb "print v_int+=v_signed_short\n"
262 -re ".*10.*$gdb_prompt $" {
263 send_gdb "print v_int\n"
265 -re ".*10.*$gdb_prompt $" {
266 pass "v_int+=signed_short"
268 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_short" }
269 timeout { fail "(timeout) v_int+=v_signed_short" }
272 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_short" }
273 timeout { fail "(timeout) v_int+=v_signed_short" }
277 gdb_test "set variable v_int = 6" "" "set v_int to 6 (11)"
281 send_gdb "print v_int+=v_unsigned_short\n"
283 -re ".*11.*$gdb_prompt $" {
284 send_gdb "print v_int\n"
286 -re ".*11.*$gdb_prompt $" {
287 pass "v_int=+unsigned_short"
289 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_short" }
290 timeout { fail "(timeout) v_int+=v_unsigned_short" }
293 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_short" }
294 timeout { fail "(timeout) v_int+=v_unsigned_short" }
298 gdb_test "set variable v_int = 6" "" "set v_int to 6 (12)"
302 send_gdb "print v_int+=v_signed_int\n"
304 -re ".*13.*$gdb_prompt $" {
305 send_gdb "print v_int\n"
307 -re ".*13.*$gdb_prompt $" {
308 pass "v_int+=signed_int"
310 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_int" }
311 timeout { fail "(timeout) v_int+=v_signed_int" }
314 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_int" }
315 timeout { fail "(timeout) v_int+=v_signed_int" }
319 gdb_test "set variable v_int = 6" "" "set v_int to 6 (13)"
323 send_gdb "print v_int+=v_unsigned_int\n"
325 -re ".*14.*$gdb_prompt $" {
326 send_gdb "print v_int\n"
328 -re ".*14.*$gdb_prompt $" {
329 pass "v_int+=unsigned_int"
331 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_int" }
332 timeout { fail "(timeout) v_int+=v_unsigned_int" }
335 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_int" }
336 timeout { fail "(timeout) v_int+=v_unsigned_int" }
340 gdb_test "set variable v_int = 6" "" "set v_int to 6 (14)"
344 send_gdb "print v_int+=v_long\n"
346 -re ".*15.*$gdb_prompt $" {
347 send_gdb "print v_int\n"
349 -re ".*15.*$gdb_prompt $" {
352 -re ".*$gdb_prompt $" { fail "v_int+=v_long" }
353 timeout { fail "(timeout) v_int+=v_long" }
356 -re ".*$gdb_prompt $" { fail "v_int+=v_long" }
357 timeout { fail "(timeout) v_int+=v_long" }
361 gdb_test "set variable v_int = 6" "" "set v_int to 6 (15)"
365 send_gdb "print v_int+=v_signed_long\n"
367 -re ".*16.*$gdb_prompt $" {
368 send_gdb "print v_int\n"
370 -re ".*16.*$gdb_prompt $" {
371 pass "v_int+=signed_long"
373 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" }
374 timeout { fail "(timeout) v_int+=v_signed_long" }
377 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" }
378 timeout { fail "(timeout) v_int+=v_signed_long" }
382 gdb_test "set variable v_int = 6" "" "set v_int to 6 (16)"
385 send_gdb "print v_int+=v_unsigned_long\n"
387 -re ".*17.*$gdb_prompt $" {
388 send_gdb "print v_int\n"
390 -re ".*17.*$gdb_prompt $" {
391 pass "v_int+=unsigned_long"
393 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_long" }
394 timeout { fail "(timeout) v_int+=v_unsigned_long" }
397 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_long" }
398 timeout { fail "(timeout) v_int+=v_unsigned_long" }
402 gdb_test "set variable v_int = 6" "" "set v_int to 6 (17)"
405 send_gdb "print v_int+=v_float\n"
407 -re ".*106\r\n$gdb_prompt $" {
408 send_gdb "print v_int\n"
410 -re ".*106\r\n$gdb_prompt $" {
411 pass "v_int+=v_float"
413 -re ".*$gdb_prompt $" { fail "v_int+=v_float" }
414 timeout { fail "(timeout) v_int+=v_float" }
417 -re ".*$gdb_prompt $" { fail "v_int+=v_float" }
418 timeout { fail "(timeout) v_int+=v_float" }
422 gdb_test "set variable v_int = 6" "" "set v_int to 6 (18)"
425 send_gdb "print v_int+=v_double\n"
427 -re ".*206\r\n$gdb_prompt $" {
428 send_gdb "print v_int\n"
430 -re ".*206\r\n$gdb_prompt $" {
433 -re ".*$gdb_prompt $" { fail "v_int+=v_double" }
434 timeout { fail "(timeout) v_int+=v_double" }
437 -re ".*$gdb_prompt $" { fail "v_int+=v_double" }
438 timeout { fail "(timeout) v_int+=v_double" }