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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.chill/] [builtins.exp] - Blame information for rev 1774

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

Line No. Rev Author Line
1 106 markom
# Copyright (C) 1995, 1997 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 tests various Chill values, expressions, and types.
21
 
22
if $tracelevel then {
23
        strace $tracelevel
24
}
25
 
26
if [skip_chill_tests] then { continue }
27
 
28
set testfile "builtins"
29
set srcfile ${srcdir}/$subdir/${testfile}.ch
30
set binfile ${objdir}/${subdir}/${testfile}.exe
31
if  { [compile "${srcfile} -g -w -o ${binfile} ${CHILL_RT0} ${CHILL_LIB}"] != "" } {
32
    perror "Couldn't compile ${srcfile}"
33
    return -1
34
}
35
 
36
# Set the current language to chill.  This counts as a test.  If it
37
# fails, then we skip the other tests.
38
 
39
proc set_lang_chill {} {
40
    global gdb_prompt
41
    global binfile objdir subdir
42
 
43
    verbose "loading file '$binfile'"
44
    gdb_load $binfile
45
    send_gdb "set language chill\n"
46
    gdb_expect {
47
        -re ".*$gdb_prompt $" {}
48
        timeout { fail "set language chill (timeout)" ; return 0 }
49
    }
50
 
51
    send_gdb "show language\n"
52
    gdb_expect {
53
        -re ".* source language is \"chill\".*$gdb_prompt $" {
54
            pass "set language to \"chill\""
55
            send_gdb "break xx_\n"
56
            gdb_expect {
57
                -re ".*$gdb_prompt $" {
58
                    send_gdb "run\n"
59
                    gdb_expect -re ".*$gdb_prompt $" {}
60
                    return 1
61
                }
62
                timeout {
63
                    fail "can't set breakpoint (timeout)"
64
                    return 0
65
                }
66
            }
67
        }
68
        -re ".*$gdb_prompt $" {
69
            fail "setting language to \"chill\""
70
            return 0
71
        }
72
        timeout {
73
            fail "can't show language (timeout)"
74
            return 0
75
        }
76
    }
77
}
78
 
79
# Testing printing of a specific value.  Increment passcount for
80
# success or issue fail message for failure.  In both cases, return
81
# a 1 to indicate that more tests can proceed.  However a timeout
82
# is a serious error, generates a special fail message, and causes
83
# a 0 to be returned to indicate that more tests are likely to fail
84
# as well.
85
#
86
# Args are:
87
#
88
#       First one is string to send_gdb to gdb
89
#       Second one is string to match gdb result to
90
#       Third one is an optional message to be printed
91
 
92
proc test_print_accept { args } {
93
    global gdb_prompt
94
    global passcount
95
    global verbose
96
 
97
    if [llength $args]==3 then {
98
        set message [lindex $args 2]
99
    } else {
100
        set message [lindex $args 0]
101
    }
102
    set sendthis [lindex $args 0]
103
    set expectthis [lindex $args 1]
104
    set result [gdb_test $sendthis ".* = ${expectthis}" $message]
105
    if $result==0 {incr passcount}
106
    return $result
107
}
108
 
