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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.base/] [arithmet.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 correctness of arithmetic 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
 
42
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
43
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
44
    }
45
 
46
gdb_exit
47
gdb_start
48
gdb_reinitialize_dir $srcdir/$subdir
49
gdb_load ${binfile}
50
 
51
 
52
#
53
# set it up at a breakpoint so we can play with the variable values
54
#
55
 
56
if ![runto_main] then {
57
    perror "couldn't run to breakpoint"
58
    continue
59
}
60
 
61
#
62
# test expressions with "int" types
63
#
64
 
65
gdb_test "set variable x=14" "" "set variable x=14"
66
gdb_test "set variable y=2" "" "set variable y=2"
67
gdb_test "set variable z=2" "" "set variable z=2"
68
gdb_test "set variable w=3" "" "set variable w=3"
69
 
70
send_gdb "print x\n"
71
gdb_expect {
72
    -re ".*14.*$gdb_prompt $" {
73
        pass "print value of x"
74
      }
75
    -re ".*$gdb_prompt $" { fail "print value of x" }
76
    timeout           { fail "(timeout) print value of x" }
77
  }
78
 
79
 
80
send_gdb "print y\n"
81
gdb_expect {
82
    -re ".*2.*$gdb_prompt $" {
83
        pass "print value of y"
84
      }
85
    -re ".*$gdb_prompt $" { fail "print value of y" }
86
    timeout           { fail "(timeout) print value of y" }
87
  }
88
 
89
send_gdb "print z\n"
90
gdb_expect {
91
    -re ".*2.*$gdb_prompt $" {
92
        pass "print value of z"
93
      }
94
    -re ".*$gdb_prompt $" { fail "print value of z" }
95
    timeout           { fail "(timeout) print value of z" }
96
  }
97
 
98
send_gdb "print w\n"
99
gdb_expect {
100
    -re ".*3.*$gdb_prompt $" {
101
        pass "print value of w"
102
      }
103
    -re ".*$gdb_prompt $" { fail "print value of w" }
104
    timeout           { fail "(timeout) print value of w" }
105
  }
106
 
107
 
108
 
109
send_gdb "print x+y\n"
110
gdb_expect {
111
    -re ".*16.*$gdb_prompt $" {
112
        pass "print value of x+y"
113
      }
114
    -re ".*$gdb_prompt $" { fail "print value of x+y" }
115
    timeout           { fail "(timeout) print value of x+y" }
116
  }
117
 
118
send_gdb "print x-y\n"
119
gdb_expect {
120
    -re ".*12.*$gdb_prompt $" {
121
        pass "print value of x-y"
122
      }
123
    -re ".*$gdb_prompt $" { fail "print value of x-y" }
124
    timeout           { fail "(timeout) print value of x-y" }
125
  }
126
 
127
send_gdb "print x*y\n"
128
gdb_expect {
129
    -re ".*28.*$gdb_prompt $" {
130
        pass "print value of x*y"
131
      }
132
    -re ".*$gdb_prompt $" { fail "print value of x*y" }
133
    timeout           { fail "(timeout) print value of x*y" }
134
  }
135
 
136
send_gdb "print x/y\n"
137
gdb_expect {
138
    -re ".*7.*$gdb_prompt $" {
139
        pass "print value of x/y"
140
      }
141
    -re ".*$gdb_prompt $" { fail "print value of x/y" }
142
    timeout           { fail "(timeout) print value of x/y" }
143
  }
144
 
145
send_gdb "print x%y\n"
146
gdb_expect {
147
    -re ".*0.*$gdb_prompt $" {
148
        pass "print value of x%y"
149
      }
150
    -re ".*$gdb_prompt $" { fail "print value of x%y" }
151
    timeout           { fail "(timeout) print value of x%y" }
152
  }
153
 
154
 
155
 
156
# Test associativity of +, -, *, % ,/
157
 
158
 
