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