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 all the assignemnt operators
25 # with mixed types and with int type variables
33 # test running programs
38 set testfile "all-types"
39 set srcfile ${testfile}.c
40 set binfile ${objdir}/${subdir}/${testfile}
42 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
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=57\n"
68 -re ".*57.*$gdb_prompt $" {
69 send_gdb "print v_int\n"
71 -re ".*57.*$gdb_prompt $" {
74 -re ".*$gdb_prompt $" { fail "v_int=57" }
75 timeout { fail "(timeout) v_int=57" }
78 -re ".*$gdb_prompt $" { fail "v_int=57" }
79 timeout { fail "(timeout) v_int=57" }
83 gdb_test "set variable v_int = 6" "" "set v_int to 6"
86 send_gdb "print v_int+=57\n"
88 -re ".*63.*$gdb_prompt $" {
89 send_gdb "print v_int\n"
91 -re ".*63.*$gdb_prompt $" {
94 -re ".*$gdb_prompt $" { fail "v_int+=57" }
95 timeout { fail "(timeout) v_int+=57" }
98 -re ".*$gdb_prompt $" { fail "v_int+=57" }
99 timeout { fail "(timeout) v_int+=57" }
102 gdb_test "set variable v_int = 6" "" "set v_int to 6"
104 send_gdb "print v_int-=57\n"
106 -re ".*-51.*$gdb_prompt $" {
107 send_gdb "print v_int\n"
109 -re ".*-51.*$gdb_prompt $" {
112 -re ".*$gdb_prompt $" { fail "v_int-=57" }
113 timeout { fail "(timeout) v_int-=57" }
116 -re ".*$gdb_prompt $" { fail "v_int-=57" }
117 timeout { fail "(timeout) v_int-=57" }
120 gdb_test "set variable v_int = 6" "" "set v_int to 6"
122 send_gdb "print v_int*=5\n"
124 -re ".*30.*$gdb_prompt $" {
125 send_gdb "print v_int\n"
127 -re ".*30.*$gdb_prompt $" {
130 -re ".*$gdb_prompt $" { fail "v_int*=5" }
131 timeout { fail "(timeout) v_int*=5" }
134 -re ".*$gdb_prompt $" { fail "v_int*=5" }
135 timeout { fail "(timeout) v_int*=5" }
138 gdb_test "set variable v_int = 6" "" "set v_int to 6"
140 send_gdb "print v_int/=4\n"
142 -re ".*1.*$gdb_prompt $" {
143 send_gdb "print v_int\n"
145 -re ".*1.*$gdb_prompt $" {
148 -re ".*$gdb_prompt $" { fail "v_int/=4" }
149 timeout { fail "(timeout) v_int/=4" }
152 -re ".*$gdb_prompt $" { fail "v_int/=4" }
153 timeout { fail "(timeout) v_int/=4" }
158 gdb_test "set variable v_int = 6" "" "set v_int to 6"
160 send_gdb "print v_int%=4\n"
162 -re ".*2.*$gdb_prompt $" {
163 send_gdb "print v_int\n"
165 -re ".*2.*$gdb_prompt $" {
168 -re ".*$gdb_prompt $" { fail "v_int%=4" }
169 timeout { fail "(timeout) v_int%=4" }
172 -re ".*$gdb_prompt $" { fail "v_int%=4" }
173 timeout { fail "(timeout) v_int%=4" }
178 gdb_test "set variable v_int = 6" "" "set v_int to 6"
182 send_gdb "print v_int+=v_char\n"
184 -re ".*71.*$gdb_prompt $" {
185 send_gdb "print v_int\n"
187 -re ".*71.*$gdb_prompt $" {
190 -re ".*$gdb_prompt $" { fail "v_int+=v_char" }
191 timeout { fail "(timeout) v_int+=v_char" }
194 -re ".*$gdb_prompt $" { fail "v_int+=v_char" }
195 timeout { fail "(timeout) v_int+=v_char" }
199 gdb_test "set variable v_int = 6" "" "set v_int to 6"
203 send_gdb "print v_int+=v_signed_char\n"
205 -re ".*72.*$gdb_prompt $" {
206 send_gdb "print v_int\n"
208 -re ".*72.*$gdb_prompt $" {
209 pass "v_int+=signed_char"
211 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_char" }
212 timeout { fail "(timeout) v_int+=v_signed_char" }
215 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_char" }
216 timeout { fail "(timeout) v_int+=v_signed_char" }
220 gdb_test "set variable v_int = 6" "" "set v_int to 6"
224 send_gdb "print v_int+=v_unsigned_char\n"
226 -re ".*73.*$gdb_prompt $" {
227 send_gdb "print v_int\n"
229 -re ".*73.*$gdb_prompt $" {
230 pass "v_int+=unsigned_char"
232 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_char" }
233 timeout { fail "(timeout) v_int+=v_unsigned_char" }
236 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_char" }
237 timeout { fail "(timeout) v_int+=v_unsigned_char" }
241 gdb_test "set variable v_int = 6" "" "set v_int to 6"
245 send_gdb "print v_int+=v_short\n"
247 -re ".*9.*$gdb_prompt $" {
248 send_gdb "print v_int\n"
250 -re ".*9.*$gdb_prompt $" {
253 -re ".*$gdb_prompt $" { fail "v_int+=v_short" }
254 timeout { fail "(timeout) v_int+=v_short" }
257 -re ".*$gdb_prompt $" { fail "v_int+=v_short" }
258 timeout { fail "(timeout) v_int+=v_short" }
262 gdb_test "set variable v_int = 6" "" "set v_int to 6"
266 send_gdb "print v_int+=v_signed_short\n"
268 -re ".*10.*$gdb_prompt $" {
269 send_gdb "print v_int\n"
271 -re ".*10.*$gdb_prompt $" {
272 pass "v_int+=signed_short"
274 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_short" }
275 timeout { fail "(timeout) v_int+=v_signed_short" }
278 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_short" }
279 timeout { fail "(timeout) v_int+=v_signed_short" }
283 gdb_test "set variable v_int = 6" "" "set v_int to 6"
287 send_gdb "print v_int+=v_unsigned_short\n"
289 -re ".*11.*$gdb_prompt $" {
290 send_gdb "print v_int\n"
292 -re ".*11.*$gdb_prompt $" {
293 pass "v_int=+unsigned_short"
295 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_short" }
296 timeout { fail "(timeout) v_int+=v_unsigned_short" }
299 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_short" }
300 timeout { fail "(timeout) v_int+=v_unsigned_short" }
304 gdb_test "set variable v_int = 6" "" "set v_int to 6"
308 send_gdb "print v_int+=v_signed_int\n"
310 -re ".*13.*$gdb_prompt $" {
311 send_gdb "print v_int\n"
313 -re ".*13.*$gdb_prompt $" {
314 pass "v_int+=signed_int"
316 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_int" }
317 timeout { fail "(timeout) v_int+=v_signed_int" }
320 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_int" }
321 timeout { fail "(timeout) v_int+=v_signed_int" }
325 gdb_test "set variable v_int = 6" "" "set v_int to 6"
329 send_gdb "print v_int+=v_unsigned_int\n"
331 -re ".*14.*$gdb_prompt $" {
332 send_gdb "print v_int\n"
334 -re ".*14.*$gdb_prompt $" {
335 pass "v_int+=unsigned_int"
337 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_int" }
338 timeout { fail "(timeout) v_int+=v_unsigned_int" }
341 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_int" }
342 timeout { fail "(timeout) v_int+=v_unsigned_int" }
346 gdb_test "set variable v_int = 6" "" "set v_int to 6"
350 send_gdb "print v_int+=v_long\n"
352 -re ".*15.*$gdb_prompt $" {
353 send_gdb "print v_int\n"
355 -re ".*15.*$gdb_prompt $" {
358 -re ".*$gdb_prompt $" { fail "v_int+=v_long" }
359 timeout { fail "(timeout) v_int+=v_long" }
362 -re ".*$gdb_prompt $" { fail "v_int+=v_long" }
363 timeout { fail "(timeout) v_int+=v_long" }
367 gdb_test "set variable v_int = 6" "" "set v_int to 6"
371 send_gdb "print v_int+=v_signed_long\n"
373 -re ".*16.*$gdb_prompt $" {
374 send_gdb "print v_int\n"
376 -re ".*16.*$gdb_prompt $" {
377 pass "v_int+=signed_long"
379 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" }
380 timeout { fail "(timeout) v_int+=v_signed_long" }
383 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" }
384 timeout { fail "(timeout) v_int+=v_signed_long" }
388 gdb_test "set variable v_int = 6" "" "set v_int to 6"
391 send_gdb "print v_int+=v_unsigned_long\n"
393 -re ".*17.*$gdb_prompt $" {
394 send_gdb "print v_int\n"
396 -re ".*17.*$gdb_prompt $" {
397 pass "v_int+=unsigned_long"
399 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_long" }
400 timeout { fail "(timeout) v_int+=v_unsigned_long" }
403 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_long" }
404 timeout { fail "(timeout) v_int+=v_unsigned_long" }
408 gdb_test "set variable v_int = 6" "" "set v_int to 6"
411 send_gdb "print v_int+=v_float\n"
413 -re ".*106\r\n$gdb_prompt $" {
414 send_gdb "print v_int\n"
416 -re ".*106\r\n$gdb_prompt $" {
417 pass "v_int+=v_float"
419 -re ".*$gdb_prompt $" { fail "v_int+=v_float" }
420 timeout { fail "(timeout) v_int+=v_float" }
423 -re ".*$gdb_prompt $" { fail "v_int+=v_float" }
424 timeout { fail "(timeout) v_int+=v_float" }
428 gdb_test "set variable v_int = 6" "" "set v_int to 6"
431 send_gdb "print v_int+=v_double\n"
433 -re ".*206\r\n$gdb_prompt $" {
434 send_gdb "print v_int\n"
436 -re ".*206\r\n$gdb_prompt $" {
439 -re ".*$gdb_prompt $" { fail "v_int+=v_double" }
440 timeout { fail "(timeout) v_int+=v_double" }
443 -re ".*$gdb_prompt $" { fail "v_int+=v_double" }
444 timeout { fail "(timeout) v_int+=v_double" }