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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [radix.exp] - Blame information for rev 816

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

Line No. Rev Author Line
1 227 jeremybenn
# This testcase is part of GDB, the GNU debugger.
2
# Copyright 1993, 1997, 2004, 2007, 2008, 2009, 2010
3
# Free Software Foundation, Inc.
4
 
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program.  If not, see .
17
 
18
# This file was written by Fred Fish. (fnf@cygnus.com)
19
# And rewritten by Michael Chastain (mec.gnu@mindspring.com)
20
 
21
if $tracelevel then {
22
        strace $tracelevel
23
}
24
 
25
set prms_id 0
26
set bug_id 0
27
 
28
# Start with a fresh gdb.
29
 
30
gdb_exit
31
gdb_start
32
 
33
# Test input radices.
34
 
35
proc test_one_input { iradix input output } {
36
    gdb_test "print $input" "$output" \
37
        "print $input; expect $output; input radix $iradix"
38
}
39
 
40
proc test_input_radix { iradix iradixhex iradixoctal } {
41
    # set input-radix = $iradix, output-radix = ten
42
    gdb_test "set radix" \
43
        "Input and output radices now set to decimal 10, hex a, octal 12." \
44
        "initialize radix, input radix $iradix"
45
    gdb_test "set input-radix $iradix" \
46
        "Input radix now set to decimal $iradix, hex $iradixhex, octal $iradixoctal."
47
    if { $iradix == 10 } then {
48
        gdb_test "show radix" \
49
            "Input and output radices set to decimal 10, hex a, octal 12." \
50
            "show radix, input radix $iradix"
51
    } else {
52
        gdb_test "show radix" \
53
            "Input radix set to decimal $iradix, hex $iradixhex, octal $iradixoctal.\r\nOutput radix set to decimal 10, hex a, octal 12." \
54
            "show radix, input radix $iradix"
55
    }
56
 
57
    # test constants with specific bases that do not use $iradix
58
    test_one_input $iradix  "010"        "8"
59
    test_one_input $iradix  "20."        "20"
60
    test_one_input $iradix  "(int) 20."  "20"
61
    test_one_input $iradix  "0xf"        "15"
62
 
63
    # test simple one-digit constants
64
    test_one_input $iradix  "0"          "0"
65
    test_one_input $iradix  "1"          "1"
66
    test_one_input $iradix  "-1"          "-1"
67
 
68
    # test simple two-digit constants
69
    test_one_input $iradix "10"          [expr $iradix]
70
    test_one_input $iradix "11"          [expr $iradix + 1]
71
    test_one_input $iradix "-10"         [expr 0 - $iradix]
72
    test_one_input $iradix "-11"         [expr 0 - $iradix - 1]
73
 
74
    # test simple three-digit constants
75
    test_one_input $iradix "100"         [expr $iradix * $iradix]
76
    test_one_input $iradix "101"         [expr $iradix * $iradix + 1]
77
    test_one_input $iradix "-100"        [expr 0 - $iradix * $iradix]
78
    test_one_input $iradix "-101"        [expr 0 - $iradix * $iradix - 1]
79
 
80
    # test a five-digit constant
81
    test_one_input $iradix  "10101"      \
82
        [expr $iradix * $iradix * $iradix * $iradix + $iradix * $iradix + 1]
83
}
84
 
85
test_input_radix 2 "2" "2"
86
    test_one_input 2  "4"   "Invalid number \"4\"\\."
87
    test_one_input 2  "-2"  "Invalid number \"2\"\\."
88
 
89
test_input_radix 3 "3" "3"
90
    test_one_input 3  "2"   "2"
91
    test_one_input 3  "20"  "6"
92
    test_one_input 3  "3"   "Invalid number \"3\"\\."
93
    test_one_input 2  "30"  "Invalid number \"30\"\\."
94
 
95
test_input_radix 8 "8" "10"
96
    test_one_input 8  "20"  "16"
97
    test_one_input 8  "-20" "-16"
98
    test_one_input 8  "8"   "Invalid number \"8\"."
99
    test_one_input 8  "-9"  "Invalid number \"9\"."
100
 
101
test_input_radix 10 "a" "12"
102
    test_one_input 10 "-12"  "-12"
103
 
104
test_input_radix 16 "10" "20"
105
 
106
# Test output radices.
107
 
