OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.base/] [logical.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
# Copyright (C) 1998 Free Software Foundation, Inc.
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
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.
12
#
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.
16
 
17
# Please email any bugs, comments, and/or additions to this file to:
18
# bug-gdb@prep.ai.mit.edu
19
 
20
# This file was written by Elena Zannoni (ezannoni@cygnus.com)
21
 
22
# This file is part of the gdb testsuite
23
 
24
#
25
# tests for correctenss of logical operators, associativity and precedence
26
# with integer type variables
27
#
28
 
29
if $tracelevel then {
30
        strace $tracelevel
31
        }
32
 
33
#
34
# test running programs
35
#
36
set prms_id 0
37
set bug_id 0
38
 
39
set testfile "int-type"
40
set srcfile ${testfile}.c
41
set binfile ${objdir}/${subdir}/${testfile}
42
 
43
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
44
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
45
    }
46
 
47
if [get_compiler_info ${binfile}] {
48
    return -1;
49
}
50
 
51
gdb_exit
52
gdb_start
53
gdb_reinitialize_dir $srcdir/$subdir
54
gdb_load ${binfile}
55
 
56
 
57
#
58
# set it up at a breakpoint so we can play with the variable values
59
#
60
 
61
if ![runto_main] then {
62
    perror "couldn't run to breakpoint"
63
    continue
64
}
65
 
66
#
67
# test expressions with "int" types
68
#
69
 
70
gdb_test "set variable x=0" "" "set variable x=0"
71
gdb_test "set variable y=0" "" "set variable y=0"
72
gdb_test "set variable z=0" "" "set variable z=0"
73
 
74
send_gdb "print x\n"
75
gdb_expect {
76
    -re ".*0.*$gdb_prompt $" {
77
        pass "print value of x"
78
      }
79
    -re ".*$gdb_prompt $" { fail "print value of x" }
80
    timeout           { fail "(timeout) print value of x" }
81
  }
82
 
83
 
84
send_gdb "print y\n"
85
gdb_expect {
86
    -re ".*0.*$gdb_prompt $" {
87
        pass "print value of y"
88
      }
89
    -re ".*$gdb_prompt $" { fail "print value of y" }
90
    timeout           { fail "(timeout) print value of y" }
91
  }
92
 
93
send_gdb "print z\n"
94
gdb_expect {
95
    -re ".*0.*$gdb_prompt $" {
96
        pass "print value of z"
97
      }
98
    -re ".*$gdb_prompt $" { fail "print value of z" }
99
    timeout           { fail "(timeout) print value of z" }
100
  }
101
 
102
 
103
# truth tables for && , || , !
104
 