159
send_gdb "print x+y+z\n"
160
gdb_expect {
161
    -re ".*18.*$gdb_prompt $" {
162
        pass "print value of x+y"
163
      }
164
    -re ".*$gdb_prompt $" { fail "print value of x+y" }
165
    timeout           { fail "(timeout) print value of x+y" }
166
  }
167
 
168
send_gdb "print x-y-z\n"
169
gdb_expect {
170
    -re ".*10.*$gdb_prompt $" {
171
        pass "print value of x-y"
172
      }
173
    -re ".*$gdb_prompt $" { fail "print value of x-y" }
174
    timeout           { fail "(timeout) print value of x-y" }
175
  }
176
 
177
send_gdb "print x*y*z\n"
178
gdb_expect {
179
    -re ".*56.*$gdb_prompt $" {
180
        pass "print value of x*y"
181
      }
182
    -re 8".*$gdb_prompt $" { fail "print value of x*y" }
183
    timeout           { fail "(timeout) print value of x*y" }
184
  }
185
 
186
send_gdb "print x/y/z\n"
187
gdb_expect {
188
    -re ".*3.*$gdb_prompt $" {
189
        pass "print value of x/y"
190
      }
191
    -re ".*$gdb_prompt $" { fail "print value of x/y" }
192
    timeout           { fail "(timeout) print value of x/y" }
193
  }
194
 
195
send_gdb "print x%y%z\n"
196
gdb_expect {
197
    -re ".*0.*$gdb_prompt $" {
198
        pass "print value of x%y"
199
      }
200
    -re ".*$gdb_prompt $" { fail "print value of x%y" }
201
    timeout           { fail "(timeout) print value of x%y" }
202
  }
203
 
204
 
205
# test precedence rules on pairs of arithmetic operators
206
 
207
gdb_test "set variable x=10" "" "set variable x"
208
gdb_test "set variable y=4" ""  "set variable y"
209
gdb_test "set variable z=2" ""  "set variable z"
210
 
211
 
212
 
213
# x  y z
214
# 10 4 2
215
send_gdb "print x+y-z\n"
216
gdb_expect {
217
    -re ".*12.*$gdb_prompt $" {
218
        pass "print value of x+y-z"
219
      }
220
    -re ".*$gdb_prompt $" { fail "print value of x+y-z" }
221
    timeout           { fail "(timeout) print value of x+y-z" }
222
  }
223
 
224
# 10 4 2
225
send_gdb "print x+y*z\n"
226
gdb_expect {
227
    -re ".*18.*$gdb_prompt $" {
228
        pass "print value of x+y*z"
229
      }
230
    -re ".*$gdb_prompt $" { fail "print value of x+y*z" }
231
    timeout           { fail "(timeout) print value of x+y*z" }
232
  }
233
 
234
 
235
gdb_test "set variable z=3" "" "set variable z"
236
 
237
 
238
# 10 4 3
239
send_gdb "print x+y%z\n"
240
gdb_expect {
241
    -re ".*11.*$gdb_prompt $" {
242
        pass "print value of x+y%z"
243
      }
244
    -re ".*$gdb_prompt $" { fail "print value of x+y%z" }
245
    timeout           { fail "(timeout) print value of x+y%z" }
246
  }
247
 
248
 
249
# 10 4 3
250
send_gdb "print x+y/z\n"
251
gdb_expect {
252
    -re ".*11.*$gdb_prompt $" {
253
        pass "print value of x+y/z"
254
      }
255
    -re ".*$gdb_prompt $" { fail "print value of x+y/z" }
256
    timeout           { fail "(timeout) print value of x+y/z" }
257
  }
258
 
259
gdb_test "set variable z=2" "" " set variable z"
260
 
261
 
262
# 10 4 2
263
send_gdb "print x-y*z\n"
264
gdb_expect {
265
    -re ".*2.*$gdb_prompt $" {
266
        pass "print value of x-y*z"
267
      }
268
    -re ".*$gdb_prompt $" { fail "print value of x-y*z" }
269
    timeout           { fail "(timeout) print value of x-y*z" }
270
  }