108
proc test_one_output { oradix input output } {
109
    gdb_test "print $input" "$output" \
110
        "print $input; expect $output; output radix $oradix"
111
}
112
 
113
proc test_output_radix { oradix oradixhex oradixoctal } {
114
    # set input-radix = ten, output-radix = $oradix
115
    gdb_test "set radix" \
116
        "Input and output radices now set to decimal 10, hex a, octal 12." \
117
        "initialize radix, output radix $oradix"
118
    gdb_test "set output-radix $oradix" \
119
        "Output radix now set to decimal $oradix, hex $oradixhex, octal $oradixoctal."
120
    if { $oradix == 10 } then {
121
        gdb_test "show radix" \
122
            "Input and output radices set to decimal 10, hex a, octal 12." \
123
            "show radix, output radix $oradix"
124
    } else {
125
        gdb_test "show radix" \
126
            "Input radix set to decimal 10, hex a, octal 12.\r\nOutput radix set to decimal $oradix, hex $oradixhex, octal $oradixoctal." \
127
            "show radix, output radix $oradix"
128
    }
129
 
130
    # no standard tests for output radix
131
}
132
 
133
test_output_radix 8 "8" "10"
134
    test_one_output 8  "010"        "010"
135
    test_one_output 8  "0xf"        "17"
136
    test_one_output 8  "10"         "12"
137
    test_one_output 8  "100"        "144"
138
    setup_kfail *-*-* "gdb/1715"
139
    test_one_output 8  "20."        "24"
140
    test_one_output 8  "(int) 20."  "24"
141
 
142
test_output_radix 10 "a" "12"
143
    test_one_output 10 "010"        "8"
144
    test_one_output 10 "0xf"        "15"
145
    test_one_output 10 "10"         "10"
146
    test_one_output 10 "100"        "100"
147
    test_one_output 10 "20."        "20"
148
    test_one_output 10 "(int) 20."  "20"
149
 
150
test_output_radix 16 "10" "20"
151
    test_one_output 16 "010"        "8"
152
    test_one_output 16 "0xf"        "f"
153
    test_one_output 16 "10"         "a"
154
    test_one_output 16 "100"        "64"
155
    setup_kfail *-*-* "gdb/1715"
156
    test_one_output 16 "20."        "14"
157
    test_one_output 16 "(int) 20."  "14"
158
 
159
# Test rejecting invalid input radices and unsupported output radices
160
# really rejects the radices, instead of just claiming so (PR 7536).
161
 
162
gdb_test "set radix" \
163
    "Input and output radices now set to decimal 10, hex a, octal 12\." \
164
    "Reset radices"
165
 
166
gdb_test "set input-radix 0" \
167
    "Nonsense input radix ``decimal 0''; input radix unchanged\\." \
168
    "Reject input-radix 0"
169
gdb_test "show input-radix" \
170
    "Default input radix for entering numbers is 10\\." \
171
    "Input radix unchanged after rejecting 0"
172
 
173
gdb_test "set input-radix 1" \
174
    "Nonsense input radix ``decimal 1''; input radix unchanged\\." \
175
    "Reject input-radix 1"
176
gdb_test "show input-radix" \
177
    "Default input radix for entering numbers is 10\\." \
178
    "Input radix unchanged after rejecting 1"
179
 
180
gdb_test "set output-radix 0" \
181
    "Unsupported output radix ``decimal 0''; output radix unchanged\\." \
182
    "Reject output-radix 0"
183
gdb_test "show output-radix" \
184
    "Default output radix for printing of values is 10\\." \
185
    "Output radix unchanged after rejecting 0"
186
gdb_test "set output-radix 1" \
187
    "Unsupported output radix ``decimal 1''; output radix unchanged\\." \
188
    "Reject output-radix 1"
189
gdb_test "show output-radix" \
190
    "Default output radix for printing of values is 10\\." \
191
    "Output radix unchanged after rejecting 1"
192
 
193
gdb_test "set radix 7" \
194
    "Unsupported output radix ``decimal 7''; output radix unchanged\\." \
195
    "set radix 7 rejected"
196
gdb_test "show output-radix" \
197
    "Default output radix for printing of values is 10\\." \
198
    "Output radix unchanged after rejection through set radix command"

powered by: WebSVN 2.1.0

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