Commit | Line | Data |
---|---|---|
4d9eda44 | 1 | # Copyright 1998, 1999, 2001, 2003 Free Software Foundation, Inc. |
a0b3c4fd JM |
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 | ||
21 | # This file is part of the gdb testsuite | |
22 | # file written by Elena Zannoni (ezannoni@cygnus.com) | |
23 | # | |
24 | # source files cttiadd.cc, cttiadd1.cc, cttiadd2.cc, cttiadd3.cc | |
25 | # | |
26 | ||
27 | ||
28 | if $tracelevel then { | |
29 | strace $tracelevel | |
30 | } | |
31 | ||
fc33412a | 32 | if { [skip_cplus_tests] } { continue } |
55b13a65 DB |
33 | |
34 | # Check to see if we have an executable to test. If not, then either we | |
35 | # haven't tried to compile one, or the compilation failed for some reason. | |
36 | # In either case, just notify the user and skip the tests in this file. | |
a0b3c4fd JM |
37 | |
38 | set testfile "cttiadd" | |
39 | set srcfile ${testfile}.cc | |
40 | set srcfile1 ${testfile}1.cc | |
41 | set srcfile2 ${testfile}2.cc | |
42 | set srcfile3 ${testfile}3.cc | |
43 | set binfile ${objdir}/${subdir}/${testfile} | |
44 | ||
45 | if [get_compiler_info ${binfile} "c++"] { | |
46 | return -1; | |
47 | } | |
48 | ||
4d9eda44 | 49 | if { [test_compiler_info gcc-*] } then { continue } |
a0b3c4fd | 50 | |
55b13a65 DB |
51 | #if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1} ${srcdir}/${subdir}/${srcfile2} ${srcdir}/${subdir}/${srcfile3}" "${binfile}" executable {debug c++}] != "" } { |
52 | # gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
53 | #} | |
a0b3c4fd | 54 | |
55b13a65 | 55 | set cmdline "$CXX_FOR_TARGET ${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1} ${srcdir}/${subdir}/${srcfile2} ${srcdir}/${subdir}/${srcfile3} -g -o ${binfile}" |
a0b3c4fd | 56 | |
55b13a65 | 57 | remote_exec build $cmdline |
a0b3c4fd JM |
58 | |
59 | gdb_exit | |
60 | gdb_start | |
61 | gdb_reinitialize_dir $srcdir/$subdir | |
62 | gdb_load ${binfile} | |
63 | ||
64 | ||
65 | ||
66 | if ![runto_main] then { | |
67 | perror "couldn't run to breakpoint" | |
68 | continue | |
69 | } | |
70 | ||
71 | ||
72 | send_gdb "n\n" | |
73 | gdb_expect { | |
74 | -re "$decimal.*i = 2;.*$gdb_prompt $" { | |
75 | pass "next " | |
76 | } | |
77 | -re ".*$gdb_prompt $" { fail "next " } | |
78 | timeout { fail "next " } | |
79 | } | |
80 | ||
81 | ||
82 | send_gdb "n\n" | |
83 | gdb_expect { | |
84 | -re "$decimal.*f = 4.5;.*$gdb_prompt $" { | |
85 | pass "next " | |
86 | } | |
87 | -re ".*$gdb_prompt $" { fail "next " } | |
88 | timeout { fail "next " } | |
89 | } | |
90 | ||
91 | send_gdb "n\n" | |
92 | gdb_expect { | |
93 | -re "$decimal.*c = add\\(c, c\\);.*$gdb_prompt $" { | |
94 | pass "next " | |
95 | } | |
96 | -re ".*$gdb_prompt $" { fail "next " } | |
97 | timeout { fail "next " } | |
98 | } | |
99 | ||
100 | send_gdb "n\n" | |
101 | gdb_expect { | |
102 | -re "$decimal.*i = add\\(i, i\\);.*$gdb_prompt $" { | |
103 | pass "next " | |
104 | } | |
105 | -re ".*$gdb_prompt $" { fail "next " } | |
106 | timeout { fail "next " } | |
107 | } | |
108 | ||
109 | send_gdb "n\n" | |
110 | gdb_expect { | |
111 | -re "$decimal.*f = add\\(f, f\\);.*$gdb_prompt $" { | |
112 | pass "next " | |
113 | } | |
114 | -re ".*$gdb_prompt $" { fail "next " } | |
115 | timeout { fail "next " } | |
116 | } | |
117 | ||
118 | send_gdb "n\n" | |
119 | gdb_expect { | |
120 | -re "$decimal.*add1\\(\\);.*$gdb_prompt $" { | |
121 | pass "next " | |
122 | } | |
123 | -re ".*$gdb_prompt $" { fail "next " } | |
124 | timeout { fail "next " } | |
125 | } | |
126 | ||
127 | send_gdb "print c\n" | |
128 | gdb_expect { | |
129 | -re ".$decimal = -62.*\r\n$gdb_prompt $" { | |
130 | pass "print value of c" | |
131 | } | |
132 | -re ".*$gdb_prompt $" { fail "print value of c" } | |
133 | timeout { fail "(timeout) print value of c" } | |
134 | } | |
135 | ||
136 | ||
137 | send_gdb "print f\n" | |
138 | gdb_expect { | |
139 | -re ".$decimal = 9\r\n$gdb_prompt $" { | |
140 | pass "print value of f" | |
141 | } | |
142 | -re ".*$gdb_prompt $" { fail "print value of f" } | |
143 | timeout { fail "(timeout) print value of f" } | |
144 | } | |
145 | ||
146 | ||
147 | send_gdb "print i\n" | |
148 | gdb_expect { | |
149 | -re ".$decimal = 4\r\n$gdb_prompt $" { | |
150 | pass "print value of i" | |
151 | } | |
152 | -re ".*$gdb_prompt $" { fail "print value of i" } | |
153 | timeout { fail "(timeout) print value of i" } | |
154 | } | |
155 | ||
156 | ||
157 | ||
158 | send_gdb "print add<int>(2,2)\n" | |
159 | gdb_expect { | |
160 | -re ".$decimal = 4\r\n$gdb_prompt $" { | |
161 | pass "print value of add<int>(2,2)" | |
162 | } | |
163 | -re ".*$gdb_prompt $" { fail "print value of add<int>(2,2)" } | |
164 | timeout { fail "(timeout) print value of add<int>(2,2)" } | |
165 | } | |
166 | ||
167 | send_gdb "print add<float>(2.3,2.3)\n" | |
168 | gdb_expect { | |
169 | -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" { | |
170 | pass "print value of add<float>(2.3,2.3)" | |
171 | } | |
172 | -re ".*$gdb_prompt $" { fail "print value of add<float>(2.3,2.3)" } | |
173 | timeout { fail "(timeout) print value of add<float>(2.3,2.3)" } | |
174 | } | |
175 | ||
176 | send_gdb "print add<char>('A','A')\n" | |
177 | gdb_expect { | |
178 | -re ".$decimal = -126.*202.\r\n$gdb_prompt $" { | |
179 | pass "print value of add<char>('A','A')" | |
180 | } | |
181 | -re ".*$gdb_prompt $" { fail "print value of add<char>('A','A')" } | |
182 | timeout { fail "(timeout) print value of add<char>('A','A')" } | |
183 | } | |
184 | ||
185 | ||
186 | send_gdb "print add2<int>(2,2)\n" | |
187 | gdb_expect { | |
188 | -re ".$decimal = 4\r\n$gdb_prompt $" { | |
189 | pass "print value of add2<int>(2,2)" | |
190 | } | |
191 | -re ".*$gdb_prompt $" { fail "print value of add2<int>(2,2)" } | |
192 | timeout { fail "(timeout) print value of add2<int>(2,2)" } | |
193 | } | |
194 | ||
195 | send_gdb "print add2<float>(2.3,2.3)\n" | |
196 | gdb_expect { | |
197 | -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" { | |
198 | pass "print value of add2<float>(2.3,2.3)" | |
199 | } | |
200 | -re ".*$gdb_prompt $" { fail "print value of add2<float>(2.3,2.3)" } | |
201 | timeout { fail "(timeout) print value of add2<float>(2.3,2.3)" } | |
202 | } | |
203 | ||
204 | send_gdb "print add2<char>('A','A')\n" | |
205 | gdb_expect { | |
206 | -re ".$decimal = -126.*202.\r\n$gdb_prompt $" { | |
207 | pass "print value of add2<char>('A','A')" | |
208 | } | |
209 | -re ".*$gdb_prompt $" { fail "print value of add2<char>('A','A')" } | |
210 | timeout { fail "(timeout) print value of add2<char>('A','A')" } | |
211 | } | |
212 | ||
213 | send_gdb "print add3<int>(2,2)\n" | |
214 | gdb_expect { | |
215 | -re ".$decimal = 4\r\n$gdb_prompt $" { | |
216 | pass "print value of add3<int>(2,2)" | |
217 | } | |
218 | -re ".*$gdb_prompt $" { fail "print value of add3<int>(2,2)" } | |
219 | timeout { fail "(timeout) print value of add3<int>(2,2)" } | |
220 | } | |
221 | ||
222 | send_gdb "print add3<float>(2.3,2.3)\n" | |
223 | gdb_expect { | |
224 | -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" { | |
225 | pass "print value of add3<float>(2.3,2.3)" | |
226 | } | |
227 | -re ".*$gdb_prompt $" { fail "print value of add3<float>(2.3,2.3)" } | |
228 | timeout { fail "(timeout) print value of add3<float>(2.3,2.3)" } | |
229 | } | |
230 | ||
231 | send_gdb "print add3<char>('A','A')\n" | |
232 | gdb_expect { | |
233 | -re ".$decimal = -126.*202.\r\n$gdb_prompt $" { | |
234 | pass "print value of add3<char>('A','A')" | |
235 | } | |
236 | -re ".*$gdb_prompt $" { fail "print value of add3<char>('A','A')" } | |
237 | timeout { fail "(timeout) print value of add3<char>('A','A')" } | |
238 | } | |
239 | ||
240 | send_gdb "print add4<int>(2,2)\n" | |
241 | gdb_expect { | |
242 | -re ".$decimal = 4\r\n$gdb_prompt $" { | |
243 | pass "print value of add4<int>(2,2)" | |
244 | } | |
245 | -re ".*$gdb_prompt $" { fail "print value of add4<int>(2,2)" } | |
246 | timeout { fail "(timeout) print value of add4<int>(2,2)" } | |
247 | } | |
248 | ||
249 | send_gdb "print add4<float>(2.3,2.3)\n" | |
250 | gdb_expect { | |
251 | -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" { | |
252 | pass "print value of add4<float>(2.3,2.3)" | |
253 | } | |
254 | -re ".*$gdb_prompt $" { fail "print value of add4<float>(2.3,2.3)" } | |
255 | timeout { fail "(timeout) print value of add4<float>(2.3,2.3)" } | |
256 | } | |
257 | ||
258 | send_gdb "print add4<char>('A','A')\n" | |
259 | gdb_expect { | |
260 | -re ".$decimal = -126.*202.\r\n$gdb_prompt $" { | |
261 | pass "print value of add4<char>('A','A')" | |
262 | } | |
263 | -re ".*$gdb_prompt $" { fail "print value of add4<char>('A','A')" } | |
264 | timeout { fail "(timeout) print value of add4<char>('A','A')" } | |
265 | } | |
266 | ||
267 | ||
268 | gdb_exit | |
269 | return 0 |