1 # Copyright (C) 1998 Free Software Foundation, Inc.
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.
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.
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.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
21 # This file is part of the gdb testsuite
22 # file written by Elena Zannoni (ezannoni@cygnus.com)
24 # source files cttiadd.cc, cttiadd1.cc, cttiadd2.cc, cttiadd3.cc
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.
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}
44 if [get_compiler_info ${binfile} "c++"] {
48 if { $gcc_compiled } then { continue }
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."
54 set cmdline "$CXX_FOR_TARGET ${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1} ${srcdir}/${subdir}/${srcfile2} ${srcdir}/${subdir}/${srcfile3} -g -o ${binfile}"
56 remote_exec build $cmdline
60 gdb_reinitialize_dir $srcdir/$subdir
65 if ![runto_main] then {
66 perror "couldn't run to breakpoint"
73 -re "$decimal.*i = 2;.*$gdb_prompt $" {
76 -re ".*$gdb_prompt $" { fail "next " }
77 timeout { fail "next " }
83 -re "$decimal.*f = 4.5;.*$gdb_prompt $" {
86 -re ".*$gdb_prompt $" { fail "next " }
87 timeout { fail "next " }
92 -re "$decimal.*c = add\\(c, c\\);.*$gdb_prompt $" {
95 -re ".*$gdb_prompt $" { fail "next " }
96 timeout { fail "next " }
101 -re "$decimal.*i = add\\(i, i\\);.*$gdb_prompt $" {
104 -re ".*$gdb_prompt $" { fail "next " }
105 timeout { fail "next " }
110 -re "$decimal.*f = add\\(f, f\\);.*$gdb_prompt $" {
113 -re ".*$gdb_prompt $" { fail "next " }
114 timeout { fail "next " }
119 -re "$decimal.*add1\\(\\);.*$gdb_prompt $" {
122 -re ".*$gdb_prompt $" { fail "next " }
123 timeout { fail "next " }
128 -re ".$decimal = -62.*\r\n$gdb_prompt $" {
129 pass "print value of c"
131 -re ".*$gdb_prompt $" { fail "print value of c" }
132 timeout { fail "(timeout) print value of c" }
138 -re ".$decimal = 9\r\n$gdb_prompt $" {
139 pass "print value of f"
141 -re ".*$gdb_prompt $" { fail "print value of f" }
142 timeout { fail "(timeout) print value of f" }
148 -re ".$decimal = 4\r\n$gdb_prompt $" {
149 pass "print value of i"
151 -re ".*$gdb_prompt $" { fail "print value of i" }
152 timeout { fail "(timeout) print value of i" }
157 send_gdb "print add<int>(2,2)\n"
159 -re ".$decimal = 4\r\n$gdb_prompt $" {
160 pass "print value of add<int>(2,2)"
162 -re ".*$gdb_prompt $" { fail "print value of add<int>(2,2)" }
163 timeout { fail "(timeout) print value of add<int>(2,2)" }
166 send_gdb "print add<float>(2.3,2.3)\n"
168 -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" {
169 pass "print value of add<float>(2.3,2.3)"
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)" }
175 send_gdb "print add<char>('A','A')\n"
177 -re ".$decimal = -126.*202.\r\n$gdb_prompt $" {
178 pass "print value of add<char>('A','A')"
180 -re ".*$gdb_prompt $" { fail "print value of add<char>('A','A')" }
181 timeout { fail "(timeout) print value of add<char>('A','A')" }
185 send_gdb "print add2<int>(2,2)\n"
187 -re ".$decimal = 4\r\n$gdb_prompt $" {
188 pass "print value of add2<int>(2,2)"
190 -re ".*$gdb_prompt $" { fail "print value of add2<int>(2,2)" }
191 timeout { fail "(timeout) print value of add2<int>(2,2)" }
194 send_gdb "print add2<float>(2.3,2.3)\n"
196 -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" {
197 pass "print value of add2<float>(2.3,2.3)"
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)" }
203 send_gdb "print add2<char>('A','A')\n"
205 -re ".$decimal = -126.*202.\r\n$gdb_prompt $" {
206 pass "print value of add2<char>('A','A')"
208 -re ".*$gdb_prompt $" { fail "print value of add2<char>('A','A')" }
209 timeout { fail "(timeout) print value of add2<char>('A','A')" }
212 send_gdb "print add3<int>(2,2)\n"
214 -re ".$decimal = 4\r\n$gdb_prompt $" {
215 pass "print value of add3<int>(2,2)"
217 -re ".*$gdb_prompt $" { fail "print value of add3<int>(2,2)" }
218 timeout { fail "(timeout) print value of add3<int>(2,2)" }
221 send_gdb "print add3<float>(2.3,2.3)\n"
223 -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" {
224 pass "print value of add3<float>(2.3,2.3)"
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)" }
230 send_gdb "print add3<char>('A','A')\n"
232 -re ".$decimal = -126.*202.\r\n$gdb_prompt $" {
233 pass "print value of add3<char>('A','A')"
235 -re ".*$gdb_prompt $" { fail "print value of add3<char>('A','A')" }
236 timeout { fail "(timeout) print value of add3<char>('A','A')" }
239 send_gdb "print add4<int>(2,2)\n"
241 -re ".$decimal = 4\r\n$gdb_prompt $" {
242 pass "print value of add4<int>(2,2)"
244 -re ".*$gdb_prompt $" { fail "print value of add4<int>(2,2)" }
245 timeout { fail "(timeout) print value of add4<int>(2,2)" }
248 send_gdb "print add4<float>(2.3,2.3)\n"
250 -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" {
251 pass "print value of add4<float>(2.3,2.3)"
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)" }
257 send_gdb "print add4<char>('A','A')\n"
259 -re ".$decimal = -126.*202.\r\n$gdb_prompt $" {
260 pass "print value of add4<char>('A','A')"
262 -re ".*$gdb_prompt $" { fail "print value of add4<char>('A','A')" }
263 timeout { fail "(timeout) print value of add4<char>('A','A')" }