]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/assign.exp
This commit was manufactured by cvs2svn to create branch
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / assign.exp
CommitLineData
9b254dd1 1# Copyright 1998, 1999, 2007, 2008 Free Software Foundation, Inc.
c906108c
SS
2
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 15
c906108c
SS
16# This file was written by Elena Zannoni (ezannoni@cygnus.com)
17
18# This file is part of the gdb testsuite
19#
20# tests for all the assignemnt operators
21# with mixed types and with int type variables
22#
23
24if $tracelevel then {
25 strace $tracelevel
26 }
27
28#
29# test running programs
30#
31set prms_id 0
32set bug_id 0
33
34set testfile "all-types"
35set srcfile ${testfile}.c
36set binfile ${objdir}/${subdir}/${testfile}
37
fc91c6c2 38if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
b60f0898
JB
39 untested assign.exp
40 return -1
c906108c
SS
41 }
42
43
44
45gdb_exit
46gdb_start
47gdb_reinitialize_dir $srcdir/$subdir
48gdb_load ${binfile}
49
50
51#
52# set it up at a breakpoint so we can play with the variable values
53#
54
55if ![runto_main] then {
56 perror "couldn't run to breakpoint"
57 continue
58}
59
60gdb_test "next" "return 0;" "continuing after dummy()"
61
62send_gdb "print v_int=57\n"
63gdb_expect {
64 -re ".*57.*$gdb_prompt $" {
65 send_gdb "print v_int\n"
66 gdb_expect {
67 -re ".*57.*$gdb_prompt $" {
68 pass "v_int=57"
69 }
70 -re ".*$gdb_prompt $" { fail "v_int=57" }
71 timeout { fail "(timeout) v_int=57" }
72 }
73 }
74 -re ".*$gdb_prompt $" { fail "v_int=57" }
75 timeout { fail "(timeout) v_int=57" }
76 }
77
78
79gdb_test "set variable v_int = 6" "" "set v_int to 6"
80
81
82send_gdb "print v_int+=57\n"
83gdb_expect {
84 -re ".*63.*$gdb_prompt $" {
85 send_gdb "print v_int\n"
86 gdb_expect {
87 -re ".*63.*$gdb_prompt $" {
88 pass "v_int+=57"
89 }
90 -re ".*$gdb_prompt $" { fail "v_int+=57" }
91 timeout { fail "(timeout) v_int+=57" }
92 }
93 }
94 -re ".*$gdb_prompt $" { fail "v_int+=57" }
95 timeout { fail "(timeout) v_int+=57" }
96 }
97
e691325a 98gdb_test "set variable v_int = 6" "" "set v_int to 6 (2)"
c906108c
SS
99
100send_gdb "print v_int-=57\n"
101gdb_expect {
102 -re ".*-51.*$gdb_prompt $" {
103 send_gdb "print v_int\n"
104 gdb_expect {
105 -re ".*-51.*$gdb_prompt $" {
106 pass "v_int-=57"
107 }
108 -re ".*$gdb_prompt $" { fail "v_int-=57" }
109 timeout { fail "(timeout) v_int-=57" }
110 }
111 }
112 -re ".*$gdb_prompt $" { fail "v_int-=57" }
113 timeout { fail "(timeout) v_int-=57" }
114 }
115
e691325a 116gdb_test "set variable v_int = 6" "" "set v_int to 6 (3)"
c906108c
SS
117
118send_gdb "print v_int*=5\n"
119gdb_expect {
120 -re ".*30.*$gdb_prompt $" {
121 send_gdb "print v_int\n"
122 gdb_expect {
123 -re ".*30.*$gdb_prompt $" {
124 pass "v_int*=5"
125 }
126 -re ".*$gdb_prompt $" { fail "v_int*=5" }
127 timeout { fail "(timeout) v_int*=5" }
128 }
129 }
130 -re ".*$gdb_prompt $" { fail "v_int*=5" }
131 timeout { fail "(timeout) v_int*=5" }
132 }
133
e691325a 134gdb_test "set variable v_int = 6" "" "set v_int to 6 (4)"
c906108c
SS
135
136send_gdb "print v_int/=4\n"
137gdb_expect {
138 -re ".*1.*$gdb_prompt $" {
139 send_gdb "print v_int\n"
140 gdb_expect {
141 -re ".*1.*$gdb_prompt $" {
142 pass "v_int/=4"
143 }
144 -re ".*$gdb_prompt $" { fail "v_int/=4" }
145 timeout { fail "(timeout) v_int/=4" }
146 }
147 }
148 -re ".*$gdb_prompt $" { fail "v_int/=4" }
149 timeout { fail "(timeout) v_int/=4" }
150 }
151
152
153
e691325a 154gdb_test "set variable v_int = 6" "" "set v_int to 6 (5)"
c906108c
SS
155
156send_gdb "print v_int%=4\n"
157gdb_expect {
158 -re ".*2.*$gdb_prompt $" {
159 send_gdb "print v_int\n"
160 gdb_expect {
161 -re ".*2.*$gdb_prompt $" {
162 pass "v_int%=4"
163 }
164 -re ".*$gdb_prompt $" { fail "v_int%=4" }
165 timeout { fail "(timeout) v_int%=4" }
166 }
167 }
168 -re ".*$gdb_prompt $" { fail "v_int%=4" }
169 timeout { fail "(timeout) v_int%=4" }
170 }
171
172
173
e691325a 174gdb_test "set variable v_int = 6" "" "set v_int to 6 (6)"
c906108c
SS
175
176
177
178send_gdb "print v_int+=v_char\n"
179gdb_expect {
180 -re ".*71.*$gdb_prompt $" {
181 send_gdb "print v_int\n"
182 gdb_expect {
183 -re ".*71.*$gdb_prompt $" {
184 pass "v_int+=char"
185 }
186 -re ".*$gdb_prompt $" { fail "v_int+=v_char" }
187 timeout { fail "(timeout) v_int+=v_char" }
188 }
189 }
190 -re ".*$gdb_prompt $" { fail "v_int+=v_char" }
191 timeout { fail "(timeout) v_int+=v_char" }
192 }
193
194
e691325a 195gdb_test "set variable v_int = 6" "" "set v_int to 6 (7)"
c906108c
SS
196
197
198
199send_gdb "print v_int+=v_signed_char\n"
200gdb_expect {
201 -re ".*72.*$gdb_prompt $" {
202 send_gdb "print v_int\n"
203 gdb_expect {
204 -re ".*72.*$gdb_prompt $" {
205 pass "v_int+=signed_char"
206 }
207 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_char" }
208 timeout { fail "(timeout) v_int+=v_signed_char" }
209 }
210 }
211 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_char" }
212 timeout { fail "(timeout) v_int+=v_signed_char" }
213 }
214
215
e691325a 216gdb_test "set variable v_int = 6" "" "set v_int to 6 (8)"
c906108c
SS
217
218
219
220send_gdb "print v_int+=v_unsigned_char\n"
221gdb_expect {
222 -re ".*73.*$gdb_prompt $" {
223 send_gdb "print v_int\n"
224 gdb_expect {
225 -re ".*73.*$gdb_prompt $" {
226 pass "v_int+=unsigned_char"
227 }
228 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_char" }
229 timeout { fail "(timeout) v_int+=v_unsigned_char" }
230 }
231 }
232 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_char" }
233 timeout { fail "(timeout) v_int+=v_unsigned_char" }
234 }
235
236
e691325a 237gdb_test "set variable v_int = 6" "" "set v_int to 6 (9)"
c906108c
SS
238
239
240
241send_gdb "print v_int+=v_short\n"
242gdb_expect {
243 -re ".*9.*$gdb_prompt $" {
244 send_gdb "print v_int\n"
245 gdb_expect {
246 -re ".*9.*$gdb_prompt $" {
247 pass "v_int+=short"
248 }
249 -re ".*$gdb_prompt $" { fail "v_int+=v_short" }
250 timeout { fail "(timeout) v_int+=v_short" }
251 }
252 }
253 -re ".*$gdb_prompt $" { fail "v_int+=v_short" }
254 timeout { fail "(timeout) v_int+=v_short" }
255 }
256
257
e691325a 258gdb_test "set variable v_int = 6" "" "set v_int to 6 (10)"
c906108c
SS
259
260
261
262send_gdb "print v_int+=v_signed_short\n"
263gdb_expect {
264 -re ".*10.*$gdb_prompt $" {
265 send_gdb "print v_int\n"
266 gdb_expect {
267 -re ".*10.*$gdb_prompt $" {
268 pass "v_int+=signed_short"
269 }
270 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_short" }
271 timeout { fail "(timeout) v_int+=v_signed_short" }
272 }
273 }
274 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_short" }
275 timeout { fail "(timeout) v_int+=v_signed_short" }
276 }
277
278
e691325a 279gdb_test "set variable v_int = 6" "" "set v_int to 6 (11)"
c906108c
SS
280
281
282
283send_gdb "print v_int+=v_unsigned_short\n"
284gdb_expect {
285 -re ".*11.*$gdb_prompt $" {
286 send_gdb "print v_int\n"
287 gdb_expect {
288 -re ".*11.*$gdb_prompt $" {
289 pass "v_int=+unsigned_short"
290 }
291 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_short" }
292 timeout { fail "(timeout) v_int+=v_unsigned_short" }
293 }
294 }
295 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_short" }
296 timeout { fail "(timeout) v_int+=v_unsigned_short" }
297 }
298
299
e691325a 300gdb_test "set variable v_int = 6" "" "set v_int to 6 (12)"
c906108c
SS
301
302
303
304send_gdb "print v_int+=v_signed_int\n"
305gdb_expect {
306 -re ".*13.*$gdb_prompt $" {
307 send_gdb "print v_int\n"
308 gdb_expect {
309 -re ".*13.*$gdb_prompt $" {
310 pass "v_int+=signed_int"
311 }
312 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_int" }
313 timeout { fail "(timeout) v_int+=v_signed_int" }
314 }
315 }
316 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_int" }
317 timeout { fail "(timeout) v_int+=v_signed_int" }
318 }
319
320
e691325a 321gdb_test "set variable v_int = 6" "" "set v_int to 6 (13)"
c906108c
SS
322
323
324
325send_gdb "print v_int+=v_unsigned_int\n"
326gdb_expect {
327 -re ".*14.*$gdb_prompt $" {
328 send_gdb "print v_int\n"
329 gdb_expect {
330 -re ".*14.*$gdb_prompt $" {
331 pass "v_int+=unsigned_int"
332 }
333 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_int" }
334 timeout { fail "(timeout) v_int+=v_unsigned_int" }
335 }
336 }
337 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_int" }
338 timeout { fail "(timeout) v_int+=v_unsigned_int" }
339 }
340
341
e691325a 342gdb_test "set variable v_int = 6" "" "set v_int to 6 (14)"
c906108c
SS
343
344
345
346send_gdb "print v_int+=v_long\n"
347gdb_expect {
348 -re ".*15.*$gdb_prompt $" {
349 send_gdb "print v_int\n"
350 gdb_expect {
351 -re ".*15.*$gdb_prompt $" {
352 pass "v_int+=long"
353 }
354 -re ".*$gdb_prompt $" { fail "v_int+=v_long" }
355 timeout { fail "(timeout) v_int+=v_long" }
356 }
357 }
358 -re ".*$gdb_prompt $" { fail "v_int+=v_long" }
359 timeout { fail "(timeout) v_int+=v_long" }
360 }
361
362
e691325a 363gdb_test "set variable v_int = 6" "" "set v_int to 6 (15)"
c906108c
SS
364
365
366
367send_gdb "print v_int+=v_signed_long\n"
368gdb_expect {
369 -re ".*16.*$gdb_prompt $" {
370 send_gdb "print v_int\n"
371 gdb_expect {
372 -re ".*16.*$gdb_prompt $" {
373 pass "v_int+=signed_long"
374 }
375 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" }
376 timeout { fail "(timeout) v_int+=v_signed_long" }
377 }
378 }
379 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" }
380 timeout { fail "(timeout) v_int+=v_signed_long" }
381 }
382
383
e691325a 384gdb_test "set variable v_int = 6" "" "set v_int to 6 (16)"
c906108c
SS
385
386
387send_gdb "print v_int+=v_unsigned_long\n"
388gdb_expect {
389 -re ".*17.*$gdb_prompt $" {
390 send_gdb "print v_int\n"
391 gdb_expect {
392 -re ".*17.*$gdb_prompt $" {
393 pass "v_int+=unsigned_long"
394 }
395 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_long" }
396 timeout { fail "(timeout) v_int+=v_unsigned_long" }
397 }
398 }
399 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_long" }
400 timeout { fail "(timeout) v_int+=v_unsigned_long" }
401 }
402
403
e691325a 404gdb_test "set variable v_int = 6" "" "set v_int to 6 (17)"
c906108c
SS
405
406
407send_gdb "print v_int+=v_float\n"
408gdb_expect {
409 -re ".*106\r\n$gdb_prompt $" {
410 send_gdb "print v_int\n"
411 gdb_expect {
412 -re ".*106\r\n$gdb_prompt $" {
413 pass "v_int+=v_float"
414 }
415 -re ".*$gdb_prompt $" { fail "v_int+=v_float" }
416 timeout { fail "(timeout) v_int+=v_float" }
417 }
418 }
419 -re ".*$gdb_prompt $" { fail "v_int+=v_float" }
420 timeout { fail "(timeout) v_int+=v_float" }
421 }
422
423
e691325a 424gdb_test "set variable v_int = 6" "" "set v_int to 6 (18)"
c906108c
SS
425
426
427send_gdb "print v_int+=v_double\n"
428gdb_expect {
429 -re ".*206\r\n$gdb_prompt $" {
430 send_gdb "print v_int\n"
431 gdb_expect {
432 -re ".*206\r\n$gdb_prompt $" {
433 pass "v_int+=double"
434 }
435 -re ".*$gdb_prompt $" { fail "v_int+=v_double" }
436 timeout { fail "(timeout) v_int+=v_double" }
437 }
438 }
effe49a0 439 -re ".*$gdb_prompt $" { fail "v_int+=v_double" }
c906108c
SS
440 timeout { fail "(timeout) v_int+=v_double" }
441 }
442
443