ctti.exp revision 1.1.1.7 1 # Copyright 1998-2023 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 3 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, see <http://www.gnu.org/licenses/>.
15
16 # This file is part of the gdb testsuite
17 # file written by Elena Zannoni (ezannoni (at) cygnus.com)
18 # rewritten by Michael Chastain (mec.gnu (at) mindspring.com)
19 #
20 # source files cttiadd.cc, cttiadd1.cc, cttiadd2.cc, cttiadd3.cc
21
22 # Call to template instantiations.
23
24 if { [skip_cplus_tests] } { return }
25
26 standard_testfile cttiadd.cc cttiadd1.cc cttiadd2.cc cttiadd3.cc
27
28 if {[prepare_for_testing "failed to prepare" $testfile \
29 [list $srcfile $srcfile2 $srcfile3 $srcfile4] {debug c++}]} {
30 return -1
31 }
32
33 if {![runto_main]} {
34 return
35 }
36
37 gdb_breakpoint [gdb_get_line_number "marker add1"]
38 gdb_continue_to_breakpoint "marker add1"
39
40 gdb_test "print c" "\\$\[0-9\]+ = 194 .*"
41 gdb_test "print f" "\\$\[0-9\]+ = 9"
42 gdb_test "print i" "\\$\[0-9\]+ = 4"
43
44 # TODO: this needs more work before actually deploying it.
45 # So bail out here.
46
47 if {[test_compiler_info gcc-*]} { return }
48
49 gdb_test_multiple "print add<int>(2,2)" "print add<int>(2,2)" {
50 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
51 pass "print add<int>(2,2)"
52 }
53 -re "No symbol \"add<int>\" in current context.\r\n$gdb_prompt $" {
54 # TODO: kfail or xfail this
55 fail "print add<int>(2,2)"
56 }
57 }
58
59 # Note: 2.25 and 4.5 are exactly representable in IEEE-ish formats
60 gdb_test_multiple "print add<float>(2.25,2.25)" "print add<float>(2.25,2.25)" {
61 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
62 pass "print add<float>(2.25,2.25)"
63 }
64 -re "No symbol \"add<float>\" in current context.\r\n$gdb_prompt $" {
65 # TODO: kfail or xfail this
66 fail "print add<float>(2.25,2.25)"
67 }
68 }
69
70 gdb_test_multiple "print add<unsigned char>('A','A')" "print add<unsigned char>('A','A')" {
71 -re "\\$\[0-9\]+ = 130 .*\r\n$gdb_prompt $" {
72 pass "print add<unsigned char>('A','A')"
73 }
74 -re "No symbol \"add<unsigned char>\" in current context.\r\n$gdb_prompt $" {
75 # TODO: kfail or xfail this
76 fail "print add<unsigned char>('A','A')"
77 }
78 }
79
80 gdb_test_multiple "print add2<int>(2,2)" "print add2<int>(2,2)" {
81 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
82 pass "print add2<int>(2,2)"
83 }
84 -re "No symbol \"add2<int>\" in current context.\r\n$gdb_prompt $" {
85 # TODO: kfail or xfail this
86 fail "print add2<int>(2,2)"
87 }
88 }
89
90 gdb_test_multiple "print add2<float>(2.25,2.25)" "print add2<float>(2.25,2.25)" {
91 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
92 pass "print add2<float>(2.25,2.25)"
93 }
94 -re "No symbol \"add2<float>\" in current context.\r\n$gdb_prompt $" {
95 # TODO: kfail or xfail this
96 fail "print add2<float>(2.25,2.25)"
97 }
98 }
99
100 gdb_test_multiple "print add2<unsigned char>('A','A')" "print add2<unsigned char>('A','A')" {
101 -re "\\$\[0-9]+ = 130 .*$gdb_prompt $" {
102 pass "print add2<unsigned char>('A','A')"
103 }
104 -re "No symbol \"add2<unsigned char>\" in current context.\r\n$gdb_prompt $" {
105 # TODO: kfail or xfail this
106 fail "print add2<unsigned char>('A','A')"
107 }
108 }
109
110 gdb_test_multiple "print add3<int>(2,2)" "print add3<int>(2,2)" {
111 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
112 pass "print add3<int>(2,2)"
113 }
114 -re "No symbol \"add3<int>\" in current context.\r\n$gdb_prompt $" {
115 # TODO: kfail or xfail this
116 fail "print add3<int>(2,2)"
117 }
118 }
119
120 gdb_test_multiple "print add3<float>(2.25,2.25)" "print add3<float>(2.25,2.25)" {
121 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
122 pass "print add3<float>(2.25,2.25)"
123 }
124 -re "No symbol \"add3<float>\" in current context.\r\n$gdb_prompt $" {
125 # TODO: kfail or xfail this
126 fail "print add3<float>(2.25,2.25)"
127 }
128 }
129
130 gdb_test_multiple "print add3<unsigned char>('A','A')" "print add3<unsigned char>('A','A')" {
131 -re "\\$\[0-9]+ = 130 .*$gdb_prompt $" {
132 pass "print add3<unsigned char>('A','A')"
133 }
134 -re "No symbol \"add3<unsigned char>\" in current context.\r\n$gdb_prompt $" {
135 # TODO: kfail or xfail this
136 fail "print add3<unsigned char>('A','A')"
137 }
138 }
139
140 gdb_test_multiple "print add4<int>(2,2)" "print add4<int>(2,2)" {
141 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
142 pass "print add4<int>(2,2)"
143 }
144 -re "No symbol \"add4<int>\" in current context.\r\n$gdb_prompt $" {
145 # TODO: kfail or xfail this
146 fail "print add4<int>(2,2)"
147 }
148 }
149
150 gdb_test_multiple "print add4<float>(2.25,2.25)" "print add4<float>(2.25,2.25)" {
151 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
152 pass "print add4<float>(2.25,2.25)"
153 }
154 -re "No symbol \"add4<float>\" in current context.\r\n$gdb_prompt $" {
155 # TODO: kfail or xfail this
156 fail "print add4<float>(2.25,2.25)"
157 }
158 }
159
160 gdb_test_multiple "print add4<unsigned char>('A','A')" "print add4<unsigned char>('A','A')" {
161 -re "\\$\[0-9]+ = 130 .*$gdb_prompt $" {
162 pass "print add4<unsigned char>('A','A')"
163 }
164 -re "No symbol \"add4<unsigned char>\" in current context.\r\n$gdb_prompt $" {
165 # TODO: kfail or xfail this
166 fail "print add4<unsigned char>('A','A')"
167 }
168 }
169