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