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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [relational.exp] - Blame information for rev 231

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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