109
proc test_lower {} {
110
    global passcount
111
 
112
    verbose "testing builtin LOWER"
113
    set passcount 0
114
 
115
    # discrete mode names
116
    test_print_accept "print lower(bool)" "FALSE"
117
    test_print_accept "print lower(char)" {'\^[(]0[)]'}
118
    test_print_accept "print lower(byte)" "-128"
119
    test_print_accept "print lower(ubyte)" "0"
120
    if [istarget "alpha-*-*"] then {
121
        test_print_accept "print lower(int)" "-2147483648"
122
    } else {
123
        test_print_accept "print lower(int)" "-32768"
124
    }
125
    test_print_accept "print lower(uint)" "0"
126
    setup_xfail "alpha-*-*"
127
    test_print_accept "print lower(long)" "-2147483648"
128
    test_print_accept "print lower(ulong)" "0"
129
    test_print_accept "print lower(m_set)" "e1"
130
    test_print_accept "print lower(m_set_range)" "e2"
131
    test_print_accept "print lower(m_numbered_set)" "n2"
132
    test_print_accept "print lower(m_char_range)" "'A'"
133
    test_print_accept "print lower(m_bool_range)" "FALSE"
134
    test_print_accept "print lower(m_long_range)" "255"
135
    test_print_accept "print lower(m_range)" "12"
136
 
137
    # discrete locations
138
    test_print_accept "print lower(v_bool)" "FALSE"
139
    test_print_accept "print lower(v_char)" {'\^[(]0[)]'}
140
    test_print_accept "print lower(v_byte)" "-128"
141
    test_print_accept "print lower(v_ubyte)" "0"
142
    if [istarget "alpha-*-*"] then {
143
        test_print_accept "print lower(v_int)" "-2147483648"
144
    } else {
145
        test_print_accept "print lower(v_int)" "-32768"
146
    }
147
    test_print_accept "print lower(v_uint)" "0"
148
    setup_xfail "alpha-*-*"
149
    test_print_accept "print lower(v_long)" "-2147483648"
150
    test_print_accept "print lower(v_ulong)" "0"
151
    test_print_accept "print lower(v_set)" "e1"
152
    test_print_accept "print lower(v_set_range)" "e2"
153
    test_print_accept "print lower(v_numbered_set)" "n2"
154
    test_print_accept "print lower(v_char_range)" "'A'"
155
    test_print_accept "print lower(v_bool_range)" "FALSE"
156
    test_print_accept "print lower(v_long_range)" "255"
157
    test_print_accept "print lower(v_range)" "12"
158
 
159
    # string mode names
160
    test_print_accept "print lower(m_chars)" "0"
161
    test_print_accept "print lower(m_chars_v)" "0"
162
    test_print_accept "print lower(m_bits)" "0"
163
 
164
    # string locations
165
    test_print_accept "print lower(v_chars)" "0"
166
    test_print_accept "print lower(v_chars_v)" "0"
167
    test_print_accept "print lower(v_bits)" "0"
168
 
169
    # string expressions
170
    test_print_accept "print lower(\"abcd\")" "0"
171
    test_print_accept "print lower(B'010101')" "0"
172
 
173
    # array mode name
174
    test_print_accept "print lower(m_arr)" "1";
175
    test_print_accept "print lower(m_char_arr)" {'\^[(]0[)]'}
176
    test_print_accept "print lower(m_bool_arr)" "FALSE"
177
    if [istarget "alpha-*-*"] then {
178
        test_print_accept "print lower(m_int_arr)" "-2147483648"
179
    } else {
180
        test_print_accept "print lower(m_int_arr)" "-32768"
181
    }
182
    test_print_accept "print lower(m_set_arr)" "e1"
183
    test_print_accept "print lower(m_set_range_arr)" "e2"
184
    test_print_accept "print lower(m_numbered_set_arr)" "n2"
185
    test_print_accept "print lower(m_char_range_arr)" "'A'"
186
    test_print_accept "print lower(m_bool_range_arr)" "FALSE"
187
    test_print_accept "print lower(m_long_range_arr)" "255"
188
    test_print_accept "print lower(m_range_arr)" "12"
189
 
190
    # array locations
191
    test_print_accept "print lower(v_arr)" "1";
192
    test_print_accept "print lower(v_char_arr)" {'\^[(]0[)]'}
193
    test_print_accept "print lower(v_bool_arr)" "FALSE"
194
    if [istarget "alpha-*-*"] then {
195
        test_print_accept "print lower(v_int_arr)" "-2147483648"
196
    } else {
197
        test_print_accept "print lower(v_int_arr)" "-32768"
198
    }
199
    test_print_accept "print lower(v_set_arr)" "e1"
200
    test_print_accept "print lower(v_set_range_arr)" "e2"
201
    test_print_accept "print lower(v_numbered_set_arr)" "n2"
202
    test_print_accept "print lower(v_char_range_arr)" "'A'"
203
    test_print_accept "print lower(v_bool_range_arr)" "FALSE"
204
    test_print_accept "print lower(v_long_range_arr)" "255"
205
    test_print_accept "print lower(v_range_arr)" "12"
206
}
207
 
