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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.base/] [relational.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
# tests for correctenss of relational operators, associativity and precedence
25
# with integer type variables
26
#
27
 
28
if $tracelevel then {
29
        strace $tracelevel
30
        }
31
 
32
#
33
# test running programs
34
#
35
set prms_id 0
36
set bug_id 0
37
 
38
set testfile "int-type"
39
set srcfile ${testfile}.c
40
set binfile ${objdir}/${subdir}/${testfile}
41
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
42
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
43
    }
44
 
45
if [get_compiler_info ${binfile}] {
46
    return -1;
47
}
48
 
49
gdb_exit
50
gdb_start
51
gdb_reinitialize_dir $srcdir/$subdir
52
gdb_load ${binfile}
53
 
54
 
55
#
56
# set it up at a breakpoint so we can play with the variable values
57
#
58
 
59
if ![runto_main] then {
60
    perror "couldn't run to breakpoint"
61
    continue
62
}
63
 
64
#
65
# test expressions with "int" types
66
#
67
 
68
gdb_test "set variable x=14" "" "set variable x=14"
69
gdb_test "set variable y=2" "" "set variable y=2"
70
gdb_test "set variable z=2" "" "set variable z=2"
71
gdb_test "set variable w=3" "" "set variable w=3"
72
 
73
send_gdb "print x\n"
74
gdb_expect {
75
    -re ".*14.*$gdb_prompt $" {
76
        pass "print value of x"
77
      }
78
    -re ".*$gdb_prompt $" { fail "print value of x" }
79
    timeout           { fail "(timeout) print value of x" }
80
  }
81
 
82
 
83
send_gdb "print y\n"
84
gdb_expect {
85
    -re ".*2.*$gdb_prompt $" {
86
        pass "print value of y"
87
      }
88
    -re ".*$gdb_prompt $" { fail "print value of y" }
89
    timeout           { fail "(timeout) print value of y" }
90
  }
91
 
92
send_gdb "print z\n"
93
gdb_expect {
94
    -re ".*2.*$gdb_prompt $" {
95
        pass "print value of z"
96
      }
97
    -re ".*$gdb_prompt $" { fail "print value of z" }
98
    timeout           { fail "(timeout) print value of z" }
99
  }
100
 
101
send_gdb "print w\n"
102
gdb_expect {
103
    -re ".*3.*$gdb_prompt $" {
104
        pass "print value of w"
105
      }
106
    -re ".*$gdb_prompt $" { fail "print value of w" }
107
    timeout           { fail "(timeout) print value of w" }
108
  }
109
 
110
 
111
 
