]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.c++/ctti.exp
import gdb-1999-08-02 snapshot
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.c++ / ctti.exp
CommitLineData
a0b3c4fd
JM
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
28if $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
37set testfile "cttiadd"
38set srcfile ${testfile}.cc
39set srcfile1 ${testfile}1.cc
40set srcfile2 ${testfile}2.cc
41set srcfile3 ${testfile}3.cc
42set binfile ${objdir}/${subdir}/${testfile}
43
44if [get_compiler_info ${binfile} "c++"] {
45 return -1;
46}
47
48if { $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
54set cmdline "$CXX_FOR_TARGET ${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1} ${srcdir}/${subdir}/${srcfile2} ${srcdir}/${subdir}/${srcfile3} -g -o ${binfile}"
55
56remote_exec build $cmdline
57
58gdb_exit
59gdb_start
60gdb_reinitialize_dir $srcdir/$subdir
61gdb_load ${binfile}
62
63
64
65if ![runto_main] then {
66 perror "couldn't run to breakpoint"
67 continue
68}
69
70
71send_gdb "n\n"
72gdb_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
81send_gdb "n\n"
82gdb_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
90send_gdb "n\n"
91gdb_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
99send_gdb "n\n"
100gdb_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
108send_gdb "n\n"
109gdb_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
117send_gdb "n\n"
118gdb_expect {
119 -re "$decimal.*add1\\(\\);.*$gdb_prompt $" {
120 pass "next "
121 }
122 -re ".*$gdb_prompt $" { fail "next " }
123 timeout { fail "next " }
124 }
125
126send_gdb "print c\n"
127gdb_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
136send_gdb "print f\n"
137gdb_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
146send_gdb "print i\n"
147gdb_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
157send_gdb "print add<int>(2,2)\n"
158gdb_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
166send_gdb "print add<float>(2.3,2.3)\n"
167gdb_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
175send_gdb "print add<char>('A','A')\n"
176gdb_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
185send_gdb "print add2<int>(2,2)\n"
186gdb_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
194send_gdb "print add2<float>(2.3,2.3)\n"
195gdb_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
203send_gdb "print add2<char>('A','A')\n"
204gdb_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
212send_gdb "print add3<int>(2,2)\n"
213gdb_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
221send_gdb "print add3<float>(2.3,2.3)\n"
222gdb_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
230send_gdb "print add3<char>('A','A')\n"
231gdb_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
239send_gdb "print add4<int>(2,2)\n"
240gdb_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
248send_gdb "print add4<float>(2.3,2.3)\n"
249gdb_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
257send_gdb "print add4<char>('A','A')\n"
258gdb_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
267gdb_exit
268return 0