208
proc test_upper {} {
209
    global passcount
210
 
211
    verbose "testing builtin UPPER"
212
    set passcount 0
213
 
214
    # discrete mode names
215
    test_print_accept "print upper(bool)" "TRUE"
216
    test_print_accept "print upper(char)" {'\^[(]255[)]'}
217
    test_print_accept "print upper(byte)" "127"
218
    test_print_accept "print upper(ubyte)" "255"
219
    if [istarget "alpha-*-*"] then {
220
        test_print_accept "print upper(int)" "2147483647"
221
        test_print_accept "print upper(uint)" "4294967295"
222
        setup_xfail "alpha-*-*"
223
        test_print_accept "print upper(long)" "4294967295"
224
        test_print_accept "print upper(ulong)" "18446744073709551615"
225
    } else {
226
        test_print_accept "print upper(int)" "32767"
227
        test_print_accept "print upper(uint)" "65535"
228
        test_print_accept "print upper(long)" "2147483647"
229
        test_print_accept "print upper(ulong)" "4294967295"
230
    }
231
    test_print_accept "print upper(m_set)" "e6"
232
    test_print_accept "print upper(m_set_range)" "e5"
233
    test_print_accept "print upper(m_numbered_set)" "n5"
234
    test_print_accept "print upper(m_char_range)" "'Z'"
235
    test_print_accept "print upper(m_bool_range)" "FALSE"
236
    test_print_accept "print upper(m_long_range)" "3211"
237
    test_print_accept "print upper(m_range)" "28"
238
 
239
    # discrete locations
240
    test_print_accept "print upper(v_bool)" "TRUE"
241
    test_print_accept "print upper(v_char)" {'\^[(]255[)]'}
242
    test_print_accept "print upper(v_byte)" "127"
243
    test_print_accept "print upper(v_ubyte)" "255"
244
    if [istarget "alpha-*-*"] then {
245
        test_print_accept "print upper(v_int)" "2147483647"
246
        test_print_accept "print upper(v_uint)" "4294967295"
247
        setup_xfail "alpha-*-*"
248
        test_print_accept "print upper(v_long)" "4294967295"
249
        test_print_accept "print upper(v_ulong)" "18446744073709551615"
250
    } else {
251
        test_print_accept "print upper(v_int)" "32767"
252
        test_print_accept "print upper(v_uint)" "65535"
253
        test_print_accept "print upper(v_long)" "2147483647"
254
        test_print_accept "print upper(v_ulong)" "4294967295"
255
    }
256
    test_print_accept "print upper(v_set)" "e6"
257
    test_print_accept "print upper(v_set_range)" "e5"
258
    test_print_accept "print upper(v_numbered_set)" "n5"
259
    test_print_accept "print upper(v_char_range)" "'Z'"
260
    test_print_accept "print upper(v_bool_range)" "FALSE"
261
    test_print_accept "print upper(v_long_range)" "3211"
262
    test_print_accept "print upper(v_range)" "28"
263
 
264
    # string mode names
265
    test_print_accept "print upper(m_chars)" "19"
266
    test_print_accept "print upper(m_chars_v)" "19"
267
    test_print_accept "print upper(m_bits)" "9"
268
 
269
    # string locations
270
    test_print_accept "print upper(v_chars)" "19"
271
    test_print_accept "print upper(v_chars_v)" "19"
272
    test_print_accept "print upper(v_bits)" "9"
273
 
274
    # string expressions
275
    test_print_accept "print upper(\"abcd\")" "3"
276
    test_print_accept "print upper(B'010101')" "5"
277
 
278
    # array mode name
279
    test_print_accept "print upper(m_arr)" "10";
280
    test_print_accept "print upper(m_char_arr)" {'\^[(]255[)]'}
281
    test_print_accept "print upper(m_bool_arr)" "TRUE"
282
    if [istarget "alpha-*-*"] then {
283
        test_print_accept "print upper(m_int_arr)" "2147483647"
284
    } else {
285
        test_print_accept "print upper(m_int_arr)" "32767"
286
    }
287
    test_print_accept "print upper(m_set_arr)" "e6"
288
    test_print_accept "print upper(m_set_range_arr)" "e5"
289
    test_print_accept "print upper(m_numbered_set_arr)" "n5"
290
    test_print_accept "print upper(m_char_range_arr)" "'Z'"
291
    test_print_accept "print upper(m_bool_range_arr)" "FALSE"
292
    test_print_accept "print upper(m_long_range_arr)" "3211"
293
    test_print_accept "print upper(m_range_arr)" "28"
294
 
295
    # array locations
296
    test_print_accept "print upper(v_arr)" "10";
297
    test_print_accept "print upper(v_char_arr)" {'\^[(]255[)]'}
298
    test_print_accept "print upper(v_bool_arr)" "TRUE"
299
    if [istarget "alpha-*-*"] then {
300
        test_print_accept "print upper(v_int_arr)" "2147483647"
301
    } else {
302
        test_print_accept "print upper(v_int_arr)" "32767"
303
    }
304
    test_print_accept "print upper(v_set_arr)" "e6"
305
    test_print_accept "print upper(v_set_range_arr)" "e5"
306
    test_print_accept "print upper(v_numbered_set_arr)" "n5"
307
    test_print_accept "print upper(v_char_range_arr)" "'Z'"
308
    test_print_accept "print upper(v_bool_range_arr)" "FALSE"
309
    test_print_accept "print upper(v_long_range_arr)" "3211"
310
    test_print_accept "print upper(v_range_arr)" "28"
311
}
312
 
313
proc test_length {} {
314
    global passcount
315
 
316
    verbose "testing builtin LENGTH"
317
    set passcount 0
318
 
319
    # string locations
320
    test_print_accept "print length(v_chars)" "20"
321
    test_print_accept "print length(v_chars_v)" "7";
322
    test_print_accept "print length(v_bits)" "10";
323
 
324
    # string expressions
325
    test_print_accept "print length(\"the quick brown fox ...\")" "23"
326
    test_print_accept "print length(B'010101010101')" "12"
327
    test_print_accept "print length(\"foo \" // \"bar\")" "7"
328
 
329
    # check some failures
330
    setup_xfail "*-*-*"
331
    test_print_accept "print length(m_chars)" "typename in invalid context"
332
    setup_xfail "*-*-*"
333
    test_print_accept "print length(v_byte)" "bad argument to LENGTH builtin"
334
    setup_xfail "*-*-*"
335
    test_print_accept "print length(b'000000' // b'111111')" "12"
336
}
337
 