112
send_gdb "print x < y\n"
113
gdb_expect {
114
    -re ".*$false.*$gdb_prompt $" {
115
        pass "print value of x
116
      }
117
    -re ".*$gdb_prompt $" { fail "print value of x
118
    timeout           { fail "(timeout) print value of x
119
  }
120
 
121
send_gdb "print x <= y\n"
122
gdb_expect {
123
    -re ".*$false.*$gdb_prompt $" {
124
        pass "print value of x<=y"
125
      }
126
    -re ".*$gdb_prompt $" { fail "print value of x<=y" }
127
    timeout           { fail "(timeout) print value of x<=y" }
128
  }
129
 
130
send_gdb "print x > y\n"
131
gdb_expect {
132
    -re ".*$true.*$gdb_prompt $" {
133
        pass "print value of x>y"
134
      }
135
    -re ".*$gdb_prompt $" { fail "print value of x>y" }
136
    timeout           { fail "(timeout) print value of x>y" }
137
  }
138
 
139
send_gdb "print x >= y\n"
140
gdb_expect {
141
    -re ".*$true.*$gdb_prompt $" {
142
        pass "print value of x>=y"
143
      }
144
    -re ".*$gdb_prompt $" { fail "print value of x>=y" }
145
    timeout           { fail "(timeout) print value of x>=y" }
146
  }
147
 
148
send_gdb "print x == y\n"
149
gdb_expect {
150
    -re ".*$false.*$gdb_prompt $" {
151
        pass "print value of x==y"
152
      }
153
    -re ".*$gdb_prompt $" { fail "print value of x==y" }
154
    timeout           { fail "(timeout) print value of x==y" }
155
  }
156
 
157
send_gdb "print x != y\n"
158
gdb_expect {
159
    -re ".*$true.*$gdb_prompt $" {
160
        pass "print value of x!=y"
161
      }
162
    -re ".*$gdb_prompt $" { fail "print value of x!=y" }
163
    timeout           { fail "(timeout) print value of x!=y" }
164
  }
165
 
166
 
167
 
168
# Test associativity of <, >, <=, >=, ==, !=
169
 
170
gdb_test "set variable x=3" "" "set variable x"
171
gdb_test "set variable y=5" ""  "set variable y"
172
gdb_test "set variable z=2" ""  "set variable z"
173
 
174
 
175
 
176
send_gdb "print x < y < z\n"
177
gdb_expect {
178
    -re ".*$true.*\r\n$gdb_prompt $" {
179
        pass "print value of x
180
      }
181
    -re ".*$gdb_prompt $" { fail "print value of x
182
    timeout           { fail "(timeout) print value of x
183
  }
184
 
185
send_gdb "print x <= y <= z\n"
186
gdb_expect {
187
    -re ".*$true\r\n$gdb_prompt $" {
188
        pass "print value of x<=y<=z"
189
      }
190
    -re ".*$gdb_prompt $" { fail "print value of x<=y<=z" }
191
    timeout           { fail "(timeout) print value of x<=y<=z" }
192
  }
193
 
194
send_gdb "print x > y > z\n"
195
gdb_expect {
196
    -re ".*$false.*\r\n$gdb_prompt $" {
197
        pass "print value of x>y>z"
198
      }
199
    -re 8".*$gdb_prompt $" { fail "print value of x>y>z" }
200
    timeout           { fail "(timeout) print value of x>y>z" }
201
  }
202
 
203
send_gdb "print x >= y >= z\n"
204
gdb_expect {
205
    -re ".*$false.*\r\n$gdb_prompt $" {
206
        pass "print value of x>=y>=z"
207
      }
208
    -re ".*$gdb_prompt $" { fail "print value of x>=y>=z" }
209
    timeout           { fail "(timeout) print value of x>=y>=z" }
210
  }
211
 
212
gdb_test "set variable x=2" "" "set variable x"
213
gdb_test "set variable y=2" ""  "set variable y"
214
gdb_test "set variable z=1" ""  "set variable z"
215
 
216
 
217
send_gdb "print x == y == z\n"
218
gdb_expect {
219
    -re ".*$true.*$gdb_prompt $" {
220
        pass "print value of x==y==z"
221
      }
222
    -re ".*$gdb_prompt $" { fail "print value of x==y==z" }
223
    timeout           { fail "(timeout) print value of x==y==z" }
224
  }
225
 
226
gdb_test "set variable z=0" ""  "set variable z"
227
 
228
 
229
send_gdb "print x != y != z\n"
230
gdb_expect {
231
    -re ".*$false\r\n$gdb_prompt $" {
232
        pass "print value of x!=y!=z"
233
      }
234
    -re ".*$gdb_prompt $" { fail "print value of x!=y!=z" }
235
    timeout           { fail "(timeout) print value of x!=y!=z" }
236
  }
237
 
238
 
239
# test precedence rules on pairs of relational operators
240
 
241
gdb_test "set variable x=0" "" "set variable x"
242
gdb_test "set variable y=2" ""  "set variable y"
243
gdb_test "set variable z=2" ""  "set variable z"
244
 
245
 
246
send_gdb "print x < y == z\n"
247
gdb_expect {
248
    -re ".*$false.*$gdb_prompt $" {
249
        pass "print value of x
250
      }
251
    -re ".*$gdb_prompt $" { fail "print value of x
252
    timeout           { fail "(timeout) print value of x
253
  }
254
 
255
# 0  2  2
256
send_gdb "print x < y != z\n"
257
gdb_expect {
258
    -re ".*$true.*$gdb_prompt $" {
259
        pass "print value of x
260
      }
261
    -re ".*$gdb_prompt $" { fail "print value of x
262
    timeout           { fail "(timeout) print value of x
263
  }
264
 
265
gdb_test "set variable x=2" "" "set variable x"
266
gdb_test "set variable y=3" ""  "set variable y"
267
gdb_test "set variable z=1" ""  "set variable z"
268
 
269
 
270
# 2 3 1
271
send_gdb "print x < y <= z\n"
272
gdb_expect {
273
    -re ".*$true.*$gdb_prompt $" {
274
        pass "print value of x
275
      }
276
    -re ".*$gdb_prompt $" { fail "print value of x
277
    timeout           { fail "(timeout) print value of x
278
  }
279
 
280
 
281
# 2 3 1
282
send_gdb "print x < y >= z\n"
283
gdb_expect {
284
    -re ".*$true.*$gdb_prompt $" {
285
        pass "print value of x=z"
286
      }
287
    -re ".*$gdb_prompt $" { fail "print value of x=z" }
288
    timeout           { fail "(timeout) print value of x=z" }
289
  }
290
 
291
 
292
gdb_test "set variable z=0" "" " set variable z"
293
 
294
 
295
# 2 3 0
296
send_gdb "print x < y > z\n"
297
gdb_expect {
298
    -re ".*$true.*$gdb_prompt $" {
299
        pass "print value of xz"
300
      }
301
    -re ".*$gdb_prompt $" { fail "print value of xz" }
302
    timeout           { fail "(timeout) print value of xz" }
303
  }
304
 
305
 
306
gdb_test "set variable x=1" "" " set variable x"
307
 
308
# 1 3 0
309
send_gdb "print x > y >= z\n"
310
gdb_expect {
311
    -re ".*$true.*$gdb_prompt $" {
312
        pass "print value of x>y>=z"
313
      }
314
    -re ".*$gdb_prompt $" { fail "print value of x>y>=z" }
315
    timeout           { fail "(timeout) print value of x>y>=z" }
316
  }
317
 
318
 
319
gdb_test "set variable z=2" "" " set variable z"
320
 
321
# 1 3 2
322
send_gdb "print x > y == z\n"
323
gdb_expect {
324
    -re ".*$false.*$gdb_prompt $" {
325
        pass "print value of x>y==z"
326
      }
327
    -re ".*$gdb_prompt $" { fail "print value of x>y==z" }
328
    timeout           { fail "(timeout) print value of x>y==z" }
329
  }
330
 
331
 
332
gdb_test "set variable x=2" "" " set variable x"
333
gdb_test "set variable z=0" "" " set variable z"
334
 
335
# 2 3 0
336
send_gdb "print x > y != z\n"
337
gdb_expect {
338
    -re ".*$false.*$gdb_prompt $" {
339
        pass "print value of x>y!=z"
340
      }
341
    -re ".*$gdb_prompt $" { fail "print value of x>y!=z" }
342
    timeout           { fail "(timeout) print value of x>y!=z" }
343
  }
344
 
345
 
346
gdb_test "set variable x=4" "" "set x to 4"
347
 
348
# 4 3 0
349
send_gdb "print x > y <= z\n"
350
gdb_expect {
351
    -re ".*$false.*$gdb_prompt $" {
352
        pass "print value of x>y<=z"
353
      }
354
    -re ".*$gdb_prompt $" { fail "print value of x>y<=z" }
355
    timeout           { fail "(timeout) print value of x>y<=z" }
356
  }
357
 
358
# 4 3 0
359
send_gdb "print x >= y == z\n"
360
gdb_expect {
361
    -re ".*$false\r\n$gdb_prompt $" {
362
        pass "print value of x>=y==z"
363
      }
364
    -re ".*$gdb_prompt $" { fail "print value of x>=y==z" }
365
    timeout           { fail "(timeout) print value of x>=y==z" }
366
  }
367
 
368
 
369
gdb_test "set variable x=2" "" " set variable x"
370
 
371
# 2 3 0
372
send_gdb "print x >= y != z\n"
373
gdb_expect {
374
    -re ".*$false\r\n$gdb_prompt $" {
375
        pass "print value of x>=y!=z"
376
      }
377
    -re ".*$gdb_prompt $" { fail "print value of x>=y!=z" }
378
    timeout           { fail "(timeout) print value of x>=y!=z" }
379
  }
380
 
381
 
382
gdb_test "set variable x=0" "" " set variable x"
383
gdb_test "set variable z=4" "" " set variable z"
384
 
385
# 0 3 4
386
send_gdb "print x >= y <= z\n"
387
gdb_expect {
388
    -re ".*$true\r\n$gdb_prompt $" {
389
        pass "print value of x>=y<=z"
390
      }
391
    -re ".*$gdb_prompt $" { fail "print value of x>=y<=z" }
392
    timeout           { fail "(timeout) print value of x>=y<=z" }
393
  }
394
 
395
# 0 3 4
396
send_gdb "print x <= y == z\n"
397
gdb_expect {
398
    -re ".*$false\r\n$gdb_prompt $" {
399
        pass "print value of x<=y==z"
400
      }
401
    -re ".*$gdb_prompt $" { fail "print value of x<=y==z" }
402
    timeout           { fail "(timeout) print value of x<=y==z" }
403
  }
404
 
405
gdb_test "set variable x=2" "" " set variable x"
406
 
407
# 2 3 4
408
send_gdb "print x <= y != z\n"
409
gdb_expect {
410
    -re ".*$true\r\n$gdb_prompt $" {
411
        pass "print value of x<=y!=z"
412
      }
413
    -re ".*$gdb_prompt $" { fail "print value of x<=y!=z" }
414
    timeout           { fail "(timeout) print value of x<=y!=z" }
415
  }
416
 
417
 
418
# 2 3 4
419
send_gdb "print x == y != z\n"
420
gdb_expect {
421
    -re ".*$true\r\n$gdb_prompt $" {
422
        pass "print value of x==y!=z"
423
      }
424
    -re ".*$gdb_prompt $" { fail "print value of x==y!=z" }
425
    timeout           { fail "(timeout) print value of x==y!=z" }
426
  }
427
 
428
 
429
 
430
# test use of parenthesis to enforce different order of evaluation
431
 
432
 
433
gdb_test "set variable z=0" "" " set variable z"
434
 
435
# 2 3 0
436
send_gdb "print x >= (y < z)\n"
437
gdb_expect {
438
    -re ".*$true\r\n$gdb_prompt $" {
439
        pass "print value of x>=(y
440
      }
441
    -re ".*$gdb_prompt $" { fail "print value of x>=(y
442
    timeout           { fail "(timeout) print value of x>=(y
443
  }
444
 
445
 
446
# 2 3 0
447
send_gdb "print x >= (y != z)\n"
448
gdb_expect {
449
    -re ".*$true\r\n$gdb_prompt $" {
450
        pass "print value of x>=(y!=z)"
451
      }
452
    -re ".*$gdb_prompt $" { fail "print value of x>=(y*!=z)" }
453
    timeout           { fail "(timeout) print value of x>=(y!=z)" }
454
  }
455
 
456
# 2 3 0
457
send_gdb "print x == (y == z)\n"
458
gdb_expect {
459
    -re ".*$false\r\n$gdb_prompt $" {
460
        pass "print value of x==(y==z)"
461
      }
462
    -re ".*$gdb_prompt $" { fail "print value of x==(y==z)" }
463
    timeout           { fail "(timeout) print value of x==(y==z)" }
464
  }
465
 
466
 
467
gdb_test "set variable x=1" "" " set variable x"
468
gdb_test "set variable z=4" "" " set variable z"
469
 
470
# 1 3 4
471
send_gdb "print (x == y) < z\n"
472
gdb_expect {
473
    -re ".*$true\r\n$gdb_prompt $" {
474
        pass "print value of (x==y)
475
      }
476
    -re ".*$gdb_prompt $" { fail "print value of (x==y)
477
    timeout           { fail "(timeout) print value of (x==y)
478
  }
479
 
480
 
481
 
482
 
483
 
484
 

powered by: WebSVN 2.1.0

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