2009-10-28 Kai Tietz <kai.tietz@onevision.com>
[external/binutils.git] / binutils / testsuite / binutils-all / dlltool.exp
1 # Copyright 2002, 2004, 2006, 2007, 2009 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, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
16
17 if {![istarget "i*86-*-*"] && ![istarget "x86_64-*-mingw*"] } {
18     return
19 }
20
21 if {![istarget "i*86-*-*pe*"] \
22     && ![istarget "i*86-*-cygwin*"] \
23     && ![istarget "i*86-*-mingw32*"] \
24     && ![istarget "x86_64-*-mingw*"] } {
25     set target_xfail "yes"
26 } else {
27     set target_xfail "no"
28 }
29
30 if {![info exists DLLTOOL]} then {
31     return
32 }
33
34 if {[which $DLLTOOL] == 0} then {
35     return
36 }
37
38 verbose "$DLLTOOL -d $srcdir/$subdir/fastcall.def" 1
39 catch "exec $DLLTOOL -d $srcdir/$subdir/fastcall.def" err
40
41 if ![string match "" $err] then {
42     send_log "$err\n"
43     verbose "$err" 1
44     fail "dlltool (fastcall export)"
45 } else {
46     pass "dlltool (fastcall export)"
47 }
48
49 if { "$target_xfail" == "yes" } {
50     setup_xfail *-*
51 }
52
53 verbose "$DLLTOOL -p prefix -l tmpdir/libalias.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" 1
54 catch "exec $DLLTOOL -p prefix -l tmpdir/libalias.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" err
55
56 if ![string match "" $err] then {
57     send_log "$err\n"
58     verbose "$err" 1
59     fail "dlltool -p (execution)"
60     continue
61 }
62
63 pass "dlltool -p (execution)"
64
65 set got [binutils_run $NM "tmpdir/libalias.a"]
66 set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol"
67
68 if [regexp $want $got] then {
69     pass "dlltool -p (symbol names)"
70 } else {
71     fail "dlltool -p (symbol names)"
72 }
73
74 set got [binutils_run $OBJDUMP "-s -j .idata\$6 tmpdir/libalias.a"]
75 set want "(Contents of section .idata\\\$6:.*\\.\\.symbol\\.\\..*){2,2}"
76
77 if [regexp $want $got] then {
78     pass "dlltool -p (import name)"
79 } else {
80     fail "dlltool -p (import name)"
81 }
82
83 verbose "$DLLTOOL -p prefix -l tmpdir/libalias2.a -d $srcdir/$subdir/alias-2.def $dlltool_gas_flag" 1
84 catch "exec $DLLTOOL -p prefix -l tmpdir/libalias2.a -d $srcdir/$subdir/alias-2.def $dlltool_gas_flag" err
85
86 if ![string match "" $err] then {
87     send_log "$err\n"
88     verbose "$err" 1
89     fail "dlltool -p (execution) alias-2.def"
90     continue
91 }
92
93 pass "dlltool -p (execution) alias-2.def"
94
95 set got [binutils_run $NM "tmpdir/libalias2.a"]
96 set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol"
97
98 if [regexp $want $got] then {
99     pass "dlltool -p (symbol names) alias-2.def"
100 } else {
101     fail "dlltool -p (symbol names) alias-2.def"
102 }
103
104 set got [binutils_run $OBJDUMP "-s -j .idata\$6 tmpdir/libalias2.a"]
105 set want "(Contents of section .idata\\\$6:.*\\.\\.something\\..*){2,2}"
106
107 if [regexp $want $got] then {
108     pass "dlltool -p (import name) alias-2.def"
109 } else {
110     fail "dlltool -p (import name) alias-2.def"
111 }
112
113 # Here we test explicit without leading underscore
114
115 verbose "$DLLTOOL --no-leading-underscore -d $srcdir/$subdir/fastcall.def" 1
116 catch "exec $DLLTOOL --no-leading-underscore -d $srcdir/$subdir/fastcall.def" err
117
118 if ![string match "" $err] then {
119     send_log "$err\n"
120     verbose "$err" 1
121     fail "dlltool (fastcall export no leading underscore)"
122 } else {
123     pass "dlltool (fastcall export no leading underscore)"
124 }
125
126 if { "$target_xfail" == "yes" } {
127     setup_xfail *-*
128 }
129
130 verbose "$DLLTOOL --no-leading-underscore -p prefix -l tmpdir/libalias_nu.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" 1
131 catch "exec $DLLTOOL --no-leading-underscore -p prefix -l tmpdir/libalias_nu.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" err
132
133 if ![string match "" $err] then {
134     send_log "$err\n"
135     verbose "$err" 1
136     fail "dlltool -p (execution no leading underscore)"
137     continue
138 }
139
140 pass "dlltool -p (execution no leading underscore)"
141
142 set got [binutils_run $NM "tmpdir/libalias_nu.a"]
143 set want "00000000 I __imp_prefixsymbol.*00000000 T prefixsymbol.*00000000 I __imp_symbol.*00000000 T symbol"
144
145 if [regexp $want $got] then {
146     pass "dlltool -p (symbol names no leading underscore)"
147 } else {
148     fail "dlltool -p (symbol names no leading underscore)"
149 }
150
151 set got [binutils_run $OBJDUMP "-s -j .idata\$6 tmpdir/libalias_nu.a"]
152 set want "(Contents of section .idata\\\$6:.*\\.\\.symbol\\.\\..*){2,2}"
153
154 if [regexp $want $got] then {
155     pass "dlltool -p (import name no leading underscore)"
156 } else {
157     fail "dlltool -p (import name no leading underscore)"
158 }
159
160 verbose "$DLLTOOL --no-leading-underscore -p prefix -l tmpdir/libalias_nu2.a -d $srcdir/$subdir/alias-2.def $dlltool_gas_flag" 1
161 catch "exec $DLLTOOL --no-leading-underscore -p prefix -l tmpdir/libalias_nu2.a -d $srcdir/$subdir/alias-2.def $dlltool_gas_flag" err
162
163 if ![string match "" $err] then {
164     send_log "$err\n"
165     verbose "$err" 1
166     fail "dlltool -p (execution no leading underscore) alias-2.def"
167     continue
168 }
169
170 pass "dlltool -p (execution no leading underscore) alias-2.def"
171
172 set got [binutils_run $NM "tmpdir/libalias_nu2.a"]
173 set want "00000000 I __imp_prefixsymbol.*00000000 T prefixsymbol.*00000000 I __imp_symbol.*00000000 T symbol"
174
175 if [regexp $want $got] then {
176     pass "dlltool -p (symbol names no leading underscore) alias-2.def"
177 } else {
178     fail "dlltool -p (symbol names no leading underscore) alias-2.def"
179 }
180
181 set got [binutils_run $OBJDUMP "-s -j .idata\$6 tmpdir/libalias_nu2.a"]
182 set want "(Contents of section .idata\\\$6:.*\\.\\.something\\..*){2,2}"
183
184 if [regexp $want $got] then {
185     pass "dlltool -p (import name no leading underscore) alias-2.def"
186 } else {
187     fail "dlltool -p (import name no leading underscore) alias-2.def"
188 }
189
190 # Now we test with leading underscore
191 verbose "$DLLTOOL --leading-underscore -d $srcdir/$subdir/fastcall.def" 1
192 catch "exec $DLLTOOL --leading-underscore -d $srcdir/$subdir/fastcall.def" err
193
194 if ![string match "" $err] then {
195     send_log "$err\n"
196     verbose "$err" 1
197     fail "dlltool (fastcall export leading underscore)"
198 } else {
199     pass "dlltool (fastcall export leading underscore)"
200 }
201
202 if { "$target_xfail" == "yes" } {
203     setup_xfail *-*
204 }
205
206 verbose "$DLLTOOL --leading-underscore -p prefix -l tmpdir/libalias_u.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" 1
207 catch "exec $DLLTOOL --leading-underscore -p prefix -l tmpdir/libalias_u.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" err
208
209 if ![string match "" $err] then {
210     send_log "$err\n"
211     verbose "$err" 1
212     fail "dlltool -p (execution leading underscore)"
213     continue
214 }
215
216 pass "dlltool -p (execution leading-underscore)"
217
218 set got [binutils_run $NM "tmpdir/libalias_u.a"]
219 set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol"
220
221 if [regexp $want $got] then {
222     pass "dlltool -p (symbol names leading underscore)"
223 } else {
224     fail "dlltool -p (symbol names leading underscore)"
225 }
226
227 set got [binutils_run $OBJDUMP "-s -j .idata\$6 tmpdir/libalias_u.a"]
228 set want "(Contents of section .idata\\\$6:.*\\.\\.symbol\\..*){2,2}"
229
230 if [regexp $want $got] then {
231     pass "dlltool -p (import name leading underscore)"
232 } else {
233     fail "dlltool -p (import name leading underscore)"
234 }
235
236 verbose "$DLLTOOL --leading-underscore -p prefix -l tmpdir/libalias_u2.a -d $srcdir/$subdir/alias-2.def $dlltool_gas_flag" 1
237 catch "exec $DLLTOOL --leading-underscore -p prefix -l tmpdir/libalias_u2.a -d $srcdir/$subdir/alias-2.def $dlltool_gas_flag" err
238
239 if ![string match "" $err] then {
240     send_log "$err\n"
241     verbose "$err" 1
242     fail "dlltool -p (execution) alias-2.def"
243     continue
244 }
245
246 pass "dlltool -p (execution leading underscore) alias-2.def"
247
248 set got [binutils_run $NM "tmpdir/libalias_u2.a"]
249 set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol"
250
251 if [regexp $want $got] then {
252     pass "dlltool -p (symbol names leading underscore) alias-2.def"
253 } else {
254     fail "dlltool -p (symbol names leading underscore) alias-2.def"
255 }
256
257 set got [binutils_run $OBJDUMP "-s -j .idata\$6 tmpdir/libalias_u2.a"]
258 set want "(Contents of section .idata\\\$6:.*\\.\\.something\\..*){2,2}"
259
260 if [regexp $want $got] then {
261     pass "dlltool -p (import name leading underscore) alias-2.def"
262 } else {
263     fail "dlltool -p (import name leading underscore) alias-2.def"
264 }