338
proc test_size {} {
339
    global passcount
340
 
341
    verbose "testing builtin SIZE"
342
    set passcount 0
343
 
344
    # modes
345
    test_print_accept "print size(bool)" "1"
346
    test_print_accept "print size(char)" "1"
347
    test_print_accept "print size(byte)" "1"
348
    if [istarget "alpha-*-*"] then {
349
        test_print_accept "print size(int)" "4"
350
        test_print_accept "print size(ulong)" "8"
351
        test_print_accept "print size(ptr)" "8"
352
        test_print_accept "print size(m_chars_v)" "24"
353
        test_print_accept "print size(m_struct)" "40"
354
    } else {
355
        test_print_accept "print size(int)" "2"
356
        test_print_accept "print size(ulong)" "4"
357
        test_print_accept "print size(ptr)" "4"
358
        test_print_accept "print size(m_chars_v)" "22"
359
        test_print_accept "print size(m_struct)" "36"
360
    }
361
    test_print_accept "print size(m_set)" "1"
362
    test_print_accept "print size(m_numbered_set)" "1"
363
    test_print_accept "print size(m_char_range)" "1"
364
    test_print_accept "print size(m_range_arr)" "17"
365
    test_print_accept "print size(m_chars)" "20"
366
    test_print_accept "print size(m_bits)" "2"
367
 
368
    # locations
369
    test_print_accept "print size(v_bool)" "1"
370
    test_print_accept "print size(v_char)" "1"
371
    test_print_accept "print size(v_byte)" "1"
372
    if [istarget "alpha-*-*"] then {
373
        test_print_accept "print size(v_int)" "4"
374
        test_print_accept "print size(v_ulong)" "8"
375
        test_print_accept "print size(v_ptr)" "8"
376
        test_print_accept "print size(v_chars_v)" "24"
377
        test_print_accept "print size(v_struct)" "40"
378
    } else {
379
        test_print_accept "print size(v_int)" "2"
380
        test_print_accept "print size(v_ulong)" "4"
381
        test_print_accept "print size(v_ptr)" "4"
382
        test_print_accept "print size(v_chars_v)" "22"
383
        test_print_accept "print size(v_struct)" "36"
384
    }
385
    test_print_accept "print size(v_set)" "1"
386
    test_print_accept "print size(v_numbered_set)" "1"
387
    test_print_accept "print size(v_char_range)" "1"
388
    test_print_accept "print size(v_range_arr)" "17"
389
    test_print_accept "print size(v_chars)" "20"
390
    test_print_accept "print size(v_bits)" "2"
391
}
392
 
393
proc test_num {} {
394
    global passcount
395
 
396
    verbose "testing builtin NUM"
397
    set passcount 0
398
 
399
    # constants
400
    test_print_accept "print num(false)" "0"
401
    test_print_accept "print num(true)" "1"
402
    test_print_accept "print num(10)" "10"
403
    test_print_accept "print num(33-34)" "-1"
404
    test_print_accept "print num('X')" "88"
405
    test_print_accept "print num(e5)" "4"
406
 
407
    # locations
408
    test_print_accept "print num(v_bool)" "0"
409
    test_print_accept "print num(v_char)" "88"
410
    test_print_accept "print num(v_byte)" "-30"
411
    test_print_accept "print num(v_ubyte)" "30"
412
    test_print_accept "print num(v_int)" "-333"
413
    test_print_accept "print num(v_uint)" "333"
414
    test_print_accept "print num(v_long)" "-4444"
415
    test_print_accept "print num(v_ulong)" "4444"
416
    test_print_accept "print num(v_set)" "2"
417
    test_print_accept "print num(v_set_range)" "2"
418
    test_print_accept "print num(v_numbered_set)" "35"
419
    test_print_accept "print num(v_char_range)" "71"
420
    test_print_accept "print num(v_long_range)" "1000"
421
    test_print_accept "print num(v_range)" "23"
422
}
423
 
424
# Start with a fresh gdb.
425
 
426
gdb_exit
427
gdb_start
428
gdb_reinitialize_dir $srcdir/$subdir
429
 
430
gdb_test "set print sevenbit-strings" ".*"
431
 
432
if [set_lang_chill] then {
433
    # test builtins as described in chapter 6.20.3 Z.200
434
    test_num
435
    test_size
436
    test_lower
437
    test_upper
438
    test_length
439
} else {
440
    warning "$test_name tests suppressed."
441
}

powered by: WebSVN 2.1.0

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