Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.base / assign.exp
blob77f06de4072ed102827316be2f7ee0f9db453b1c
1 # Copyright 1998, 1999 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.
7 #
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
28 if $tracelevel then {
29 strace $tracelevel
33 # test running programs
35 set prms_id 0
36 set bug_id 0
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}] != "" } {
43 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
48 gdb_exit
49 gdb_start
50 gdb_reinitialize_dir $srcdir/$subdir
51 gdb_load ${binfile}
55 # set it up at a breakpoint so we can play with the variable values
58 if ![runto_main] then {
59 perror "couldn't run to breakpoint"
60 continue
63 gdb_test "next" "return 0;" "continuing after dummy()"
65 send_gdb "print v_int=57\n"
66 gdb_expect {
67 -re ".*57.*$gdb_prompt $" {
68 send_gdb "print v_int\n"
69 gdb_expect {
70 -re ".*57.*$gdb_prompt $" {
71 pass "v_int=57"
73 -re ".*$gdb_prompt $" { fail "v_int=57" }
74 timeout { fail "(timeout) v_int=57" }
77 -re ".*$gdb_prompt $" { fail "v_int=57" }
78 timeout { fail "(timeout) v_int=57" }
82 gdb_test "set variable v_int = 6" "" "set v_int to 6"
85 send_gdb "print v_int+=57\n"
86 gdb_expect {
87 -re ".*63.*$gdb_prompt $" {
88 send_gdb "print v_int\n"
89 gdb_expect {
90 -re ".*63.*$gdb_prompt $" {
91 pass "v_int+=57"
93 -re ".*$gdb_prompt $" { fail "v_int+=57" }
94 timeout { fail "(timeout) v_int+=57" }
97 -re ".*$gdb_prompt $" { fail "v_int+=57" }
98 timeout { fail "(timeout) v_int+=57" }
101 gdb_test "set variable v_int = 6" "" "set v_int to 6"
103 send_gdb "print v_int-=57\n"
104 gdb_expect {
105 -re ".*-51.*$gdb_prompt $" {
106 send_gdb "print v_int\n"
107 gdb_expect {
108 -re ".*-51.*$gdb_prompt $" {
109 pass "v_int-=57"
111 -re ".*$gdb_prompt $" { fail "v_int-=57" }
112 timeout { fail "(timeout) v_int-=57" }
115 -re ".*$gdb_prompt $" { fail "v_int-=57" }
116 timeout { fail "(timeout) v_int-=57" }
119 gdb_test "set variable v_int = 6" "" "set v_int to 6"
121 send_gdb "print v_int*=5\n"
122 gdb_expect {
123 -re ".*30.*$gdb_prompt $" {
124 send_gdb "print v_int\n"
125 gdb_expect {
126 -re ".*30.*$gdb_prompt $" {
127 pass "v_int*=5"
129 -re ".*$gdb_prompt $" { fail "v_int*=5" }
130 timeout { fail "(timeout) v_int*=5" }
133 -re ".*$gdb_prompt $" { fail "v_int*=5" }
134 timeout { fail "(timeout) v_int*=5" }
137 gdb_test "set variable v_int = 6" "" "set v_int to 6"
139 send_gdb "print v_int/=4\n"
140 gdb_expect {
141 -re ".*1.*$gdb_prompt $" {
142 send_gdb "print v_int\n"
143 gdb_expect {
144 -re ".*1.*$gdb_prompt $" {
145 pass "v_int/=4"
147 -re ".*$gdb_prompt $" { fail "v_int/=4" }
148 timeout { fail "(timeout) v_int/=4" }
151 -re ".*$gdb_prompt $" { fail "v_int/=4" }
152 timeout { fail "(timeout) v_int/=4" }
157 gdb_test "set variable v_int = 6" "" "set v_int to 6"
159 send_gdb "print v_int%=4\n"
160 gdb_expect {
161 -re ".*2.*$gdb_prompt $" {
162 send_gdb "print v_int\n"
163 gdb_expect {
164 -re ".*2.*$gdb_prompt $" {
165 pass "v_int%=4"
167 -re ".*$gdb_prompt $" { fail "v_int%=4" }
168 timeout { fail "(timeout) v_int%=4" }
171 -re ".*$gdb_prompt $" { fail "v_int%=4" }
172 timeout { fail "(timeout) v_int%=4" }
177 gdb_test "set variable v_int = 6" "" "set v_int to 6"
181 send_gdb "print v_int+=v_char\n"
182 gdb_expect {
183 -re ".*71.*$gdb_prompt $" {
184 send_gdb "print v_int\n"
185 gdb_expect {
186 -re ".*71.*$gdb_prompt $" {
187 pass "v_int+=char"
189 -re ".*$gdb_prompt $" { fail "v_int+=v_char" }
190 timeout { fail "(timeout) v_int+=v_char" }
193 -re ".*$gdb_prompt $" { fail "v_int+=v_char" }
194 timeout { fail "(timeout) v_int+=v_char" }
198 gdb_test "set variable v_int = 6" "" "set v_int to 6"
202 send_gdb "print v_int+=v_signed_char\n"
203 gdb_expect {
204 -re ".*72.*$gdb_prompt $" {
205 send_gdb "print v_int\n"
206 gdb_expect {
207 -re ".*72.*$gdb_prompt $" {
208 pass "v_int+=signed_char"
210 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_char" }
211 timeout { fail "(timeout) v_int+=v_signed_char" }
214 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_char" }
215 timeout { fail "(timeout) v_int+=v_signed_char" }
219 gdb_test "set variable v_int = 6" "" "set v_int to 6"
223 send_gdb "print v_int+=v_unsigned_char\n"
224 gdb_expect {
225 -re ".*73.*$gdb_prompt $" {
226 send_gdb "print v_int\n"
227 gdb_expect {
228 -re ".*73.*$gdb_prompt $" {
229 pass "v_int+=unsigned_char"
231 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_char" }
232 timeout { fail "(timeout) v_int+=v_unsigned_char" }
235 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_char" }
236 timeout { fail "(timeout) v_int+=v_unsigned_char" }
240 gdb_test "set variable v_int = 6" "" "set v_int to 6"
244 send_gdb "print v_int+=v_short\n"
245 gdb_expect {
246 -re ".*9.*$gdb_prompt $" {
247 send_gdb "print v_int\n"
248 gdb_expect {
249 -re ".*9.*$gdb_prompt $" {
250 pass "v_int+=short"
252 -re ".*$gdb_prompt $" { fail "v_int+=v_short" }
253 timeout { fail "(timeout) v_int+=v_short" }
256 -re ".*$gdb_prompt $" { fail "v_int+=v_short" }
257 timeout { fail "(timeout) v_int+=v_short" }
261 gdb_test "set variable v_int = 6" "" "set v_int to 6"
265 send_gdb "print v_int+=v_signed_short\n"
266 gdb_expect {
267 -re ".*10.*$gdb_prompt $" {
268 send_gdb "print v_int\n"
269 gdb_expect {
270 -re ".*10.*$gdb_prompt $" {
271 pass "v_int+=signed_short"
273 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_short" }
274 timeout { fail "(timeout) v_int+=v_signed_short" }
277 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_short" }
278 timeout { fail "(timeout) v_int+=v_signed_short" }
282 gdb_test "set variable v_int = 6" "" "set v_int to 6"
286 send_gdb "print v_int+=v_unsigned_short\n"
287 gdb_expect {
288 -re ".*11.*$gdb_prompt $" {
289 send_gdb "print v_int\n"
290 gdb_expect {
291 -re ".*11.*$gdb_prompt $" {
292 pass "v_int=+unsigned_short"
294 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_short" }
295 timeout { fail "(timeout) v_int+=v_unsigned_short" }
298 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_short" }
299 timeout { fail "(timeout) v_int+=v_unsigned_short" }
303 gdb_test "set variable v_int = 6" "" "set v_int to 6"
307 send_gdb "print v_int+=v_signed_int\n"
308 gdb_expect {
309 -re ".*13.*$gdb_prompt $" {
310 send_gdb "print v_int\n"
311 gdb_expect {
312 -re ".*13.*$gdb_prompt $" {
313 pass "v_int+=signed_int"
315 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_int" }
316 timeout { fail "(timeout) v_int+=v_signed_int" }
319 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_int" }
320 timeout { fail "(timeout) v_int+=v_signed_int" }
324 gdb_test "set variable v_int = 6" "" "set v_int to 6"
328 send_gdb "print v_int+=v_unsigned_int\n"
329 gdb_expect {
330 -re ".*14.*$gdb_prompt $" {
331 send_gdb "print v_int\n"
332 gdb_expect {
333 -re ".*14.*$gdb_prompt $" {
334 pass "v_int+=unsigned_int"
336 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_int" }
337 timeout { fail "(timeout) v_int+=v_unsigned_int" }
340 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_int" }
341 timeout { fail "(timeout) v_int+=v_unsigned_int" }
345 gdb_test "set variable v_int = 6" "" "set v_int to 6"
349 send_gdb "print v_int+=v_long\n"
350 gdb_expect {
351 -re ".*15.*$gdb_prompt $" {
352 send_gdb "print v_int\n"
353 gdb_expect {
354 -re ".*15.*$gdb_prompt $" {
355 pass "v_int+=long"
357 -re ".*$gdb_prompt $" { fail "v_int+=v_long" }
358 timeout { fail "(timeout) v_int+=v_long" }
361 -re ".*$gdb_prompt $" { fail "v_int+=v_long" }
362 timeout { fail "(timeout) v_int+=v_long" }
366 gdb_test "set variable v_int = 6" "" "set v_int to 6"
370 send_gdb "print v_int+=v_signed_long\n"
371 gdb_expect {
372 -re ".*16.*$gdb_prompt $" {
373 send_gdb "print v_int\n"
374 gdb_expect {
375 -re ".*16.*$gdb_prompt $" {
376 pass "v_int+=signed_long"
378 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" }
379 timeout { fail "(timeout) v_int+=v_signed_long" }
382 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" }
383 timeout { fail "(timeout) v_int+=v_signed_long" }
387 gdb_test "set variable v_int = 6" "" "set v_int to 6"
390 send_gdb "print v_int+=v_unsigned_long\n"
391 gdb_expect {
392 -re ".*17.*$gdb_prompt $" {
393 send_gdb "print v_int\n"
394 gdb_expect {
395 -re ".*17.*$gdb_prompt $" {
396 pass "v_int+=unsigned_long"
398 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_long" }
399 timeout { fail "(timeout) v_int+=v_unsigned_long" }
402 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_long" }
403 timeout { fail "(timeout) v_int+=v_unsigned_long" }
407 gdb_test "set variable v_int = 6" "" "set v_int to 6"
410 send_gdb "print v_int+=v_float\n"
411 gdb_expect {
412 -re ".*106\r\n$gdb_prompt $" {
413 send_gdb "print v_int\n"
414 gdb_expect {
415 -re ".*106\r\n$gdb_prompt $" {
416 pass "v_int+=v_float"
418 -re ".*$gdb_prompt $" { fail "v_int+=v_float" }
419 timeout { fail "(timeout) v_int+=v_float" }
422 -re ".*$gdb_prompt $" { fail "v_int+=v_float" }
423 timeout { fail "(timeout) v_int+=v_float" }
427 gdb_test "set variable v_int = 6" "" "set v_int to 6"
430 send_gdb "print v_int+=v_double\n"
431 gdb_expect {
432 -re ".*206\r\n$gdb_prompt $" {
433 send_gdb "print v_int\n"
434 gdb_expect {
435 -re ".*206\r\n$gdb_prompt $" {
436 pass "v_int+=double"
438 -re ".*$gdb_prompt $" { fail "v_int+=v_double" }
439 timeout { fail "(timeout) v_int+=v_double" }
442 -re ".*$gdb_prompt $" { fail "v_int+=v_double" }
443 timeout { fail "(timeout) v_int+=v_double" }