Commit | Line | Data |
---|---|---|
c906108c SS |
1 | # 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 arithmetic, logical and relational operators | |
25 | # with mixed types | |
26 | # | |
27 | ||
28 | ||
29 | ||
30 | if $tracelevel then { | |
31 | strace $tracelevel | |
32 | } | |
33 | ||
34 | # | |
35 | # test running programs | |
36 | # | |
37 | set prms_id 0 | |
38 | set bug_id 0 | |
39 | ||
40 | set testfile "all-types" | |
41 | set srcfile ${testfile}.c | |
42 | set binfile ${objdir}/${subdir}/${testfile} | |
43 | ||
44 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { | |
45 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
46 | } | |
47 | ||
085dd6e6 JM |
48 | if [get_compiler_info ${binfile}] { |
49 | return -1 | |
50 | } | |
51 | ||
c906108c SS |
52 | gdb_exit |
53 | gdb_start | |
54 | gdb_reinitialize_dir $srcdir/$subdir | |
55 | gdb_load ${binfile} | |
56 | ||
57 | ||
58 | # | |
59 | # set it up at a breakpoint so we can play with the variable values | |
60 | # | |
61 | ||
62 | if ![runto_main] then { | |
63 | perror "couldn't run to breakpoint" | |
64 | continue | |
65 | } | |
66 | ||
67 | gdb_test "next" "return 0;" "continuing after dummy()" | |
68 | ||
69 | send_gdb "print v_int+v_char\n" | |
70 | gdb_expect { | |
71 | -re ".*71.*$gdb_prompt $" { | |
72 | pass "print value of v_int+v_char" | |
73 | } | |
74 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_char" } | |
75 | timeout { fail "(timeout) print value of v_int+v_char" } | |
76 | } | |
77 | ||
78 | send_gdb "print v_int+v_short\n" | |
79 | gdb_expect { | |
80 | -re ".*9.*$gdb_prompt $" { | |
81 | pass "print value of v_int+v_short" | |
82 | } | |
83 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_short" } | |
84 | timeout { fail "(timeout) print value of v_int+v_short" } | |
85 | } | |
86 | ||
87 | ||
88 | send_gdb "print v_int+v_signed_char\n" | |
89 | gdb_expect { | |
90 | -re ".*72.*$gdb_prompt $" { | |
91 | pass "print value of v_int+v_signed_char" | |
92 | } | |
93 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_char" } | |
94 | timeout { fail "(timeout) print value of v_int+v_signed_char" } | |
95 | } | |
96 | ||
97 | ||
98 | send_gdb "print v_int+v_unsigned_char\n" | |
99 | gdb_expect { | |
100 | -re ".*73.*$gdb_prompt $" { | |
101 | pass "print value of v_int+v_unsigned_char" | |
102 | } | |
103 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_char" } | |
104 | timeout { fail "(timeout) print value of v_int+v_unsigned_char" } | |
105 | } | |
106 | ||
107 | ||
108 | send_gdb "print v_int+v_signed_short\n" | |
109 | gdb_expect { | |
110 | -re ".*10.*$gdb_prompt $" { | |
111 | pass "print value of v_int+v_signed_short" | |
112 | } | |
113 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_short" } | |
114 | timeout { fail "(timeout) print value of v_int+v_signed_short" } | |
115 | } | |
116 | ||
117 | ||
118 | send_gdb "print v_int+v_unsigned_short\n" | |
119 | gdb_expect { | |
120 | -re ".*11.*$gdb_prompt $" { | |
121 | pass "print value of v_int+v_unsigned_short" | |
122 | } | |
123 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_short" } | |
124 | timeout { fail "(timeout) print value of v_int+v_unsigned_short" } | |
125 | } | |
126 | ||
127 | ||
128 | send_gdb "print v_int+v_signed_int\n" | |
129 | gdb_expect { | |
130 | -re ".*13.*$gdb_prompt $" { | |
131 | pass "print value of v_int+v_signed_int" | |
132 | } | |
133 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_int" } | |
134 | timeout { fail "(timeout) print value of v_int+v_signed_int" } | |
135 | } | |
136 | ||
137 | ||
138 | send_gdb "print v_int+v_unsigned_int\n" | |
139 | gdb_expect { | |
140 | -re ".*14.*$gdb_prompt $" { | |
141 | pass "print value of v_int+v_unsigned_int" | |
142 | } | |
143 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_int" } | |
144 | timeout { fail "(timeout) print value of v_int+v_unsigned_int" } | |
145 | } | |
146 | ||
147 | ||
148 | send_gdb "print v_int+v_long\n" | |
149 | gdb_expect { | |
150 | -re ".*15.*$gdb_prompt $" { | |
151 | pass "print value of v_int+v_long" | |
152 | } | |
153 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_long" } | |
154 | timeout { fail "(timeout) print value of v_int+v_long" } | |
155 | } | |
156 | ||
157 | ||
158 | send_gdb "print v_int+v_signed_long\n" | |
159 | gdb_expect { | |
160 | -re ".*16.*$gdb_prompt $" { | |
161 | pass "print value of v_int+v_signed_long" | |
162 | } | |
163 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_long" } | |
164 | timeout { fail "(timeout) print value of v_int+v_signed_long" } | |
165 | } | |
166 | ||
167 | ||
168 | send_gdb "print v_int+v_unsigned_long\n" | |
169 | gdb_expect { | |
170 | -re ".*17.*$gdb_prompt $" { | |
171 | pass "print value of v_int+v_unsigned_long" | |
172 | } | |
173 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_long" } | |
174 | timeout { fail "(timeout) print value of v_int+v_unsigned_long" } | |
175 | } | |
176 | ||
177 | ||
178 | send_gdb "print v_int+v_float\n" | |
179 | gdb_expect { | |
180 | -re ".*106.34343.*$gdb_prompt $" { | |
181 | pass "print value of v_int+v_float" | |
182 | } | |
183 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_float" } | |
184 | timeout { fail "(timeout) print value of v_int+v_float" } | |
185 | } | |
186 | ||
187 | ||
188 | send_gdb "print v_int+v_double\n" | |
189 | gdb_expect { | |
190 | -re ".*206.56565.*$gdb_prompt $" { | |
191 | pass "print value of v_int+v_double" | |
192 | } | |
193 | -re ".*$gdb_prompt $" { fail "print value of v_int+v_double" } | |
194 | timeout { fail "(timeout) print value of v_int+" } | |
195 | } | |
196 | ||
197 | ||
198 | # | |
199 | # test the relational operators with mixed types | |
200 | # | |
201 | ||
202 | send_gdb "print v_int <= v_char\n" | |
203 | gdb_expect { | |
204 | -re ".*1.*$gdb_prompt $" { | |
205 | pass "print value of v_int<=v_char" | |
206 | } | |
207 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_char" } | |
208 | timeout { fail "(timeout) print value of v_int<=v_char" } | |
209 | } | |
210 | ||
211 | send_gdb "print v_int <= v_short\n" | |
212 | gdb_expect { | |
085dd6e6 | 213 | -re ".*$false.*$gdb_prompt $" { |
c906108c SS |
214 | pass "print value of v_int<=v_short" |
215 | } | |
216 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_short" } | |
217 | timeout { fail "(timeout) print value of v_int<=v_short" } | |
218 | } | |
219 | ||
220 | ||
221 | send_gdb "print v_int <= v_signed_char\n" | |
222 | gdb_expect { | |
223 | -re ".*1.*$gdb_prompt $" { | |
224 | pass "print value of v_int<=v_signed_char" | |
225 | } | |
226 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_char" } | |
227 | timeout { fail "(timeout) print value of v_int<=v_signed_char" } | |
228 | } | |
229 | ||
230 | ||
231 | send_gdb "print v_int <= v_unsigned_char\n" | |
232 | gdb_expect { | |
233 | -re ".*1.*$gdb_prompt $" { | |
234 | pass "print value of v_int<=v_unsigned_char" | |
235 | } | |
236 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_char" } | |
237 | timeout { fail "(timeout) print value of v_int<=v_unsigned_char" } | |
238 | } | |
239 | ||
240 | ||
241 | send_gdb "print v_int <= v_signed_short\n" | |
242 | gdb_expect { | |
085dd6e6 | 243 | -re ".*$false.*$gdb_prompt $" { |
c906108c SS |
244 | pass "print value of v_int<=v_signed_short" |
245 | } | |
246 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_short" } | |
247 | timeout { fail "(timeout) print value of v_int<=v_signed_short" } | |
248 | } | |
249 | ||
250 | ||
251 | send_gdb "print v_int <= v_unsigned_short\n" | |
252 | gdb_expect { | |
085dd6e6 | 253 | -re ".*$false.*$gdb_prompt $" { |
c906108c SS |
254 | pass "print value of v_int<=v_unsigned_short" |
255 | } | |
256 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_short" } | |
257 | timeout { fail "(timeout) print value of v_int<=v_unsigned_short" } | |
258 | } | |
259 | ||
260 | ||
261 | send_gdb "print v_int <= v_signed_int\n" | |
262 | gdb_expect { | |
085dd6e6 | 263 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
264 | pass "print value of v_int<=v_signed_int" |
265 | } | |
266 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_int" } | |
267 | timeout { fail "(timeout) print value of v_int<=v_signed_int" } | |
268 | } | |
269 | ||
270 | ||
271 | send_gdb "print v_int <= v_unsigned_int\n" | |
272 | gdb_expect { | |
085dd6e6 | 273 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
274 | pass "print value of v_int<=v_unsigned_int" |
275 | } | |
276 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_int" } | |
277 | timeout { fail "(timeout) print value of v_int<=v_unsigned_int" } | |
278 | } | |
279 | ||
280 | ||
281 | send_gdb "print v_int <= v_long\n" | |
282 | gdb_expect { | |
085dd6e6 | 283 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
284 | pass "print value of v_int<=v_long" |
285 | } | |
286 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_long" } | |
287 | timeout { fail "(timeout) print value of v_int<=v_long" } | |
288 | } | |
289 | ||
290 | ||
291 | send_gdb "print v_int <= v_signed_long\n" | |
292 | gdb_expect { | |
085dd6e6 | 293 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
294 | pass "print value of v_int<=v_signed_long" |
295 | } | |
296 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_long" } | |
297 | timeout { fail "(timeout) print value of v_int<=v_signed_long" } | |
298 | } | |
299 | ||
300 | ||
301 | send_gdb "print v_int <= v_unsigned_long\n" | |
302 | gdb_expect { | |
085dd6e6 | 303 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
304 | pass "print value of v_int<=v_unsigned_long" |
305 | } | |
306 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_long" } | |
307 | timeout { fail "(timeout) print value of v_int<=v_unsigned_long" } | |
308 | } | |
309 | ||
310 | ||
311 | send_gdb "print v_int <= v_float\n" | |
312 | gdb_expect { | |
085dd6e6 | 313 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
314 | pass "print value of v_int<=v_float" |
315 | } | |
316 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_float" } | |
317 | timeout { fail "(timeout) print value of v_int<=v_float" } | |
318 | } | |
319 | ||
320 | ||
321 | send_gdb "print v_int <= v_double\n" | |
322 | gdb_expect { | |
085dd6e6 | 323 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
324 | pass "print value of v_int<=v_double" |
325 | } | |
326 | -re ".*$gdb_prompt $" { fail "print value of v_int<=v_double" } | |
327 | timeout { fail "(timeout) print value of v_int<=v_double" } | |
328 | } | |
329 | ||
330 | ||
331 | ||
332 | # | |
333 | # test the logical operators with mixed types | |
334 | # | |
335 | ||
336 | gdb_test "set variable v_char=0" "" "set v_char=0" | |
337 | gdb_test "set variable v_double=0.0" "" "set v_double=0" | |
338 | gdb_test "set variable v_unsigned_long=0" "" "set v_unsigned_long=0" | |
339 | ||
340 | send_gdb "print v_int && v_char\n" | |
341 | gdb_expect { | |
085dd6e6 | 342 | -re ".*$false.*$gdb_prompt $" { |
c906108c SS |
343 | pass "print value of v_int&&v_char" |
344 | } | |
345 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_char" } | |
346 | timeout { fail "(timeout) print value of v_int&&v_char" } | |
347 | } | |
348 | ||
349 | send_gdb "print v_int && v_short\n" | |
350 | gdb_expect { | |
085dd6e6 | 351 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
352 | pass "print value of v_int&&v_short" |
353 | } | |
354 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_short" } | |
355 | timeout { fail "(timeout) print value of v_int&&v_short" } | |
356 | } | |
357 | ||
358 | ||
359 | send_gdb "print v_int && v_signed_char\n" | |
360 | gdb_expect { | |
085dd6e6 | 361 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
362 | pass "print value of v_int&&v_signed_char" |
363 | } | |
364 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_char" } | |
365 | timeout { fail "(timeout) print value of v_int&&v_signed_char" } | |
366 | } | |
367 | ||
368 | ||
369 | send_gdb "print v_int && v_unsigned_char\n" | |
370 | gdb_expect { | |
085dd6e6 | 371 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
372 | pass "print value of v_int&&v_unsigned_char" |
373 | } | |
374 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_char" } | |
375 | timeout { fail "(timeout) print value of v_int&&v_unsigned_char" } | |
376 | } | |
377 | ||
378 | ||
379 | send_gdb "print v_int && v_signed_short\n" | |
380 | gdb_expect { | |
085dd6e6 | 381 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
382 | pass "print value of v_int&&v_signed_short" |
383 | } | |
384 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_short" } | |
385 | timeout { fail "(timeout) print value of v_int&&v_signed_short" } | |
386 | } | |
387 | ||
388 | ||
389 | send_gdb "print v_int && v_unsigned_short\n" | |
390 | gdb_expect { | |
085dd6e6 | 391 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
392 | pass "print value of v_int&&v_unsigned_short" |
393 | } | |
394 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_short" } | |
395 | timeout { fail "(timeout) print value of v_int&&v_unsigned_short" } | |
396 | } | |
397 | ||
398 | ||
399 | send_gdb "print v_int && v_signed_int\n" | |
400 | gdb_expect { | |
085dd6e6 | 401 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
402 | pass "print value of v_int&&v_signed_int" |
403 | } | |
404 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_int" } | |
405 | timeout { fail "(timeout) print value of v_int&&v_signed_int" } | |
406 | } | |
407 | ||
408 | ||
409 | send_gdb "print v_int && v_unsigned_int\n" | |
410 | gdb_expect { | |
085dd6e6 | 411 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
412 | pass "print value of v_int&&v_unsigned_int" |
413 | } | |
414 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_int" } | |
415 | timeout { fail "(timeout) print value of v_int&&v_unsigned_int" } | |
416 | } | |
417 | ||
418 | ||
419 | send_gdb "print v_int && v_long\n" | |
420 | gdb_expect { | |
085dd6e6 | 421 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
422 | pass "print value of v_int&&v_long" |
423 | } | |
424 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_long" } | |
425 | timeout { fail "(timeout) print value of v_int&&v_long" } | |
426 | } | |
427 | ||
428 | ||
429 | send_gdb "print v_int && v_signed_long\n" | |
430 | gdb_expect { | |
085dd6e6 | 431 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
432 | pass "print value of v_int&&v_signed_long" |
433 | } | |
434 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_long" } | |
435 | timeout { fail "(timeout) print value of v_int&&v_signed_long" } | |
436 | } | |
437 | ||
438 | ||
439 | send_gdb "print v_int && v_unsigned_long\n" | |
440 | gdb_expect { | |
085dd6e6 | 441 | -re ".*$false.*$gdb_prompt $" { |
c906108c SS |
442 | pass "print value of v_int&&v_unsigned_long" |
443 | } | |
444 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_long" } | |
445 | timeout { fail "(timeout) print value of v_int&&v_unsigned_long" } | |
446 | } | |
447 | ||
448 | ||
449 | send_gdb "print v_int && v_float\n" | |
450 | gdb_expect { | |
085dd6e6 | 451 | -re ".*$true.*$gdb_prompt $" { |
c906108c SS |
452 | pass "print value of v_int&&v_float" |
453 | } | |
454 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_float" } | |
455 | timeout { fail "(timeout) print value of v_int&&v_float" } | |
456 | } | |
457 | ||
458 | ||
459 | send_gdb "print v_int && v_double\n" | |
460 | gdb_expect { | |
085dd6e6 | 461 | -re ".*$false.*$gdb_prompt $" { |
c906108c SS |
462 | pass "print value of v_int&&v_double" |
463 | } | |
464 | -re ".*$gdb_prompt $" { fail "print value of v_int&&v_double" } | |
465 | timeout { fail "(timeout) print value of v_int&&v_double" } | |
466 | } | |
467 | ||
468 | ||
469 | ||
470 | ||
471 |