105
send_gdb "print x && y\n"
106
gdb_expect {
107
    -re ".*$false.*$gdb_prompt $" {
108
        pass "print value of x
109
      }
110
    -re ".*$gdb_prompt $" { fail "print value of x
111
    timeout           { fail "(timeout) print value of x
112
  }
113
 
114
 
115
 
116
send_gdb "print x || y\n"
117
gdb_expect {
118
    -re ".*$false.*$gdb_prompt $" {
119
        pass "print value of x<=y"
120
      }
121
    -re ".*$gdb_prompt $" { fail "print value of x<=y" }
122
    timeout           { fail "(timeout) print value of x<=y" }
123
  }
124
 
125
send_gdb "print !x\n"
126
gdb_expect {
127
    -re ".*$true.*$gdb_prompt $" {
128
        pass "print value of x>y"
129
      }
130
    -re ".*$gdb_prompt $" { fail "print value of x>y" }
131
    timeout           { fail "(timeout) print value of x>y" }
132
  }
133
 
134
gdb_test "set variable y=1" "" "set variable y=1"
135
 
136
send_gdb "print x && y\n"
137
gdb_expect {
138
    -re ".*$false.*$gdb_prompt $" {
139
        pass "print value of x
140
      }
141
    -re ".*$gdb_prompt $" { fail "print value of x
142
    timeout           { fail "(timeout) print value of x
143
  }
144
 
145
 
146
 
147
send_gdb "print x || y\n"
148
gdb_expect {
149
    -re ".*$true.*$gdb_prompt $" {
150
        pass "print value of x<=y"
151
      }
152
    -re ".*$gdb_prompt $" { fail "print value of x<=y" }
153
    timeout           { fail "(timeout) print value of x<=y" }
154
  }
155
 
156
gdb_test "set variable x=1" "" "set variable x=1"
157
 
158
send_gdb "print x && y\n"
159
gdb_expect {
160
    -re ".*$true.*$gdb_prompt $" {
161
        pass "print value of x
162
      }
163
    -re ".*$gdb_prompt $" { fail "print value of x
164
    timeout           { fail "(timeout) print value of x
165
  }
166
 
167
 
168
 
169
send_gdb "print x || y\n"
170
gdb_expect {
171
    -re ".*$true.*$gdb_prompt $" {
172
        pass "print value of x<=y"
173
      }
174
    -re ".*$gdb_prompt $" { fail "print value of x<=y" }
175
    timeout           { fail "(timeout) print value of x<=y" }
176
  }
177
 
178
send_gdb "print !x\n"
179
gdb_expect {
180
    -re ".*$false.*$gdb_prompt $" {
181
        pass "print value of x>y"
182
      }
183
    -re ".*$gdb_prompt $" { fail "print value of x>y" }
184
    timeout           { fail "(timeout) print value of x>y" }
185
  }
186
 
187
gdb_test "set variable y=0" "" "set variable y=0"
188
 
189
send_gdb "print x && y\n"
190
gdb_expect {
191
    -re ".*$false.*$gdb_prompt $" {
192
        pass "print value of x
193
      }
194
    -re ".*$gdb_prompt $" { fail "print value of x
195
    timeout           { fail "(timeout) print value of x
196
  }
197
 
198
 
199
 
200
send_gdb "print x || y\n"
201
gdb_expect {
202
    -re ".*$true.*$gdb_prompt $" {
203
        pass "print value of x<=y"
204
      }
205
    -re ".*$gdb_prompt $" { fail "print value of x<=y" }
206
    timeout           { fail "(timeout) print value of x<=y" }
207
  }
208
 
209
 
210
# end truth tables for &&, ||, !
211
 
212
 
213
# test associativity of && , || , !
214
 
215
gdb_test "set variable x=0" "" "set variable x=0"
216
gdb_test "set variable y=0" "" "set variable y=0"
217
gdb_test "set variable z=0" "" "set variable z=0"
218
 
219
send_gdb "print x && y && z\n"
220
gdb_expect {
221
    -re ".*$false.*$gdb_prompt $" {
222
        pass "print value of x &&  y && z (000)"
223
      }
224
    -re ".*$gdb_prompt $" { fail "print value of x && y && z (000) " }
225
    timeout           { fail "(timeout) print value of x && y && z (000) " }
226
  }
227
 
228
send_gdb "print x || y || z\n"
229
gdb_expect {
230
    -re ".*$false.*$gdb_prompt $" {
231
        pass "print value of x || y || z (000)"
232
      }
233
    -re ".*$gdb_prompt $" { fail "print value of x || y || z (000)" }
234
    timeout           { fail "(timeout) print value of x || y || z (000) " }
235
  }
236
 
237
send_gdb "print !!x\n"
238
gdb_expect {
239
    -re ".*$false.*$gdb_prompt $" {
240
        pass "print value of !!x (0)"
241
      }
242
    -re ".*$gdb_prompt $" { fail "print value of !!x (0)" }
243
    timeout           { fail "(timeout) print value of !!x (0) " }
244
  }
245
 
246
 
247
gdb_test "set variable y=1" "" "set variable y=1"
248
 
249
send_gdb "print x && y && z\n"
250
gdb_expect {
251
    -re ".*$false.*$gdb_prompt $" {
252
        pass "print value of x &&  y && z (010)"
253
      }
254
    -re ".*$gdb_prompt $" { fail "print value of x && y && z (010) " }
255
    timeout           { fail "(timeout) print value of x && y && z (010) " }
256
  }
257
 
258
send_gdb "print x || y || z\n"
259
gdb_expect {
260
    -re ".*$true.*$gdb_prompt $" {
261
        pass "print value of x || y || z (010)"
262
      }
263
    -re ".*$gdb_prompt $" { fail "print value of x || y || z (010)" }
264
    timeout           { fail "(timeout) print value of x || y || z (010) " }
265
  }
266
 
267
 
268
gdb_test "set variable z=1" "" "set variable z=1"
269
 
270
send_gdb "print x && y && z\n"
271
gdb_expect {
272
    -re ".*$false.*$gdb_prompt $" {
273
        pass "print value of x &&  y && z (011)"
274
      }
275
    -re ".*$gdb_prompt $" { fail "print value of x && y && z (011) " }
276
    timeout           { fail "(timeout) print value of x && y && z (011) " }
277
  }
278
 
279
send_gdb "print x || y || z\n"
280
gdb_expect {
281
    -re ".*$true.*$gdb_prompt $" {
282
        pass "print value of x || y || z (011)"
283
      }
284
    -re ".*$gdb_prompt $" { fail "print value of x || y || z (011)" }
285
    timeout           { fail "(timeout) print value of x || y || z (011) " }
286
  }
287
 
288
 
289
gdb_test "set variable x=1" "" "set variable x=1"
290
 
291
send_gdb "print x && y && z\n"
292
gdb_expect {
293
    -re ".*$true.*$gdb_prompt $" {
294
        pass "print value of x &&  y && z (111)"
295
      }
296
    -re ".*$gdb_prompt $" { fail "print value of x && y && z (111) " }
297
    timeout           { fail "(timeout) print value of x && y && z (111) " }
298
  }
299
 
300
send_gdb "print x || y || z\n"
301
gdb_expect {
302
    -re ".*$true.*$gdb_prompt $" {
303
        pass "print value of x || y || z (111)"
304
      }
305
    -re ".*$gdb_prompt $" { fail "print value of x || y || z (111)" }
306
    timeout           { fail "(timeout) print value of x || y || z (111) " }
307
  }
308
 
309
send_gdb "print !!x\n"
310
gdb_expect {
311
    -re ".*$true.*$gdb_prompt $" {
312
        pass "print value of !!x (1)"
313
      }
314
    -re ".*$gdb_prompt $" { fail "print value of !!x (1)" }
315
    timeout           { fail "(timeout) print value of !!x (1) " }
316
  }
317
 
318
 
319
gdb_test "set variable z=0" "" "set variable z=0"
320
 
321
send_gdb "print x && y && z\n"
322
gdb_expect {
323
    -re ".*$false.*$gdb_prompt $" {
324
        pass "print value of x &&  y && z (110)"
325
      }
326
    -re ".*$gdb_prompt $" { fail "print value of x && y && z (110) " }
327
    timeout           { fail "(timeout) print value of x && y && z (110) " }
328
  }
329
 
330
send_gdb "print x || y || z\n"
331
gdb_expect {
332
    -re ".*$true.*$gdb_prompt $" {
333
        pass "print value of x || y || z (110)"
334
      }
335
    -re ".*$gdb_prompt $" { fail "print value of x || y || z (110)" }
336
    timeout           { fail "(timeout) print value of x || y || z (110) " }
337
  }
338
 
339
 
340
 
341
 
342
gdb_test "set variable y=0" "" "set variable y=0"
343
 
344
send_gdb "print x && y && z\n"
345
gdb_expect {
346
    -re ".*$false.*$gdb_prompt $" {
347
        pass "print value of x &&  y && z (100)"
348
      }
349
    -re ".*$gdb_prompt $" { fail "print value of x && y && z (100) " }
350
    timeout           { fail "(timeout) print value of x && y && z (100) " }
351
  }
352
 
353
send_gdb "print x || y || z\n"
354
gdb_expect {
355
    -re ".*$true.*$gdb_prompt $" {
356
        pass "print value of x || y || z (100)"
357
      }
358
    -re ".*$gdb_prompt $" { fail "print value of x || y || z (100)" }
359
    timeout           { fail "(timeout) print value of x || y || z (100) " }
360
  }
361
 
362
 
363
 
364
 
365
gdb_test "set variable z=1" "" "set variable z=1"
366
 
367
send_gdb "print x && y && z\n"
368
gdb_expect {
369
    -re ".*$false.*$gdb_prompt $" {
370
        pass "print value of x &&  y && z (101)"
371
      }
372
    -re ".*$gdb_prompt $" { fail "print value of x && y && z (101) " }
373
    timeout           { fail "(timeout) print value of x && y && z (101) " }
374
  }
375
 
376
send_gdb "print x || y || z\n"
377
gdb_expect {
378
    -re ".*$true.*$gdb_prompt $" {
379
        pass "print value of x || y || z (101)"
380
      }
381
    -re ".*$gdb_prompt $" { fail "print value of x || y || z (101)" }
382
    timeout           { fail "(timeout) print value of x || y || z (101) " }
383
  }
384
 
385
 
386
gdb_test "set variable x=0" "" "set variable x=0"
387
 
388
send_gdb "print x && y && z\n"
389
gdb_expect {
390
    -re ".*$false.*$gdb_prompt $" {
391
        pass "print value of x &&  y && z (001)"
392
      }
393
    -re ".*$gdb_prompt $" { fail "print value of x && y && z (001) " }
394
    timeout           { fail "(timeout) print value of x && y && z (001) " }
395
  }
396
 
397
send_gdb "print x || y || z\n"
398
gdb_expect {
399
    -re ".*$true.*$gdb_prompt $" {
400
        pass "print value of x || y || z (001)"
401
      }
402
    -re ".*$gdb_prompt $" { fail "print value of x || y || z (001)" }
403
    timeout           { fail "(timeout) print value of x || y || z (001) " }
404
  }
405
 
406
 
407
 
408
 
409
# test precedence of &&, || ,!
410
 
411
 
412
send_gdb "print !x && y\n"
413
gdb_expect {
414
    -re ".*$false.*$gdb_prompt $" {
415
        pass "print value of !x && y  (00)"
416
      }
417
    -re ".*$gdb_prompt $" { fail "print value of  !x && y (00)" }
418
    timeout           { fail "(timeout) print value of !x && y (00) " }
419
  }
420
 
421
 
422
gdb_test "set variable x=1" "" "set variable x=1"
423
 
424
 
425
send_gdb "print !x && y\n"
426
gdb_expect {
427
    -re ".*$false.*$gdb_prompt $" {
428
        pass "print value of !x && y  (10)"
429
      }
430
    -re ".*$gdb_prompt $" { fail "print value of  !x && y (10)" }
431
    timeout           { fail "(timeout) print value of !x && y (10) " }
432
  }
433
 
434
 
435
 
436
 
437
gdb_test "set variable y=1" "" "set variable y=1"
438
 
439
send_gdb "print !x || y\n"
440
gdb_expect {
441
    -re ".*$true.*$gdb_prompt $" {
442
        pass "print value of !x || y  (11)"
443
      }
444
    -re ".*$gdb_prompt $" { fail "print value of  !x || y (11)" }
445
    timeout           { fail "(timeout) print value of !x || y (11) " }
446
  }
447
 
448
 
449
gdb_test "set variable x=0" "" "set variable x=0"
450
 
451
 
452
send_gdb "print !x || y\n"
453
gdb_expect {
454
    -re ".*$true.*$gdb_prompt $" {
455
        pass "print value of !x || y  (01)"
456
      }
457
    -re ".*$gdb_prompt $" { fail "print value of  !x || y (01)" }
458
    timeout           { fail "(timeout) print value of !x || y (01) " }
459
  }
460
 
461
 
462
 
463
gdb_test "set variable x=1" "" "set variable x=1"
464
gdb_test "set variable z=0" "" "set variable z=0"
465
 
466
send_gdb "print x || y && z\n"
467
gdb_expect {
468
    -re ".*$true.*$gdb_prompt $" {
469
        pass "print value of x || y && z  (110)"
470
      }
471
    -re ".*$gdb_prompt $" { fail "print value of  x || y && z (110)" }
472
    timeout           { fail "(timeout) print value of x || y && z (110) " }
473
  }
474
 
475
 
476
gdb_test "set variable y=0" "" "set variable y=0"
477
 
478
 
479
send_gdb "print x || y && z\n"
480
gdb_expect {
481
    -re ".*$true.*$gdb_prompt $" {
482
        pass "print value of x || y && z (100)"
483
      }
484
    -re ".*$gdb_prompt $" { fail "print value of  x || y && z (100)" }
485
    timeout           { fail "(timeout) print value of x || y && z (100) " }
486
  }
487
 
488
 
489
 
490
gdb_test "set variable x=0" "" "set variable x=0"
491
 
492
send_gdb "print x || !y && z\n"
493
gdb_expect {
494
    -re ".*$false.*$gdb_prompt $" {
495
 
496
         gdb_test "set variable x=1" "" "set variable x=1"
497
         send_gdb "print x || !y && z\n"
498
         gdb_expect {
499
             -re ".*$true.*$gdb_prompt $" {
500
                  pass "print value of x || !y && z "
501
             }
502
             -re ".*$gdb_prompt $" { fail "print value of  x || !y && z" }
503
             timeout           { fail "(timeout) print value of x || !y && z " }
504
           }
505
    }
506
    -re ".*$gdb_prompt $" { fail "print value of  x || y && z " }
507
    timeout           { fail "(timeout) print value of x || y && z " }
508
 }
509
 
510
 
511
 
512
 
513
 
514
gdb_test "set variable x=1" "" "set variable x=1"
515
gdb_test "set variable y=2" "" "set variable y=2"
516
gdb_test "set variable w=3" "" "set variable w=3"
517
gdb_test "set variable z=3" "" "set variable z=3"
518
 
519
 
520
send_gdb "print x > y || w == z\n"
521
gdb_expect {
522
    -re ".*$true.*$gdb_prompt $" {
523
        pass "print value of x > y || w == z"
524
      }
525
    -re ".*$gdb_prompt $" { fail "print value of  x > y || w == z" }
526
    timeout           { fail "(timeout) print value of x > y || w == z " }
527
  }
528
 
529
 
530
gdb_test "set variable x=1" "" "set variable x=1"
531
gdb_test "set variable y=2" "" "set variable y=2"
532
gdb_test "set variable w=1" "" "set variable w=1"
533
gdb_test "set variable z=3" "" "set variable z=3"
534
 
535
 
536
send_gdb "print x >= y && w != z\n"
537
gdb_expect {
538
    -re ".*$false.*$gdb_prompt $" {
539
        pass "print value of x >= y || w != z"
540
      }
541
    -re ".*$gdb_prompt $" { fail "print value of  x >= y || w != z" }
542
    timeout           { fail "(timeout) print value of x >= y || w != z " }
543
  }
544
 
545
 
546
 
547
gdb_test "set variable x=2" "" "set variable x=2"
548
gdb_test "set variable y=2" "" "set variable y=2"
549
gdb_test "set variable w=2" "" "set variable w=2"
550
gdb_test "set variable z=3" "" "set variable z=3"
551
 
552
 
553
send_gdb "print ! x > y || w + z\n"
554
gdb_expect {
555
    -re ".*$true.*$gdb_prompt $" {
556
        pass "print value of x > y || w != z"
557
      }
558
    -re ".*$gdb_prompt $" { fail "print value of  x > y || w != z" }
559
    timeout           { fail "(timeout) print value of x > y || w != z " }
560
  }
561
 
562
 
563
 
564
 
565
 
566
 
567
 
568
 
569
 
570
 
571
 
572
 
573
 
574
 
575
 
576
 
577
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.