271
 
272
# 10 4 2
273
send_gdb "print x-y%z\n"
274
gdb_expect {
275
    -re ".*10.*$gdb_prompt $" {
276
        pass "print value of x-y%z"
277
      }
278
    -re ".*$gdb_prompt $" { fail "print value of x-y%z" }
279
    timeout           { fail "(timeout) print value of x-y%z" }
280
  }
281
 
282
 
283
# 10 4 2
284
send_gdb "print x-y/z\n"
285
gdb_expect {
286
    -re ".*8.*$gdb_prompt $" {
287
        pass "print value of x-y/z"
288
      }
289
    -re ".*$gdb_prompt $" { fail "print value of x-y/z" }
290
    timeout           { fail "(timeout) print value of x-y/z" }
291
  }
292
 
293
# 10 4 2
294
send_gdb "print x*y/z\n"
295
gdb_expect {
296
    -re ".*20.*$gdb_prompt $" {
297
        pass "print value of x*y/z"
298
      }
299
    -re ".*$gdb_prompt $" { fail "print value of x*y/z" }
300
    timeout           { fail "(timeout) print value of x*y/z" }
301
  }
302
 
303
gdb_test "set variable z=3" "" "set z to 3"
304
 
305
# 10 4 3
306
send_gdb "print x*y%z\n"
307
gdb_expect {
308
    -re ".*1.*$gdb_prompt $" {
309
        pass "print value of x*y%z"
310
      }
311
    -re ".*$gdb_prompt $" { fail "print value of x*y%z" }
312
    timeout           { fail "(timeout) print value of x*y%z" }
313
  }
314
 
315
# 10 4 3
316
send_gdb "print x/y%z\n"
317
gdb_expect {
318
    -re ".*2\r\n$gdb_prompt $" {
319
        pass "print value of x/y%z"
320
      }
321
    -re ".*$gdb_prompt $" { fail "print value of x/y%z" }
322
    timeout           { fail "(timeout) print value of x/y%z" }
323
  }
324
 
325
 
326
 
327
# test use of parenthesis to enforce different order of evaluation
328
 
329
# 10 4 3
330
send_gdb "print x-(y+z)\n"
331
gdb_expect {
332
    -re ".*3\r\n$gdb_prompt $" {
333
        pass "print value of x-(y+z)"
334
      }
335
    -re ".*$gdb_prompt $" { fail "print value of x-(y+z)" }
336
    timeout           { fail "(timeout) print value of x-(y+z)" }
337
  }
338
 
339
 
340
# 10 4 3
341
send_gdb "print x/(y*z)\n"
342
gdb_expect {
343
    -re ".*0\r\n$gdb_prompt $" {
344
        pass "print value of x/(y*z)"
345
      }
346
    -re ".*$gdb_prompt $" { fail "print value of x/(y*z)" }
347
    timeout           { fail "(timeout) print value of x/(y*z)" }
348
  }
349
 
350
# 10 4 3
351
send_gdb "print x-(y/z)\n"
352
gdb_expect {
353
    -re ".*9\r\n$gdb_prompt $" {
354
        pass "print value of x-(y/z)"
355
      }
356
    -re ".*$gdb_prompt $" { fail "print value of x-(y/z)" }
357
    timeout           { fail "(timeout) print value of x-(y/z)" }
358
  }
359
 
360
 
361
# 10 4 3
362
send_gdb "print (x+y)*z\n"
363
gdb_expect {
364
    -re ".*42\r\n$gdb_prompt $" {
365
        pass "print value of (x+y)*z"
366
      }
367
    -re ".*$gdb_prompt $" { fail "print value of (x+y)*z" }
368
    timeout           { fail "(timeout) print value of (x+y)*z" }
369
  }
370
 
371
 
372
 
373
 
374
 
375
 

powered by: WebSVN 2.1.0

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