* gdb.base/setvar.c, gdb.base/setvar.exp: Add new tests for
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / setvar.exp
1 # Copyright (C) 1988, 1990, 1991, 1992, 1994, 1995
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
20
21 # This file was written by Rob Savoye. (rob@cygnus.com)
22
23 if $tracelevel then {
24 strace $tracelevel
25 }
26
27 #
28 # test running programs
29 #
30 set prms_id 0
31 set bug_id 0
32
33 set binfile "setvar"
34
35 if ![file exists $objdir/$subdir/$binfile] then {
36 perror "$objdir/$subdir/$binfile does not exist."
37 return 0
38 }
39
40 gdb_exit
41 gdb_start
42 gdb_reinitialize_dir $srcdir/$subdir
43 gdb_load $objdir/$subdir/$binfile
44
45 source gdb.base/setvar.ci
46
47 #
48 # set it up at a breakpoint so we canplay with the variable values
49 #
50 send "set print sevenbit-strings\n" ; expect -re "$prompt $"
51
52 if ![runto_main] then {
53 perror "couldn't run to breakpoint"
54 continue
55 }
56
57 # Determine expected output for unsigned long variables,
58 # the output varies with sizeof (unsigned long).
59
60 set ulong_minus_1 4294967295
61 set ulong_minus_456 4294966840
62 send "print sizeof (unsigned long)\n"
63 expect {
64 -re ".\[0-9\]* = 4.*$prompt $" {}
65 -re ".\[0-9\]* = 8.*$prompt $" {
66 set ulong_minus_1 18446744073709551615
67 set ulong_minus_456 18446744073709551160
68 }
69 -re ".*$prompt $" {
70 fail "getting sizeof unsigned long"
71 }
72 default { fail "(timeout) getting sizeof unsigned long" }
73 }
74
75 #
76 # test "set variable" for type "char"
77 #
78 # Because bare char types can be either signed or unsigned, we just test the
79 # range of values that are common to both (0-127).
80 #
81 send "set variable v_char=0\n"
82 expect {
83 -re "$prompt $"\
84 {
85 send "print v_char\n"
86 expect {
87 -re ".\[0-9\]* = 0 \'.000\'.*$prompt $" { pass "set variable char=0" }
88 -re "$prompt $" { fail "set variable char=0" }
89 timeout { fail "(timeout) set variable char=0" }
90 }
91 }
92 -re "$prompt $" { fail "set variable char=0" }
93 timeout { fail "(timeout) set variable char=0" }
94 }
95
96
97 send "set variable v_char=1\n"
98 expect {
99 -re "$prompt $"\
100 {
101 send "print v_char\n"
102 expect {
103 -re ".\[0-9\]* = 1 \'.001\'.*$prompt $" { pass "set variable char=1" }
104 -re "$prompt $" { fail "set variable char=1" }
105 timeout { fail "(timeout) set variable char=1" }
106 }
107 }
108 -re "$prompt $" { fail "set variable char=1" }
109 timeout { fail "(timeout) set variable char=1" }
110 }
111
112
113 send "set variable v_char=27\n"
114 expect {
115 -re "$prompt $"\
116 {
117 send "print v_char\n"
118 expect {
119 -re ".\[0-9\]* = 27 \'.e\'.*$prompt $" { pass "set variable char=27 (Esc)" }
120 -re "$prompt $" { fail "set variable char=27 (Esc)" }
121 timeout { fail "(timeout) set variable char=27 (Esc)" }
122 }
123 }
124 -re "$prompt $" { fail "set variable char=27 (Esc)" }
125 timeout { fail "(timeout) set variable char=27 (Esc)" }
126 }
127
128
129 send "set variable v_char=32\n"
130 expect {
131 -re "$prompt $"\
132 {
133 send "print v_char\n"
134 expect {
135 -re ".\[0-9\]* = 32 \' \'.*$prompt $" { pass "set variable char=32 (SPC)" }
136 -re "$prompt $" { fail "set variable char=32 (SPC)" }
137 timeout { fail "(timeout) set variable char=32 (SPC)" }
138 }
139 }
140 -re "$prompt $" { fail "set variable char=32 (SPC)" }
141 timeout { fail "(timeout) set variable char=32 (SPC)" }
142 }
143
144
145 send "set variable v_char=65\n"
146 expect {
147 -re "$prompt $"\
148 {
149 send "print v_char\n"
150 expect {
151 -re ".\[0-9\]* = 65 \'A\'.*$prompt $" { pass "set variable char=65 ('A')" }
152 -re "$prompt $" { fail "set variable char=65 ('A')" }
153 timeout { fail "(timeout) set variable char=65 ('A')" }
154 }
155 }
156 -re "$prompt $" { fail "set variable char=65 ('A')" }
157 timeout { fail "(timeout) set variable char=65 ('A')" }
158 }
159
160
161 send "set variable v_char=97\n"
162 expect {
163 -re "$prompt $"\
164 {
165 send "print v_char\n"
166 expect {
167 -re ".\[0-9\]* = 97 \'a\'.*$prompt $" { pass "set variable char=97 ('a')" }
168 -re "$prompt $" { fail "set variable char=97 ('a')" }
169 timeout { fail "(timeout) set variable char=97 ('a')" }
170 }
171 }
172 -re "$prompt $" { fail "set variable char=97 ('a')" }
173 timeout { fail "(timeout) set variable char=97 ('a')" }
174 }
175
176
177 send "set variable v_char=126\n"
178 expect {
179 -re "$prompt $"\
180 {
181 send "print v_char\n"
182 expect {
183 -re ".\[0-9\]* = 126 \'~\'.*$prompt $" { pass "set variable char=126 ('~')" }
184 -re "$prompt $" { fail "set variable char=126 ('~')" }
185 timeout { fail "(timeout) set variable char=126 ('~')" }
186 }
187 }
188 -re "$prompt $" { fail "set variable char=126 ('~')" }
189 timeout { fail "(timeout) set variable char=126 ('~')" }
190 }
191
192
193 send "set variable v_char=127\n"
194 expect {
195 -re "$prompt $"\
196 {
197 send "print v_char\n"
198 expect {
199 -re ".\[0-9\]* = 127 \'.177\'.*$prompt $" { pass "set variable char=127 (8-bit)" }
200 -re "$prompt $" { fail "set variable char=127 (8-bit)" }
201 timeout { fail "(timeout) set variable char=127 (8-bit)" }
202 }
203 }
204 -re "$prompt $" { fail "set variable char=127 (8-bit)" }
205 timeout { fail "(timeout) set variable char=127 (8-bit)" }
206 }
207
208
209 #
210 # test "set variable" for type "signed char"
211 #
212 send "set variable v_char=0\n"
213 expect {
214 -re "$prompt $"\
215 {
216 send "print v_signed_char\n"
217 expect {
218 -re ".\[0-9\]* = 0 \'.000\'.*$prompt $" { pass "set variable signed char=0" }
219 -re "$prompt $" { fail "set variable signed char=0" }
220 timeout { fail "(timeout) set variable signed char=0" }
221 }
222 }
223 -re "$prompt $" { fail "set variable signed char=0" }
224 timeout { fail "(timeout) set variable signed char=0" }
225 }
226
227
228 send "set variable v_signed_char=1\n"
229 expect {
230 -re "$prompt $"\
231 {
232 send "print v_signed_char\n"
233 expect {
234 -re ".\[0-9\]* = 1 \'.001\'.*$prompt $" { pass "set variable signed char=1" }
235 -re "$prompt $" { fail "set variable signed char=1" }
236 timeout { fail "(timeout) set variable signed char=1" }
237 }
238 }
239 -re "$prompt $" { fail "set variable signed char=1" }
240 timeout { fail "(timeout) set variable signed char=1" }
241 }
242
243
244 send "set variable v_signed_char=27\n"
245 expect {
246 -re "$prompt $"\
247 {
248 send "print v_signed_char\n"
249 expect {
250 -re ".\[0-9\]* = 27 \'.e\'.*$prompt $" { pass "set variable signed char=27 (Esc)" }
251 -re "$prompt $" { fail "set variable signed char=27 (Esc)" }
252 timeout { fail "(timeout) set variable signed char=27 (Esc)" }
253 }
254 }
255 -re "$prompt $" { fail "set variable signed char=27 (Esc)" }
256 timeout { fail "(timeout) set variable signed char=27 (Esc)" }
257 }
258
259
260 send "set variable v_signed_char=32\n"
261 expect {
262 -re "$prompt $"\
263 {
264 send "print v_signed_char\n"
265 expect {
266 -re ".\[0-9\]* = 32 \' \'.*$prompt $" { pass "set variable signed char=32 (SPC)" }
267 -re "$prompt $" { fail "set variable signed char=32 (SPC)" }
268 timeout { fail "(timeout) set variable signed char=32 (SPC)" }
269 }
270 }
271 -re "$prompt $" { fail "set variable signed char=32 (SPC)" }
272 timeout { fail "(timeout) set variable signed char=32 (SPC)" }
273 }
274
275
276 send "set variable v_signed_char=65\n"
277 expect {
278 -re "$prompt $"\
279 {
280 send "print v_signed_char\n"
281 expect {
282 -re ".\[0-9\]* = 65 \'A\'.*$prompt $" { pass "set variable signed char=65 ('A')" }
283 -re "$prompt $" { fail "set variable signed char=65 ('A')" }
284 timeout { fail "(timeout) set variable signed char=65 ('A')" }
285 }
286 }
287 -re "$prompt $" { fail "set variable signed char=65 ('A')" }
288 timeout { fail "(timeout) set variable signed char=65 ('A')" }
289 }
290
291
292 send "set variable v_signed_char=97\n"
293 expect {
294 -re "$prompt $"\
295 {
296 send "print v_signed_char\n"
297 expect {
298 -re ".\[0-9\]* = 97 \'a\'.*$prompt $" { pass "set variable signed char=97 ('a')" }
299 -re "$prompt $" { fail "set variable signed char=97 ('a')" }
300 timeout { fail "(timeout) set variable signed char=97 ('a')" }
301 }
302 }
303 -re "$prompt $" { fail "set variable signed char=97 ('a')" }
304 timeout { fail "(timeout) set variable signed char=97 ('a')" }
305 }
306
307
308 send "set variable v_signed_char=126\n"
309 expect {
310 -re "$prompt $"\
311 {
312 send "print v_signed_char\n"
313 expect {
314 -re ".\[0-9\]* = 126 \'~\'.*$prompt $" { pass "set variable signed char=126 ('~')" }
315 -re "$prompt $" { fail "set variable signed char=126 ('~')" }
316 timeout { fail "(timeout) set variable signed char=126 ('~')" }
317 }
318 }
319 -re "$prompt $" { fail "set variable signed char=126 ('~')" }
320 timeout { fail "(timeout) set variable signed char=126 ('~')" }
321 }
322
323
324 send "set variable v_signed_char=127\n"
325 expect {
326 -re "$prompt $"\
327 {
328 send "print v_signed_char\n"
329 expect {
330 -re ".\[0-9\]* = 127 \'.177\'.*$prompt $" { pass "set variable signed char=127 (8-bit)" }
331 -re "$prompt $" { fail "set variable signed char=127 (8-bit)" }
332 timeout { fail "(timeout) set variable signed char=127 (8-bit)" }
333 }
334 }
335 -re "$prompt $" { fail "set variable signed char=127 (8-bit)" }
336 timeout { fail "(timeout) set variable signed char=127 (8-bit)" }
337 }
338
339
340 gdb_test "set variable v_signed_char=-1" ""
341 gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
342 "set variable signed char=-1 (-1)"
343
344 gdb_test "set variable v_signed_char=0xFF" ""
345 gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
346 "set variable signed char=0xFF (0xFF)"
347
348
349 #
350 # test "set variable" for type "unsigned char"
351 #
352 send "set variable v_unsigned_char=0\n"
353 expect {
354 -re "$prompt $"\
355 {
356 send "print v_unsigned_char\n"
357 expect {
358 -re ".\[0-9\]* = 0 \'.000\'.*$prompt $" { pass "set variable unsigned char=0" }
359 -re "$prompt $" { fail "set variable unsigned char=0" }
360 timeout { fail "(timeout) set variable unsigned char=0" }
361 }
362 }
363 -re "$prompt $" { fail "set variable unsigned char=0" }
364 timeout { fail "(timeout) set variable unsigned char=0" }
365 }
366
367
368 send "set variable v_unsigned_char=1\n"
369 expect {
370 -re "$prompt $"\
371 {
372 send "print v_unsigned_char\n"
373 expect {
374 -re ".\[0-9\]* = 1 \'.001\'.*$prompt $" { pass "set variable unsigned char=1" }
375 -re "$prompt $" { fail "set variable unsigned char=1" }
376 timeout { fail "(timeout) set variable unsigned char=1" }
377 }
378 }
379 -re "$prompt $" { fail "set variable unsigned char=1" }
380 timeout { fail "(timeout) set variable unsigned char=1" }
381 }
382
383
384 send "set variable v_unsigned_char=27\n"
385 expect {
386 -re "$prompt $"\
387 {
388 send "print v_unsigned_char\n"
389 expect {
390 -re ".\[0-9\]* = 27 \'.e\'.*$prompt $" { pass "set variable unsigned char=27 (Esc)" }
391 -re "$prompt $" { fail "set variable unsigned char=27 (Esc)" }
392 timeout { fail "(timeout) set variable unsigned char=27 (Esc)" }
393 }
394 }
395 -re "$prompt $" { fail "set variable unsigned char=27 (Esc)" }
396 timeout { fail "(timeout) set variable unsigned char=27 (Esc)" }
397 }
398
399
400 send "set variable v_unsigned_char=32\n"
401 expect {
402 -re "$prompt $"\
403 {
404 send "print v_unsigned_char\n"
405 expect {
406 -re ".\[0-9\]* = 32 \' \'.*$prompt $" { pass "set variable unsigned char=32 (SPC)" }
407 -re "$prompt $" { fail "set variable unsigned char=32 (SPC)" }
408 timeout { fail "(timeout) set variable unsigned char=32 (SPC)" }
409 }
410 }
411 -re "$prompt $" { fail "set variable unsigned char=32 (SPC)" }
412 timeout { fail "(timeout) set variable unsigned char=32 (SPC)" }
413 }
414
415
416 send "set variable v_unsigned_char=65\n"
417 expect {
418 -re "$prompt $"\
419 {
420 send "print v_unsigned_char\n"
421 expect {
422 -re ".\[0-9\]* = 65 \'A\'.*$prompt $" { pass "set variable unsigned char=65 ('A')" }
423 -re "$prompt $" { fail "set variable unsigned char=65 ('A')" }
424 timeout { fail "(timeout) set variable unsigned char=65 ('A')" }
425 }
426 }
427 -re "$prompt $" { fail "set variable unsigned char=65 ('A')" }
428 timeout { fail "(timeout) set variable unsigned char=65 ('A')" }
429 }
430
431
432 send "set variable v_unsigned_char=97\n"
433 expect {
434 -re "$prompt $"\
435 {
436 send "print v_unsigned_char\n"
437 expect {
438 -re ".\[0-9\]* = 97 \'a\'.*$prompt $" { pass "set variable unsigned char=97 ('a')" }
439 -re "$prompt $" { fail "set variable unsigned char=97 ('a')" }
440 timeout { fail "(timeout) set variable unsigned char=97 ('a')" }
441 }
442 }
443 -re "$prompt $" { fail "set variable unsigned char=97 ('a')" }
444 timeout { fail "(timeout) set variable unsigned char=97 ('a')" }
445 }
446
447
448 send "set variable v_unsigned_char=126\n"
449 expect {
450 -re "$prompt $"\
451 {
452 send "print v_unsigned_char\n"
453 expect {
454 -re ".\[0-9\]* = 126 \'~\'.*$prompt $" { pass "set variable unsigned char=126 ('~')" }
455 -re "$prompt $" { fail "set variable unsigned char=126 ('~')" }
456 timeout { fail "(timeout) set variable unsigned char=126 ('~')" }
457 }
458 }
459 -re "$prompt $" { fail "set variable unsigned char=126 ('~')" }
460 timeout { fail "(timeout) set variable unsigned char=126 ('~')" }
461 }
462
463
464 send "set variable v_unsigned_char=~0\n"
465 expect {
466 -re "$prompt $"\
467 {
468 send "print v_unsigned_char\n"
469 expect {
470 -re ".\[0-9\]* = 255 \'.377\'.*$prompt $" { pass "set variable unsigned char=255 (8-bit)" }
471 -re "$prompt $" { fail "set variable unsigned char=255 (8-bit)" }
472 timeout { fail "(timeout) set variable unsigned char=255 (8-bit)" }
473 }
474 }
475 -re "$prompt $" { fail "set variable unsigned char=255 (8-bit)" }
476 timeout { fail "(timeout) set variable unsigned char=255 (8-bit)" }
477 }
478
479
480 #
481 # test "set variable" for type "short"
482 #
483 send "set variable v_short=0\n"
484 expect {
485 -re "$prompt $"\
486 {
487 send "print v_short\n"
488 expect {
489 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable short=0" }
490 -re "$prompt $" { fail "set variable short=0" }
491 timeout { fail "(timeout) set variable short=0" }
492 }
493 }
494 -re "$prompt $" { fail "set variable short=0" }
495 timeout { fail "(timeout) set variable short=0" }
496 }
497
498
499 send "set variable v_short=1\n"
500 expect {
501 -re "$prompt $"\
502 {
503 send "print v_short\n"
504 expect {
505 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable short=1" }
506 -re "$prompt $" { fail "set variable short=1" }
507 timeout { fail "(timeout) set variable short=1" }
508 }
509 }
510 -re "$prompt $" { fail "set variable short=1" }
511 timeout { fail "(timeout) set variable short=1" }
512 }
513
514
515 send "set variable v_short=-1\n"
516 expect {
517 -re "$prompt $"\
518 {
519 send "print v_short\n"
520 expect {
521 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable short=-1 (minus)" }
522 -re "$prompt $" { fail "set variable short=-1 (minus)" }
523 timeout { fail "(timeout) set variable signed short=-1 (minus)" }
524 }
525 }
526 -re "$prompt $" { fail "set variable short=-1 (minus)" }
527 timeout { fail "(timeout) set variable short=-1 (minus)" }
528 }
529
530
531 #
532 # test "set variable" for type "signed short"
533 #
534 send "set variable v_signed_short=0\n"
535 expect {
536 -re "$prompt $"\
537 {
538 send "print v_signed_short\n"
539 expect {
540 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable signed short=0" }
541 -re "$prompt $" { fail "set variable signed short=0" }
542 timeout { fail "(timeout) set variable signed short=0" }
543 }
544 }
545 -re "$prompt $" { fail "set variable signed short=0" }
546 timeout { fail "(timeout) set variable signed short=0" }
547 }
548
549
550 send "set variable v_signed_short=1\n"
551 expect {
552 -re "$prompt $"\
553 {
554 send "print v_signed_short\n"
555 expect {
556 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable signed short=1" }
557 -re "$prompt $" { fail "set variable signed short=1" }
558 timeout { fail "(timeout) set variable signed short=1" }
559 }
560 }
561 -re "$prompt $" { fail "set variable signed short=1" }
562 timeout { fail "(timeout) set variable signed short=1" }
563 }
564
565
566 send "set variable v_signed_short=-1\n"
567 expect {
568 -re "$prompt $"\
569 {
570 send "print v_signed_short\n"
571 expect {
572 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable signed short=-1 (minus)" }
573 -re "$prompt $" { fail "set variable signed short=-1 (minus)" }
574 timeout { fail "(timeout) set variable signed short=-1 (minus)" }
575 }
576 }
577 -re "$prompt $" { fail "set variable signed short=-1 (minus)" }
578 timeout { fail "(timeout) set variable signed short=-1 (minus)" }
579 }
580
581
582 #
583 # test "set variable" for type "unsigned short"
584 #
585 send "set variable v_unsigned_short=0\n"
586 expect {
587 -re "$prompt $"\
588 {
589 send "print v_unsigned_short\n"
590 expect {
591 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable unsigned short=0" }
592 -re "$prompt $" { fail "set variable unsigned short=0" }
593 timeout { fail "(timeout) set variable unsigned short=0" }
594 }
595 }
596 -re "$prompt $" { fail "set variable unsigned short=0" }
597 timeout { fail "(timeout) set variable unsigned short=0" }
598 }
599
600
601 send "set variable v_unsigned_short=1\n"
602 expect {
603 -re "$prompt $"\
604 {
605 send "print v_unsigned_short\n"
606 expect {
607 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable unsigned short=1" }
608 -re "$prompt $" { fail "set variable unsigned short=1" }
609 timeout { fail "(timeout) set variable unsigned short=1" }
610 }
611 }
612 -re "$prompt $" { fail "set variable unsigned short=1" }
613 timeout { fail "(timeout) set variable unsigned short=1" }
614 }
615
616
617 send "set variable v_unsigned_short=~0\n"
618 expect {
619 -re "$prompt $"\
620 {
621 send "print v_unsigned_short\n"
622 expect {
623 -re ".\[0-9\]* = 65535.*$prompt $" { pass "set variable unsigned short=~0 (minus)" }
624 -re "$prompt $" { fail "set variable unsigned short=~0 (minus)" }
625 timeout { fail "(timeout) set variable unsigned short=~0 (minus)" }
626 }
627 }
628 -re "$prompt $" { fail "set variable unsigned short=~0 (minus)" }
629 timeout { fail "(timeout) set variable unsigned short=~0 (minus)" }
630 }
631
632
633 #
634 # test "set variable" for type "int"
635 #
636 send "set variable v_int=0\n"
637 expect {
638 -re "$prompt $"\
639 {
640 send "print v_int\n"
641 expect {
642 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable int=0" }
643 -re "$prompt $" { fail "set variable int=0" }
644 timeout { fail "(timeout) set variable int=0" }
645 }
646 }
647 -re "$prompt $" { fail "set variable int=0" }
648 timeout { fail "(timeout) set variable int=0" }
649 }
650
651
652 send "set variable v_int=1\n"
653 expect {
654 -re "$prompt $"\
655 {
656 send "print v_int\n"
657 expect {
658 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable int=1" }
659 -re "$prompt $" { fail "set variable int=1" }
660 timeout { fail "(timeout) set variable int=1" }
661 }
662 }
663 -re "$prompt $" { fail "set variable int=1" }
664 timeout { fail "(timeout) set variable int=1" }
665 }
666
667
668 send "set variable v_int=-1\n"
669 expect {
670 -re "$prompt $"\
671 {
672 send "print v_int\n"
673 expect {
674 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable int=-1 (minus)" }
675 -re "$prompt $" { fail "set variable int=-1 (minus)" }
676 timeout { fail "(timeout) set variable signed int=-1 (minus)" }
677 }
678 }
679 -re "$prompt $" { fail "set variable int=-1 (minus)" }
680 timeout { fail "(timeout) set variable int=-1 (minus)" }
681 }
682
683
684 #
685 # test "set variable" for type "signed int"
686 #
687 send "set variable v_signed_int=0\n"
688 expect {
689 -re "$prompt $"\
690 {
691 send "print v_signed_int\n"
692 expect {
693 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable signed int=0" }
694 -re "$prompt $" { fail "set variable signed int=0" }
695 timeout { fail "(timeout) set variable signed int=0" }
696 }
697 }
698 -re "$prompt $" { fail "set variable signed int=0" }
699 timeout { fail "(timeout) set variable signed int=0" }
700 }
701
702
703 send "set variable v_signed_int=1\n"
704 expect {
705 -re "$prompt $"\
706 {
707 send "print v_signed_int\n"
708 expect {
709 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable signed int=1" }
710 -re "$prompt $" { fail "set variable signed int=1" }
711 timeout { fail "(timeout) set variable signed int=1" }
712 }
713 }
714 -re "$prompt $" { fail "set variable signed int=1" }
715 timeout { fail "(timeout) set variable signed int=1" }
716 }
717
718
719 send "set variable v_signed_int=-1\n"
720 expect {
721 -re "$prompt $"\
722 {
723 send "print v_signed_int\n"
724 expect {
725 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable signed int=-1 (minus)" }
726 -re "$prompt $" { fail "set variable signed int=-1 (minus)" }
727 timeout { fail "(timeout) set variable signed int=-1 (minus)" }
728 }
729 }
730 -re "$prompt $" { fail "set variable signed int=-1 (minus)" }
731 timeout { fail "(timeout) set variable signed int=-1 (minus)" }
732 }
733
734
735 #
736 # test "set variable" for type "unsigned int"
737 #
738 send "set variable v_unsigned_int=0\n"
739 expect {
740 -re "$prompt $"\
741 {
742 send "print v_unsigned_int\n"
743 expect {
744 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable unsigned int=0" }
745 -re "$prompt $" { fail "set variable unsigned int=0" }
746 timeout { fail "(timeout) set variable unsigned int=0" }
747 }
748 }
749 -re "$prompt $" { fail "set variable unsigned int=0" }
750 timeout { fail "(timeout) set variable unsigned int=0" }
751 }
752
753
754 send "set variable v_unsigned_int=1\n"
755 expect {
756 -re "$prompt $"\
757 {
758 send "print v_unsigned_int\n"
759 expect {
760 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable unsigned int=1" }
761 -re "$prompt $" { fail "set variable unsigned int=1" }
762 timeout { fail "(timeout) set variable unsigned int=1" }
763 }
764 }
765 -re "$prompt $" { fail "set variable unsigned int=1" }
766 timeout { fail "(timeout) set variable unsigned int=1" }
767 }
768
769
770 send "set variable v_unsigned_int=~0\n"
771 expect {
772 -re "$prompt $"\
773 {
774 send "print v_unsigned_int\n"
775 expect {
776 -re ".\[0-9\]* = 4294967295.*$prompt $" { pass "set variable unsigned int=~0 (minus)" }
777 -re "$prompt $" { fail "set variable unsigned int=~0 (minus)" }
778 timeout { fail "(timeout) set variable unsigned int=~0 (minus)" }
779 }
780 }
781 -re "$prompt $" { fail "set variable unsigned int=~0 (minus)" }
782 timeout { fail "(timeout) set variable unsigned int=~0 (minus)" }
783 }
784
785
786 #
787 # test "set variable" for type "long"
788 #
789 send "set variable v_long=0\n"
790 expect {
791 -re "$prompt $"\
792 {
793 send "print v_long\n"
794 expect {
795 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable long=0" }
796 -re "$prompt $" { fail "set variable long=0" }
797 timeout { fail "(timeout) set variable long=0" }
798 }
799 }
800 -re "$prompt $" { fail "set variable long=0" }
801 timeout { fail "(timeout) set variable long=0" }
802 }
803
804
805 send "set variable v_long=1\n"
806 expect {
807 -re "$prompt $"\
808 {
809 send "print v_long\n"
810 expect {
811 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable long=1" }
812 -re "$prompt $" { fail "set variable long=1" }
813 timeout { fail "(timeout) set variable long=1" }
814 }
815 }
816 -re "$prompt $" { fail "set variable long=1" }
817 timeout { fail "(timeout) set variable long=1" }
818 }
819
820
821 send "set variable v_long=-1\n"
822 expect {
823 -re "$prompt $"\
824 {
825 send "print v_long\n"
826 expect {
827 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable long=-1 (minus)" }
828 -re "$prompt $" { fail "set variable long=-1 (minus)" }
829 timeout { fail "(timeout) set variable signed long=-1 (minus)" }
830 }
831 }
832 -re "$prompt $" { fail "set variable long=-1 (minus)" }
833 timeout { fail "(timeout) set variable long=-1 (minus)" }
834 }
835
836
837 #
838 # test "set variable" for type "signed long"
839 #
840 send "set variable v_signed_long=0\n"
841 expect {
842 -re "$prompt $"\
843 {
844 send "print v_signed_long\n"
845 expect {
846 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable signed long=0" }
847 -re "$prompt $" { fail "set variable signed long=0" }
848 timeout { fail "(timeout) set variable signed long=0" }
849 }
850 }
851 -re "$prompt $" { fail "set variable signed long=0" }
852 timeout { fail "(timeout) set variable signed long=0" }
853 }
854
855
856 send "set variable v_signed_long=1\n"
857 expect {
858 -re "$prompt $"\
859 {
860 send "print v_signed_long\n"
861 expect {
862 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable signed long=1" }
863 -re "$prompt $" { fail "set variable signed long=1" }
864 timeout { fail "(timeout) set variable signed long=1" }
865 }
866 }
867 -re "$prompt $" { fail "set variable signed long=1" }
868 timeout { fail "(timeout) set variable signed long=1" }
869 }
870
871
872 send "set variable v_signed_long=-1\n"
873 expect {
874 -re "$prompt $"\
875 {
876 send "print v_signed_long\n"
877 expect {
878 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable signed long=-1 (minus)" }
879 -re "$prompt $" { fail "set variable signed long=-1 (minus)" }
880 timeout { fail "(timeout) set variable signed long=-1 (minus)" }
881 }
882 }
883 -re "$prompt $" { fail "set variable signed long=-1 (minus)" }
884 timeout { fail "(timeout) set variable signed long=-1 (minus)" }
885 }
886
887
888 #
889 # test "set variable" for type "unsigned long"
890 #
891 send "set variable v_unsigned_long=0\n"
892 expect {
893 -re "$prompt $"\
894 {
895 send "print v_unsigned_long\n"
896 expect {
897 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable unsigned long=0" }
898 -re "$prompt $" { fail "set variable unsigned long=0" }
899 timeout { fail "(timeout) set variable unsigned long=0" }
900 }
901 }
902 -re "$prompt $" { fail "set variable unsigned long=0" }
903 timeout { fail "(timeout) set variable unsigned long=0" }
904 }
905
906
907 send "set variable v_unsigned_long=1\n"
908 expect {
909 -re "$prompt $"\
910 {
911 send "print v_unsigned_long\n"
912 expect {
913 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable unsigned long=1" }
914 -re "$prompt $" { fail "set variable unsigned long=1" }
915 timeout { fail "(timeout) set variable unsigned long=1" }
916 }
917 }
918 -re "$prompt $" { fail "set variable unsigned long=1" }
919 timeout { fail "(timeout) set variable unsigned long=1" }
920 }
921
922
923 send "set variable v_unsigned_long=~0\n"
924 expect {
925 -re "$prompt $"\
926 {
927 send "print v_unsigned_long\n"
928 expect {
929 -re ".\[0-9\]* = $ulong_minus_1.*$prompt $" { pass "set variable unsigned long=~0 (minus)" }
930 -re "$prompt $" { fail "set variable unsigned long=~0 (minus)" }
931 timeout { fail "(timeout) set variable unsigned long=~0 (minus)" }
932 }
933 }
934 -re "$prompt $" { fail "set variable unsigned long=~0 (minus)" }
935 timeout { fail "(timeout) set variable unsigned long=~0 (minus)" }
936 }
937
938
939 #
940 # test "set variable" for type "float"
941 #
942 send "set variable v_float=0.0\n"
943 expect {
944 -re "$prompt $"\
945 {
946 send "print v_float\n"
947 expect {
948 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable float=0" }
949 -re "$prompt $" { fail "set variable float=0" }
950 timeout { fail "(timeout) set variable float=0" }
951 }
952 }
953 -re "$prompt $" { fail "set variable float=0" }
954 timeout { fail "(timeout) set variable float=0" }
955 }
956
957
958 send "set variable v_float=1.0\n"
959 expect {
960 -re "$prompt $"\
961 {
962 send "print v_float\n"
963 expect {
964 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable float=1" }
965 -re "$prompt $" { fail "set variable float=1" }
966 timeout { fail "(timeout) set variable float=1" }
967 }
968 }
969 -re "$prompt $" { fail "set variable float=1" }
970 timeout { fail "(timeout) set variable float=1" }
971 }
972
973
974 send "set variable v_float=-1.0\n"
975 expect {
976 -re "$prompt $"\
977 {
978 send "print v_float\n"
979 expect {
980 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable float=-1 (minus)" }
981 -re "$prompt $" { fail "set variable float=-1 (minus)" }
982 timeout { fail "(timeout) set variable signed float=-1 (minus)" }
983 }
984 }
985 -re "$prompt $" { fail "set variable float=-1 (minus)" }
986 timeout { fail "(timeout) set variable float=-1 (minus)" }
987 }
988
989
990 #
991 # test "set variable" for type "double"
992 #
993 send "set variable v_double=0.0\n"
994 expect {
995 -re "$prompt $"\
996 {
997 send "print v_double\n"
998 expect {
999 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable double=0" }
1000 -re "$prompt $" { fail "set variable double=0" }
1001 timeout { fail "(timeout) set variable double=0" }
1002 }
1003 }
1004 -re "$prompt $" { fail "set variable double=0" }
1005 timeout { fail "(timeout) set variable double=0" }
1006 }
1007
1008
1009 send "set variable v_double=1.0\n"
1010 expect {
1011 -re "$prompt $"\
1012 {
1013 send "print v_double\n"
1014 expect {
1015 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable double=1" }
1016 -re "$prompt $" { fail "set variable double=1" }
1017 timeout { fail "(timeout) set variable double=1" }
1018 }
1019 }
1020 -re "$prompt $" { fail "set variable double=1" }
1021 timeout { fail "(timeout) set variable double=1" }
1022 }
1023
1024
1025 send "set variable v_double=-1.0\n"
1026 expect {
1027 -re "set.*$prompt $"\
1028 {
1029 send "print v_double\n"
1030 expect {
1031 -re "print.*.\[0-9\]* = -1.*$prompt $" { pass "set variable double=-1 (minus)" }
1032 -re "$prompt $" { fail "set variable double=-1 (minus)" }
1033 timeout { fail "(timeout) set variable double=-1 (minus)" }
1034 }
1035 }
1036 -re "$prompt $" { fail "set variable double=-1 (minus)" }
1037 timeout { fail "(timeout) set variable double=-1 (minus)" }
1038 }
1039
1040
1041 #
1042 # test "set variable" for "char array[2]"
1043 #
1044 send "set variable v_char_array\[0\]='h'\n"
1045 expect -re "$prompt $"
1046 send "set variable v_char_array\[1\]='i'\n"
1047 expect {
1048 -re "set.*$prompt $"\
1049 {
1050 send "print v_char_array\n"
1051 expect {
1052 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" { pass "set variable char array=\"hi\" (string)" }
1053 -re "$prompt $" { fail "set variable char array=\"hi\" (string)" }
1054 timeout { fail "(timeout) set variable char array=\"hi\" (string)" }
1055 }
1056 }
1057 -re "$prompt $" { fail "set variable char array=\"hi\" (string)" }
1058 timeout { fail "(timeout) set variable char array=\"hi\" (string)" }
1059 }
1060
1061
1062 #
1063 # test "set variable" for "signed char array[2]"
1064 #
1065 send "set variable v_signed_char_array\[0\]='h'\n"
1066 expect -re "$prompt $"
1067 send "set variable v_signed_char_array\[1\]='i'\n"
1068 expect {
1069 -re "set.*$prompt $"\
1070 {
1071 send "print v_signed_char_array\n"
1072 expect {
1073 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" { pass "set variable signed char array=\"hi\" (string)" }
1074 -re "$prompt $" { fail "set variable signed char array=\"hi\" (string)" }
1075 timeout { fail "(timeout) set variable signed char array=\"hi\" (string)" }
1076 }
1077 }
1078 -re "$prompt $" { fail "set variable signed char array=\"hi\" (string)" }
1079 timeout { fail "(timeout) set variable signed char array=\"hi\" (string)" }
1080 }
1081
1082
1083 #
1084 # test "set variable" for "unsigned char array[2]"
1085 #
1086 send "set variable v_unsigned_char_array\[0\]='h'\n"
1087 expect -re "$prompt $"
1088 send "set variable v_unsigned_char_array\[1\]='i'\n"
1089 expect {
1090 -re "set.*$prompt $"\
1091 {
1092 send "print v_unsigned_char_array\n"
1093 expect {
1094 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" { pass "set variable unsigned char array=\"hi\" (string)" }
1095 -re "$prompt $" { fail "set variable unsigned char array=\"hi\" (string)" }
1096 timeout { fail "(timeout) set variable unsigned char array=\"hi\" (string)" }
1097 }
1098 }
1099 -re "$prompt $" { fail "set variable unsigned char array=\"hi\" (string)" }
1100 timeout { fail "(timeout) set variable unsigned char array=\"hi\" (string)" }
1101 }
1102
1103
1104 #
1105 # test "set variable" for "short array[2]"
1106 #
1107 send "set variable v_short_array\[0\]=123\n"
1108 expect -re "$prompt $"
1109 send "set variable v_short_array\[1\]=-456\n"
1110 expect {
1111 -re "set.*$prompt $"\
1112 {
1113 send "print v_short_array\n"
1114 expect {
1115 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable short array" }
1116 -re "$prompt $" { fail "set variable short array" }
1117 timeout { fail "(timeout) set variable short array" }
1118 }
1119 }
1120 -re "$prompt $" { fail "set variable short array" }
1121 timeout { fail "(timeout) set variable short array" }
1122 }
1123
1124
1125 #
1126 # test "set variable" for "signed short array[2]"
1127 #
1128 send "set variable v_signed_short_array\[0\]=123\n"
1129 expect -re "$prompt $"
1130 send "set variable v_signed_short_array\[1\]=-456\n"
1131 expect {
1132 -re "set.*$prompt $"\
1133 {
1134 send "print v_signed_short_array\n"
1135 expect {
1136 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable signed short array" }
1137 -re "$prompt $" { fail "set variable signed short array" }
1138 timeout { fail "(timeout) set variable signed short array" }
1139 }
1140 }
1141 -re "$prompt $" { fail "set variable signed short array" }
1142 timeout { fail "(timeout) set variable signed short array" }
1143 }
1144
1145
1146 #
1147 # test "set variable" for "unsigned short array[2]"
1148 #
1149 send "set variable v_unsigned_short_array\[0\]=123\n"
1150 expect -re "$prompt $"
1151 send "set variable v_unsigned_short_array\[1\]=-456\n"
1152 expect {
1153 -re "set.*$prompt $"\
1154 {
1155 send "print v_unsigned_short_array\n"
1156 expect {
1157 -re "print.*.\[0-9\]* =.*\{123,.*65080\}.*$prompt $" { pass "set variable unsigned short array" }
1158 -re "$prompt $" { fail "set variable unsigned short array" }
1159 timeout { fail "(timeout) set variable unsigned short array" }
1160 }
1161 }
1162 -re "$prompt $" { fail "set variable unsigned short array" }
1163 timeout { fail "(timeout) set variable unsigned short array" }
1164 }
1165
1166
1167 #
1168 # test "set variable" for "int array[2]"
1169 #
1170 send "set variable v_int_array\[0\]=123\n"
1171 expect -re "$prompt $"
1172 send "set variable v_int_array\[1\]=-456\n"
1173 expect {
1174 -re "set.*$prompt $"\
1175 {
1176 send "print v_int_array\n"
1177 expect {
1178 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable int array" }
1179 -re "$prompt $" { fail "set variable int array" }
1180 timeout { fail "(timeout) set variable int array" }
1181 }
1182 }
1183 -re "$prompt $" { fail "set variable int array" }
1184 timeout { fail "(timeout) set variable int array" }
1185 }
1186
1187
1188 #
1189 # test "set variable" for "signed int array[2]"
1190 #
1191 send "set variable v_signed_int_array\[0\]=123\n"
1192 expect -re "$prompt $"
1193 send "set variable v_signed_int_array\[1\]=-456\n"
1194 expect {
1195 -re "set.*$prompt $"\
1196 {
1197 send "print v_signed_int_array\n"
1198 expect {
1199 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable signed int array" }
1200 -re "$prompt $" { fail "set variable signed int array" }
1201 timeout { fail "(timeout) set variable signed int array" }
1202 }
1203 }
1204 -re "$prompt $" { fail "set variable signed int array" }
1205 timeout { fail "(timeout) set variable signed int array" }
1206 }
1207
1208
1209
1210 #
1211 # test "set variable" for "unsigned int array[2]"
1212 #
1213 send "set variable v_unsigned_int_array\[0\]=123\n"
1214 expect -re "$prompt $"
1215 send "set variable v_unsigned_int_array\[1\]=-456\n"
1216 expect {
1217 -re "set.*$prompt $"\
1218 {
1219 send "print v_unsigned_int_array\n"
1220 expect {
1221 -re "print.*.\[0-9\]* =.*\{123,.*4294966840\}.*$prompt $" { pass "set variable unsigned int array" }
1222 -re "$prompt $" { fail "set variable unsigned int array" }
1223 timeout { fail "(timeout) set variable unsigned int array" }
1224 }
1225 }
1226 -re "$prompt $" { fail "set variable unsigned int array" }
1227 timeout { fail "(timeout) set variable unsigned int array" }
1228 }
1229
1230
1231 #
1232 # test "set variable" for "long array[2]"
1233 #
1234 send "set variable v_long_array\[0\]=123\n"
1235 expect -re "$prompt $"
1236 send "set variable v_long_array\[1\]=-456\n"
1237 expect {
1238 -re "set.*$prompt $"\
1239 {
1240 send "print v_long_array\n"
1241 expect {
1242 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable long array" }
1243 -re "$prompt $" { fail "set variable long array" }
1244 timeout { fail "(timeout) set variable long array" }
1245 }
1246 }
1247 -re "$prompt $" { fail "set variable long array" }
1248 timeout { fail "(timeout) set variable long array" }
1249 }
1250
1251
1252 #
1253 # test "set variable" for "signed long array[2]"
1254 #
1255 send "set variable v_signed_long_array\[0\]=123\n"
1256 expect -re "$prompt $"
1257 send "set variable v_signed_long_array\[1\]=-456\n"
1258 expect {
1259 -re "set.*$prompt $"\
1260 {
1261 send "print v_signed_long_array\n"
1262 expect {
1263 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable signed long array" }
1264 -re "$prompt $" { fail "set variable signed long array" }
1265 timeout { fail "(timeout) set variable signed long array" }
1266 }
1267 }
1268 -re "$prompt $" { fail "set variable signed long array" }
1269 timeout { fail "(timeout) set variable signed long array" }
1270 }
1271
1272
1273
1274 #
1275 # test "set variable" for "unsigned long array[2]"
1276 #
1277 send "set variable v_unsigned_long_array\[0\]=123\n"
1278 expect -re "$prompt $"
1279 send "set variable v_unsigned_long_array\[1\]=-456\n"
1280 expect {
1281 -re "$prompt $"\
1282 {
1283 send "print v_unsigned_long_array\n"
1284 expect {
1285 -re "print.*.\[0-9\]* =.*\{123,.*$ulong_minus_456\}.*$prompt $" { pass "set variable unsigned long array" }
1286 -re "$prompt $" { fail "set variable unsigned long array" }
1287 timeout { fail "(timeout) set variable unsigned long array" }
1288 }
1289 }
1290 -re "$prompt $" { fail "set variable unsigned long array" }
1291 timeout { fail "(timeout) set variable unsigned long array" }
1292 }
1293
1294
1295 #
1296 # test "set variable" for "float array[2]"
1297 #
1298 send "set variable v_float_array\[0\]=123.0\n"
1299 expect -re "$prompt $"
1300 send "set variable v_float_array\[1\]=-456.0\n"
1301 expect {
1302 -re "$prompt $"\
1303 {
1304 send "print v_float_array\n"
1305 expect {
1306 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable float array" }
1307 -re "$prompt $" { fail "set variable float array" }
1308 timeout { fail "(timeout) set variable float array" }
1309 }
1310 }
1311 -re "$prompt $" { fail "set variable float array" }
1312 timeout { fail "(timeout) set variable float array" }
1313 }
1314
1315
1316 #
1317 # test "set variable" for "double array[2]"
1318 #
1319 send "set variable v_double_array\[0\]=123.0\n"
1320 expect -re "$prompt $"
1321 send "set variable v_double_array\[1\]=-456.0\n"
1322 expect {
1323 -re "$prompt $"\
1324 {
1325 send "print v_double_array\n"
1326 expect {
1327 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable double array" }
1328 -re "$prompt $" { fail "set variable double array" }
1329 timeout { fail "(timeout) set variable double array" }
1330 }
1331 }
1332 -re "$prompt $" { fail "set variable double array" }
1333 timeout { fail "(timeout) set variable double array" }
1334 }
1335
1336
1337 #
1338 # test "set variable" for type "char *"
1339 #
1340 send "set v_char_pointer=v_char_array\n"
1341 expect -re "set.*$prompt $"
1342 send "set variable *(v_char_pointer)='h'\n"
1343 expect -re "set.*$prompt $"
1344 send "set variable *(v_char_pointer+1)='i'\n"
1345 expect {
1346 -re "set.*$prompt $" {
1347 send "print v_char_array\n"
1348 expect {
1349 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" {
1350 send "print *(v_char_pointer+1)\n"
1351 expect {
1352 -re "print.*.\[0-9\]* = 105 \'i\'.*$prompt $" { pass "set variable char pointer=\"hi\" (string)" }
1353 -re "$prompt $" { fail "set variable char pointer=\"hi\" (string)" }
1354 timeout { fail "(timeout) set variable char pointer=\"hi\" (string)" }
1355
1356 }
1357 }
1358 -re "$prompt $" { fail "set variable char pointer=\"hi\" (string)" }
1359 timeout { fail "(timeout) set variable char pointer=\"hi\" (string)" }
1360 }
1361 }
1362 -re "$prompt $" { fail "set variable char pointer=\"hi\" (string)" }
1363 timeout { fail "(timeout) set variable char pointer=\"hi\" (string)" }
1364 }
1365
1366
1367 #
1368 # test "set variable" for type "signed char *"
1369 #
1370 send "set v_signed_char_pointer=v_signed_char_array\n"
1371 expect -re "set.*$prompt $"
1372 send "set variable *(v_signed_char_pointer)='h'\n"
1373 expect -re "set.*$prompt $"
1374 send "set variable *(v_signed_char_pointer+1)='i'\n"
1375 expect {
1376 -re "set.*$prompt $" {
1377 send "print v_signed_char_array\n"
1378 expect {
1379 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" {
1380 send "print *(v_signed_char_pointer+1)\n"
1381 expect {
1382 -re "print.*.\[0-9\]* = 105 \'i\'.*$prompt $" { pass "set variable signed char pointer=\"hi\" (string)" }
1383 -re "$prompt $" { fail "set variable signed char pointer=\"hi\" (string)" }
1384 timeout { fail "(timeout) set variable signed char pointer=\"hi\" (string)" }
1385
1386 }
1387 }
1388 -re "$prompt $" { fail "set variable signed char pointer=\"hi\" (string)" }
1389 timeout { fail "(timeout) set variable signed char pointer=\"hi\" (string)" }
1390 }
1391 }
1392 -re "$prompt $" { fail "set variable signed char pointer=\"hi\" (string)" }
1393 timeout { fail "(timeout) set variable signed char pointer=\"hi\" (string)" }
1394 }
1395
1396
1397 #
1398 # test "set variable" for type "unsigned char *"
1399 #
1400 send "set v_unsigned_char_pointer=v_unsigned_char_array\n"
1401 expect -re "set.*$prompt $"
1402 send "set variable *(v_unsigned_char_pointer)='h'\n"
1403 expect -re "set.*$prompt $"
1404 send "set variable *(v_unsigned_char_pointer+1)='i'\n"
1405 expect {
1406 -re "set.*$prompt $" {
1407 send "print v_unsigned_char_array\n"
1408 expect {
1409 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" {
1410 send "print *(v_unsigned_char_pointer+1)\n"
1411 expect {
1412 -re "print.*.\[0-9\]* = 105 \'i\'.*$prompt $" { pass "set variable unsigned char pointer=\"hi\" (string)" }
1413 -re "$prompt $" { fail "set variable unsigned char pointer=\"hi\" (string)" }
1414 timeout { fail "(timeout) set variable unsigned char pointer=\"hi\" (string)" }
1415
1416 }
1417 }
1418 -re "$prompt $" { fail "set variable unsigned char pointer=\"hi\" (string)" }
1419 timeout { fail "(timeout) set variable unsigned char pointer=\"hi\" (string)" }
1420 }
1421 }
1422 -re "$prompt $" { fail "set variable unsigned char pointer=\"hi\" (string)" }
1423 timeout { fail "(timeout) set variable unsigned char pointer=\"hi\" (string)" }
1424 }
1425
1426
1427 #
1428 # test "set variable" for type "short *"
1429 #
1430 send "set v_short_pointer=v_short_array\n"
1431 expect -re "set.*$prompt $"
1432 send "set variable *(v_short_pointer)=123\n"
1433 expect -re "set.*$prompt $"
1434 send "set variable *(v_short_pointer+1)=-456\n"
1435 expect {
1436 -re "set.*$prompt $" {
1437 send "print v_short_array\n"
1438 expect {
1439 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1440 send "print *(v_short_pointer+1)\n"
1441 expect {
1442 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable short pointer" }
1443 -re "$prompt $" { fail "set variable short pointer" }
1444 timeout { fail "(timeout) set variable short pointer" }
1445
1446 }
1447 }
1448 -re "$prompt $" { fail "set variable short pointer" }
1449 timeout { fail "(timeout) set variable short pointer" }
1450 }
1451 }
1452 -re "$prompt $" { fail "set variable short pointer" }
1453 timeout { fail "(timeout) set variable short pointer" }
1454 }
1455
1456
1457 #
1458 # test "set variable" for type "signed short *"
1459 #
1460 gdb_test "set v_signed_short_pointer=v_signed_short_array" ""
1461 gdb_test "set variable *(v_signed_short_pointer)=123" ""
1462 gdb_test "set variable *(v_signed_short_pointer+1)=-456" ""
1463 gdb_test "print v_signed_short_array" ".\[0-9\]* =.*\{123,.*-456\}" \
1464 "set variable signed short pointer"
1465 gdb_test "print *(v_signed_short_pointer+1)" ".\[0-9\]*.*=.*-456"
1466
1467
1468 #
1469 # test "set variable" for type "unsigned short *"
1470 #
1471 gdb_test "set v_unsigned_short_pointer=v_unsigned_short_array" ""
1472 gdb_test "set variable *(v_unsigned_short_pointer)=123" ""
1473 gdb_test "set variable *(v_unsigned_short_pointer+1)=-456" ""
1474 gdb_test "print v_unsigned_short_array" ".\[0-9\]* =.*\{123,.*65080\}" \
1475 "set variable unsigned short pointer"
1476 gdb_test "print *(v_unsigned_short_pointer+1)" ".\[0-9\]* = 65080"
1477
1478
1479 #
1480 # test "set variable" for type "int *"
1481 #
1482 send "set v_int_pointer=v_int_array\n"
1483 expect -re "set.*$prompt $"
1484 send "set variable *(v_int_pointer)=123\n"
1485 expect -re "set.*$prompt $"
1486 send "set variable *(v_int_pointer+1)=-456\n"
1487 expect {
1488 -re "set.*$prompt $" {
1489 send "print v_int_array\n"
1490 expect {
1491 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1492 send "print *(v_int_pointer+1)\n"
1493 expect {
1494 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable int pointer" }
1495 -re "$prompt $" { fail "set variable int pointer" }
1496 timeout { fail "(timeout) set variable int pointer" }
1497
1498 }
1499 }
1500 -re "$prompt $" { fail "set variable int pointer" }
1501 timeout { fail "(timeout) set variable int pointer" }
1502 }
1503 }
1504 -re "$prompt $" { fail "set variable int pointer" }
1505 timeout { fail "(timeout) set variable int pointer" }
1506 }
1507
1508
1509 #
1510 # test "set variable" for type "signed int *"
1511 #
1512 send "set v_signed_int_pointer=v_signed_int_array\n"
1513 expect -re "set.*$prompt $"
1514 send "set variable *(v_signed_int_pointer)=123\n"
1515 expect -re "set.*$prompt $"
1516 send "set variable *(v_signed_int_pointer+1)=-456\n"
1517 expect {
1518 -re "set.*$prompt $" {
1519 send "print v_signed_int_array\n"
1520 expect {
1521 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1522 send "print *(v_signed_int_pointer+1)\n"
1523 expect {
1524 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable signed int pointer" }
1525 -re "$prompt $" { fail "set variable signed int pointer" }
1526 timeout { fail "(timeout) set variable signed int pointer" }
1527
1528 }
1529 }
1530 -re "$prompt $" { fail "set variable signed int pointer" }
1531 timeout { fail "(timeout) set variable signed int pointer" }
1532 }
1533 }
1534 -re "$prompt $" { fail "set variable signed int pointer" }
1535 timeout { fail "(timeout) set variable signed int pointer" }
1536 }
1537
1538
1539 #
1540 # test "set variable" for type "unsigned int *"
1541 #
1542 send "set v_unsigned_int_pointer=v_unsigned_int_array\n"
1543 expect -re "set.*$prompt $"
1544 send "set variable *(v_unsigned_int_pointer)=123\n"
1545 expect -re "set.*$prompt $"
1546 send "set variable *(v_unsigned_int_pointer+1)=-456\n"
1547 expect {
1548 -re "set.*$prompt $" {
1549 send "print v_unsigned_int_array\n"
1550 expect {
1551 -re "print.*.\[0-9\]* =.*\{123,.*4294966840\}.*$prompt $" {
1552 send "print *(v_unsigned_int_pointer+1)\n"
1553 expect {
1554 -re "print.*.\[0-9\]* = 4294966840.*$prompt $" { pass "set variable unsigned int pointer" }
1555 -re "$prompt $" { fail "set variable unsigned int pointer" }
1556 timeout { fail "(timeout) set variable unsigned int pointer" }
1557
1558 }
1559 }
1560 -re "$prompt $" { fail "set variable unsigned int pointer" }
1561 timeout { fail "(timeout) set variable unsigned int pointer" }
1562 }
1563 }
1564 -re "$prompt $" { fail "set variable unsigned int pointer" }
1565 timeout { fail "(timeout) set variable unsigned int pointer" }
1566 }
1567
1568
1569 #
1570 # test "set variable" for type "long *"
1571 #
1572 send "set v_long_pointer=v_long_array\n"
1573 expect -re "set.*$prompt $"
1574 send "set variable *(v_long_pointer)=123\n"
1575 expect -re "set.*$prompt $"
1576 send "set variable *(v_long_pointer+1)=-456\n"
1577 expect {
1578 -re "set.*$prompt $" {
1579 send "print v_long_array\n"
1580 expect {
1581 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1582 send "print *(v_long_pointer+1)\n"
1583 expect {
1584 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable long pointer" }
1585 -re "$prompt $" { fail "set variable long pointer" }
1586 timeout { fail "(timeout) set variable long pointer" }
1587
1588 }
1589 }
1590 -re "$prompt $" { fail "set variable long pointer" }
1591 timeout { fail "(timeout) set variable long pointer" }
1592 }
1593 }
1594 -re "$prompt $" { fail "set variable long pointer" }
1595 timeout { fail "(timeout) set variable long pointer" }
1596 }
1597
1598
1599 #
1600 # test "set variable" for type "signed long *"
1601 #
1602 send "set v_signed_long_pointer=v_signed_long_array\n"
1603 expect -re "set.*$prompt $"
1604 send "set variable *(v_signed_long_pointer)=123\n"
1605 expect -re "set.*$prompt $"
1606 send "set variable *(v_signed_long_pointer+1)=-456\n"
1607 expect {
1608 -re "set.*$prompt $" {
1609 send "print v_signed_long_array\n"
1610 expect {
1611 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1612 send "print *(v_signed_long_pointer+1)\n"
1613 expect {
1614 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable signed long pointer" }
1615 -re "$prompt $" { fail "set variable signed long pointer" }
1616 timeout { fail "(timeout) set variable signed long pointer" }
1617
1618 }
1619 }
1620 -re "$prompt $" { fail "set variable signed long pointer" }
1621 timeout { fail "(timeout) set variable signed long pointer" }
1622 }
1623 }
1624 -re "$prompt $" { fail "set variable signed long pointer" }
1625 timeout { fail "(timeout) set variable signed long pointer" }
1626 }
1627
1628
1629 #
1630 # test "set variable" for type "unsigned long *"
1631 #
1632 send "set v_unsigned_long_pointer=v_unsigned_long_array\n"
1633 expect -re "set.*$prompt $"
1634 send "set variable *(v_unsigned_long_pointer)=123\n"
1635 expect -re "set.*$prompt $"
1636 send "set variable *(v_unsigned_long_pointer+1)=-456\n"
1637 expect {
1638 -re "set.*$prompt $" {
1639 send "print v_unsigned_long_array\n"
1640 expect {
1641 -re "print.*.\[0-9\]* =.*\{123,.*$ulong_minus_456\}.*$prompt $" {
1642 send "print *(v_unsigned_long_pointer+1)\n"
1643 expect {
1644 -re "print.*.\[0-9\]* = $ulong_minus_456.*$prompt $" { pass "set variable unsigned long pointer" }
1645 -re "$prompt $" { fail "set variable unsigned long pointer" }
1646 timeout { fail "(timeout) set variable unsigned long pointer" }
1647
1648 }
1649 }
1650 -re "$prompt $" { fail "set variable unsigned long pointer" }
1651 timeout { fail "(timeout) set variable unsigned long pointer" }
1652 }
1653 }
1654 -re "$prompt $" { fail "set variable unsigned long pointer" }
1655 timeout { fail "(timeout) set variable unsigned long pointer" }
1656 }
1657
1658
1659 #
1660 # test "set variable" for type "float *"
1661 #
1662 send "set v_float_pointer=v_float_array\n"
1663 expect -re "set.*$prompt $"
1664 send "set variable *(v_float_pointer)=123.0\n"
1665 expect -re "set.*$prompt $"
1666 send "set variable *(v_float_pointer+1)=-456.0\n"
1667 expect {
1668 -re "set.*$prompt $" {
1669 send "print v_float_array\n"
1670 expect {
1671 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1672 send "print *(v_float_pointer+1)\n"
1673 expect {
1674 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable float pointer" }
1675 -re "$prompt $" { fail "set variable float pointer" }
1676 timeout { fail "(timeout) set variable float pointer" }
1677
1678 }
1679 }
1680 -re "$prompt $" { fail "set variable float pointer" }
1681 timeout { fail "(timeout) set variable float pointer" }
1682 }
1683 }
1684 -re "$prompt $" { fail "set variable float pointer" }
1685 timeout { fail "(timeout) set variable float pointer" }
1686 }
1687
1688
1689 #
1690 # test "set variable" for type "double *"
1691 #
1692 send "set v_double_pointer=v_double_array\n"
1693 expect -re "set.*$prompt $"
1694 send "set variable *(v_double_pointer)=123.0\n"
1695 expect -re "set.*$prompt $"
1696 send "set variable *(v_double_pointer+1)=-456.0\n"
1697 expect {
1698 -re "set.*$prompt $" {
1699 send "print v_double_array\n"
1700 expect {
1701 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1702 send "print *(v_double_pointer+1)\n"
1703 expect {
1704 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable double pointer" }
1705 -re "$prompt $" { fail "set variable double pointer" }
1706 timeout { fail "(timeout) set variable double pointer" }
1707
1708 }
1709 }
1710 -re "$prompt $" { fail "set variable double pointer" }
1711 timeout { fail "(timeout) set variable double pointer" }
1712 }
1713 }
1714 -re "$prompt $" { fail "set variable double pointer" }
1715 timeout { fail "(timeout) set variable double pointer" }
1716 }
1717
1718
1719 #
1720 # test "set variable" for struct members
1721 #
1722 send "set variable v_struct1.v_char_member='h'\n"
1723 expect {
1724 -re "set.*$prompt $"\
1725 {
1726 send "print v_struct1.v_char_member\n"
1727 expect {
1728 -re "print.*.\[0-9\]* = 104 \'h\'.*$prompt $" { pass "set variable structure char member" }
1729 -re "$prompt $" { fail "set variable structure char member" }
1730 timeout { fail "(timeout) set variable structure char member" }
1731 }
1732 }
1733 -re "$prompt $" { fail "set variable structure char member" }
1734 timeout { fail "(timeout) set variable structure char member" }
1735 }
1736
1737
1738 send "set variable v_struct1.v_short_member=1\n"
1739 expect {
1740 -re "set.*$prompt $"\
1741 {
1742 send "print v_struct1.v_short_member\n"
1743 expect {
1744 -re "print.*.\[0-9\]* = 1.*$prompt $" { pass "set variable structure short member" }
1745 -re "$prompt $" { fail "set variable structure short member" }
1746 timeout { fail "(timeout) set variable structure short member" }
1747 }
1748 }
1749 -re "$prompt $" { fail "set variable structure short member" }
1750 timeout { fail "(timeout) set variable structure short member" }
1751 }
1752
1753
1754 send "set variable v_struct1.v_int_member=2\n"
1755 expect {
1756 -re "set.*$prompt $"\
1757 {
1758 send "print v_struct1.v_int_member\n"
1759 expect {
1760 -re "print.*.\[0-9\]* = 2.*$prompt $" { pass "set variable structure int member" }
1761 -re "$prompt $" { fail "set variable structure int member" }
1762 timeout { fail "(timeout) set variable structure int member" }
1763 }
1764 }
1765 -re "$prompt $" { fail "set variable structure int member" }
1766 timeout { fail "(timeout) set variable structure int member" }
1767 }
1768
1769
1770 send "set variable v_struct1.v_long_member=3\n"
1771 expect {
1772 -re "set.*$prompt $"\
1773 {
1774 send "print v_struct1.v_long_member\n"
1775 expect {
1776 -re "print.*.\[0-9\]* = 3.*$prompt $" { pass "set variable structure long member" }
1777 -re "$prompt $" { fail "set variable structure long member" }
1778 timeout { fail "(timeout) set variable structure long member" }
1779 }
1780 }
1781 -re "$prompt $" { fail "set variable structure long member" }
1782 timeout { fail "(timeout) set variable structure long member" }
1783 }
1784
1785
1786 send "set variable v_struct1.v_float_member=4.0\n"
1787 expect {
1788 -re "set.*$prompt $"\
1789 {
1790 send "print v_struct1.v_float_member\n"
1791 expect {
1792 -re "print.*.\[0-9\]* = 4.*$prompt $" { pass "set variable structure float member" }
1793 -re "$prompt $" { fail "set variable structure float member" }
1794 timeout { fail "(timeout) set variable structure float member" }
1795 }
1796 }
1797 -re "$prompt $" { fail "set variable structure float member" }
1798 timeout { fail "(timeout) set variable structure float member" }
1799 }
1800
1801
1802 send "set variable v_struct1.v_double_member=5.0\n"
1803 expect {
1804 -re "set.*$prompt $"\
1805 {
1806 send "print v_struct1.v_double_member\n"
1807 expect {
1808 -re "print.*.\[0-9\]* = 5.*$prompt $" { pass "set variable structure double member" }
1809 -re "$prompt $" { fail "set variable structure double member" }
1810 timeout { fail "(timeout) set variable structure double member" }
1811 }
1812 }
1813 -re "$prompt $" { fail "set variable structure double member" }
1814 timeout { fail "(timeout) set variable structure double member" }
1815 }
1816
1817
1818 gdb_test "print v_struct1" \
1819 "print.*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\
1820 .*v_int_member = 2,.*\
1821 v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \
1822 "set print structure #1"
1823
1824 # This should be an error. GCC extensions for structure constants require
1825 # the type of the structure to be specified, as in
1826 # v_struct1 = (struct t_struct) {32, 33, 34, 35, 36, 37}
1827 # GDB should do the same if it wants to provide this feature.
1828 gdb_test "set variable v_struct1 = {32, 33, 34, 35, 36, 37}" "Invalid.*"
1829
1830 # And after the error the structure should be unchanged.
1831 gdb_test "print v_struct1" \
1832 "print.*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\
1833 .*v_int_member = 2,.*\
1834 v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \
1835 "set print structure #2"
1836
1837 # Test printing of enumeration bitfields.
1838 # GNU C supports them, some other compilers don't.
1839
1840 if {$gcc_compiled} then {
1841 gdb_test "print sef.field=sm1" "print.*.\[0-9\]* = sm1"
1842 gdb_test "print sef.field" "print.*.\[0-9\]* = sm1" "print sef.field (sm1)"
1843 gdb_test "print sef.field=s1" "print.*.\[0-9\]* = s1"
1844 gdb_test "print sef.field" "print.*.\[0-9\]* = s1" "print sef.field (s1)"
1845 gdb_test "print uef.field=u1" "print.*.\[0-9\]* = u1"
1846 gdb_test "print uef.field" "print.*.\[0-9\]* = u1" "print uef.field (u1)"
1847 gdb_test "print uef.field=u2" "print.*.\[0-9\]* = u2"
1848 gdb_test "print uef.field" "print.*.\[0-9\]* = u2" "print uef.field (u2)"
1849 }
This page took 0.157236 seconds and 5 git commands to generate.