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 all the assignemnt operators
21 # with mixed types and with int type variables
29 # test running programs
34 set testfile "all-types"
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
47 gdb_reinitialize_dir $srcdir/$subdir
52 # set it up at a breakpoint so we can play with the variable values
55 if ![runto_main] then {
56 perror "couldn't run to breakpoint"
60 gdb_test "next" "return 0;" "continuing after dummy()"
62 send_gdb "print v_int=57\n"
64 -re ".*57.*$gdb_prompt $" {
65 send_gdb "print v_int\n"
67 -re ".*57.*$gdb_prompt $" {
70 -re ".*$gdb_prompt $" { fail "v_int=57" }
71 timeout { fail "(timeout) v_int=57" }
74 -re ".*$gdb_prompt $" { fail "v_int=57" }
75 timeout { fail "(timeout) v_int=57" }
79 gdb_test "set variable v_int = 6" "" "set v_int to 6"
82 send_gdb "print v_int+=57\n"
84 -re ".*63.*$gdb_prompt $" {
85 send_gdb "print v_int\n"
87 -re ".*63.*$gdb_prompt $" {
90 -re ".*$gdb_prompt $" { fail "v_int+=57" }
91 timeout { fail "(timeout) v_int+=57" }
94 -re ".*$gdb_prompt $" { fail "v_int+=57" }
95 timeout { fail "(timeout) v_int+=57" }
98 gdb_test "set variable v_int = 6" "" "set v_int to 6 (2)"
100 send_gdb "print v_int-=57\n"
102 -re ".*-51.*$gdb_prompt $" {
103 send_gdb "print v_int\n"
105 -re ".*-51.*$gdb_prompt $" {
108 -re ".*$gdb_prompt $" { fail "v_int-=57" }
109 timeout { fail "(timeout) v_int-=57" }
112 -re ".*$gdb_prompt $" { fail "v_int-=57" }
113 timeout { fail "(timeout) v_int-=57" }
116 gdb_test "set variable v_int = 6" "" "set v_int to 6 (3)"
118 send_gdb "print v_int*=5\n"
120 -re ".*30.*$gdb_prompt $" {
121 send_gdb "print v_int\n"
123 -re ".*30.*$gdb_prompt $" {
126 -re ".*$gdb_prompt $" { fail "v_int*=5" }
127 timeout { fail "(timeout) v_int*=5" }
130 -re ".*$gdb_prompt $" { fail "v_int*=5" }
131 timeout { fail "(timeout) v_int*=5" }
134 gdb_test "set variable v_int = 6" "" "set v_int to 6 (4)"
136 send_gdb "print v_int/=4\n"
138 -re ".*1.*$gdb_prompt $" {
139 send_gdb "print v_int\n"
141 -re ".*1.*$gdb_prompt $" {
144 -re ".*$gdb_prompt $" { fail "v_int/=4" }
145 timeout { fail "(timeout) v_int/=4" }
148 -re ".*$gdb_prompt $" { fail "v_int/=4" }
149 timeout { fail "(timeout) v_int/=4" }
154 gdb_test "set variable v_int = 6" "" "set v_int to 6 (5)"
156 send_gdb "print v_int%=4\n"
158 -re ".*2.*$gdb_prompt $" {
159 send_gdb "print v_int\n"
161 -re ".*2.*$gdb_prompt $" {
164 -re ".*$gdb_prompt $" { fail "v_int%=4" }
165 timeout { fail "(timeout) v_int%=4" }
168 -re ".*$gdb_prompt $" { fail "v_int%=4" }
169 timeout { fail "(timeout) v_int%=4" }
174 gdb_test "set variable v_int = 6" "" "set v_int to 6 (6)"
178 send_gdb "print v_int+=v_char\n"
180 -re ".*71.*$gdb_prompt $" {
181 send_gdb "print v_int\n"
183 -re ".*71.*$gdb_prompt $" {
186 -re ".*$gdb_prompt $" { fail "v_int+=v_char" }
187 timeout { fail "(timeout) v_int+=v_char" }
190 -re ".*$gdb_prompt $" { fail "v_int+=v_char" }
191 timeout { fail "(timeout) v_int+=v_char" }
195 gdb_test "set variable v_int = 6" "" "set v_int to 6 (7)"
199 send_gdb "print v_int+=v_signed_char\n"
201 -re ".*72.*$gdb_prompt $" {
202 send_gdb "print v_int\n"
204 -re ".*72.*$gdb_prompt $" {
205 pass "v_int+=signed_char"
207 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_char" }
208 timeout { fail "(timeout) v_int+=v_signed_char" }
211 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_char" }
212 timeout { fail "(timeout) v_int+=v_signed_char" }
216 gdb_test "set variable v_int = 6" "" "set v_int to 6 (8)"
220 send_gdb "print v_int+=v_unsigned_char\n"
222 -re ".*73.*$gdb_prompt $" {
223 send_gdb "print v_int\n"
225 -re ".*73.*$gdb_prompt $" {
226 pass "v_int+=unsigned_char"
228 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_char" }
229 timeout { fail "(timeout) v_int+=v_unsigned_char" }
232 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_char" }
233 timeout { fail "(timeout) v_int+=v_unsigned_char" }
237 gdb_test "set variable v_int = 6" "" "set v_int to 6 (9)"
241 send_gdb "print v_int+=v_short\n"
243 -re ".*9.*$gdb_prompt $" {
244 send_gdb "print v_int\n"
246 -re ".*9.*$gdb_prompt $" {
249 -re ".*$gdb_prompt $" { fail "v_int+=v_short" }
250 timeout { fail "(timeout) v_int+=v_short" }
253 -re ".*$gdb_prompt $" { fail "v_int+=v_short" }
254 timeout { fail "(timeout) v_int+=v_short" }
258 gdb_test "set variable v_int = 6" "" "set v_int to 6 (10)"
262 send_gdb "print v_int+=v_signed_short\n"
264 -re ".*10.*$gdb_prompt $" {
265 send_gdb "print v_int\n"
267 -re ".*10.*$gdb_prompt $" {
268 pass "v_int+=signed_short"
270 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_short" }
271 timeout { fail "(timeout) v_int+=v_signed_short" }
274 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_short" }
275 timeout { fail "(timeout) v_int+=v_signed_short" }
279 gdb_test "set variable v_int = 6" "" "set v_int to 6 (11)"
283 send_gdb "print v_int+=v_unsigned_short\n"
285 -re ".*11.*$gdb_prompt $" {
286 send_gdb "print v_int\n"
288 -re ".*11.*$gdb_prompt $" {
289 pass "v_int=+unsigned_short"
291 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_short" }
292 timeout { fail "(timeout) v_int+=v_unsigned_short" }
295 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_short" }
296 timeout { fail "(timeout) v_int+=v_unsigned_short" }
300 gdb_test "set variable v_int = 6" "" "set v_int to 6 (12)"
304 send_gdb "print v_int+=v_signed_int\n"
306 -re ".*13.*$gdb_prompt $" {
307 send_gdb "print v_int\n"
309 -re ".*13.*$gdb_prompt $" {
310 pass "v_int+=signed_int"
312 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_int" }
313 timeout { fail "(timeout) v_int+=v_signed_int" }
316 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_int" }
317 timeout { fail "(timeout) v_int+=v_signed_int" }
321 gdb_test "set variable v_int = 6" "" "set v_int to 6 (13)"
325 send_gdb "print v_int+=v_unsigned_int\n"
327 -re ".*14.*$gdb_prompt $" {
328 send_gdb "print v_int\n"
330 -re ".*14.*$gdb_prompt $" {
331 pass "v_int+=unsigned_int"
333 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_int" }
334 timeout { fail "(timeout) v_int+=v_unsigned_int" }
337 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_int" }
338 timeout { fail "(timeout) v_int+=v_unsigned_int" }
342 gdb_test "set variable v_int = 6" "" "set v_int to 6 (14)"
346 send_gdb "print v_int+=v_long\n"
348 -re ".*15.*$gdb_prompt $" {
349 send_gdb "print v_int\n"
351 -re ".*15.*$gdb_prompt $" {
354 -re ".*$gdb_prompt $" { fail "v_int+=v_long" }
355 timeout { fail "(timeout) v_int+=v_long" }
358 -re ".*$gdb_prompt $" { fail "v_int+=v_long" }
359 timeout { fail "(timeout) v_int+=v_long" }
363 gdb_test "set variable v_int = 6" "" "set v_int to 6 (15)"
367 send_gdb "print v_int+=v_signed_long\n"
369 -re ".*16.*$gdb_prompt $" {
370 send_gdb "print v_int\n"
372 -re ".*16.*$gdb_prompt $" {
373 pass "v_int+=signed_long"
375 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" }
376 timeout { fail "(timeout) v_int+=v_signed_long" }
379 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" }
380 timeout { fail "(timeout) v_int+=v_signed_long" }
384 gdb_test "set variable v_int = 6" "" "set v_int to 6 (16)"
387 send_gdb "print v_int+=v_unsigned_long\n"
389 -re ".*17.*$gdb_prompt $" {
390 send_gdb "print v_int\n"
392 -re ".*17.*$gdb_prompt $" {
393 pass "v_int+=unsigned_long"
395 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_long" }
396 timeout { fail "(timeout) v_int+=v_unsigned_long" }
399 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_long" }
400 timeout { fail "(timeout) v_int+=v_unsigned_long" }
404 gdb_test "set variable v_int = 6" "" "set v_int to 6 (17)"
407 send_gdb "print v_int+=v_float\n"
409 -re ".*106\r\n$gdb_prompt $" {
410 send_gdb "print v_int\n"
412 -re ".*106\r\n$gdb_prompt $" {
413 pass "v_int+=v_float"
415 -re ".*$gdb_prompt $" { fail "v_int+=v_float" }
416 timeout { fail "(timeout) v_int+=v_float" }
419 -re ".*$gdb_prompt $" { fail "v_int+=v_float" }
420 timeout { fail "(timeout) v_int+=v_float" }
424 gdb_test "set variable v_int = 6" "" "set v_int to 6 (18)"
427 send_gdb "print v_int+=v_double\n"
429 -re ".*206\r\n$gdb_prompt $" {
430 send_gdb "print v_int\n"
432 -re ".*206\r\n$gdb_prompt $" {
435 -re ".*$gdb_prompt $" { fail "v_int+=v_double" }
436 timeout { fail "(timeout) v_int+=v_double" }
439 -re ".*$gdb_prompt $" { fail "v_int+=v_double" }
440 timeout { fail "(timeout) v_int+=v_double" }