resetting manifest requested domain to floor
[platform/upstream/libtool.git] / tests / stresstest.at
1 # stresstest.at -- Libtool stress test                       -*- Autotest -*-
2 #
3 #   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4 #   Written by Ralf Wildenhues, 2005
5 #
6 #   This file is part of GNU Libtool.
7 #
8 # GNU Libtool is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of
11 # the License, or (at your option) any later version.
12 #
13 # GNU Libtool is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Libtool; see the file COPYING.  If not, a copy
20 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
21 # or obtained by writing to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ####
24
25 # Test various flag and option combinations.
26 # Test linkage against objects in various sections.
27
28 # Note: This test is experimental, and might be too strict for some systems.
29
30 AT_BANNER([Libtool stress test.])
31 AT_SETUP([Link option thorough search test])
32 AT_KEYWORDS([libtool])
33 eval `$LIBTOOL --config | $EGREP '^(CC|objdir|allow_undefined_flag)='`
34
35 mkdir sub sub2 sub3 2>/dev/null
36
37 AT_DATA(a.c,
38 [[/* all kinds of data items */
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 int v1;
43 static int v2;
44 int v3 = 0;
45 int v4 = 1;
46 extern const int v5, v6;
47 extern const char *v7;
48 extern const char v8[];
49 extern int (*const v12) (void);
50 const int v5 = 0;
51 const int v6 = 1;
52 const char* v7 = "\01foo";
53 const char v8[] = "\01bar";
54 int v9(void) { return v2 + 1; }
55 int (*v10) (void);
56 int (*v11) (void) = v9;
57 int (*const v12) (void) = v9;
58
59 typedef struct { int arr[1000]; } large;
60 large v13;
61 large v14 = { { 0 } };
62 large v15 = { { 1 } };
63 #ifdef __cplusplus
64 }
65 #endif
66 ]])
67
68 AT_DATA(asyms,
69 [[v1
70 v3
71 v4
72 v5
73 v6
74 v7
75 v8
76 v9
77 v10
78 v11
79 v12
80 v13
81 v14
82 v15
83 ]])
84
85 AT_DATA(b.c,
86 [[int b = 42;
87 int b3 = 1;
88 int ab = 1;
89 ]])
90
91 AT_DATA(main.c,
92 [[
93 #if defined(LIBA_DLL_IMPORT)
94 #  if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__)
95 #    define LIBA_SCOPE extern __declspec(dllimport)
96 #    if defined(_MSC_VER)
97 #      define LIBA_SCOPE_VAR LIBA_SCOPE
98 #    endif
99 #  endif
100 #endif
101 #if !defined(LIBA_SCOPE)
102 #  define LIBA_SCOPE extern
103 #endif
104 #if !defined(LIBA_SCOPE_VAR)
105 #  define LIBA_SCOPE_VAR extern
106 #endif
107 #ifdef __cplusplus
108 extern "C" {
109 #endif
110 LIBA_SCOPE_VAR int v1;
111 LIBA_SCOPE_VAR int v3, v4;
112 LIBA_SCOPE const int v5, v6;
113 LIBA_SCOPE_VAR const char* v7;
114 LIBA_SCOPE_VAR const char v8[];
115 extern int v9(void);
116 LIBA_SCOPE_VAR int (*v10) (void);
117 LIBA_SCOPE_VAR int (*v11) (void);
118 LIBA_SCOPE int (*const v12) (void);
119 #ifdef __cplusplus
120 }
121 #endif
122
123 typedef struct { int arr[1000]; } large;
124 LIBA_SCOPE_VAR large v13, v14, v15;
125
126 int main(void)
127 {
128   char s = v7[0] + v8[0];
129   return s + v1 + v3 + v4 + v5 + v6 + v9() + v11() + v12()
130            + v13.arr[0] + v14.arr[0] + v15.arr[0]
131            - 8;
132 }
133 ]])
134
135 AT_DATA(dlself.c,
136 [[
137 #if defined(LIBA_DLL_IMPORT)
138 #  if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__)
139 #    define LIBA_SCOPE extern __declspec(dllimport)
140 #    if defined(_MSC_VER)
141 #      define LIBA_SCOPE_VAR LIBA_SCOPE
142 #    endif
143 #  endif
144 #endif
145 #if !defined(LIBA_SCOPE)
146 #  define LIBA_SCOPE extern
147 #endif
148 #if !defined(LIBA_SCOPE_VAR)
149 #  define LIBA_SCOPE_VAR extern
150 #endif
151 #ifdef __cplusplus
152 extern "C" {
153 #endif
154 LIBA_SCOPE_VAR int v1;
155 LIBA_SCOPE_VAR int v3, v4;
156 LIBA_SCOPE const int v5, v6;
157 LIBA_SCOPE_VAR const char* v7;
158 LIBA_SCOPE_VAR const char v8[];
159 extern int v9(void);
160 LIBA_SCOPE_VAR int (*v10) (void);
161 LIBA_SCOPE_VAR int (*v11) (void);
162 LIBA_SCOPE int (*const v12) (void);
163
164 typedef struct { int arr[1000]; } large;
165 LIBA_SCOPE_VAR large v13, v14, v15;
166
167 extern int w1;
168 extern int w3, w4;
169 extern const int w5, w6;
170 extern const char* w7;
171 extern const char w8[];
172 extern int w9(void);
173 extern int (*w10) (void);
174 extern int (*w11) (void);
175 extern int (*const w12) (void);
176 extern large w13, w14, w15;
177 #ifdef __cplusplus
178 }
179 #endif
180
181 int main(void)
182 {
183   char s = v7[0] + v8[0] + w7[0] + w8[0];
184   return s + v1 + v3 + v4 + v5 + v6 + v9() + v11() + v12()
185            + v13.arr[0] + v14.arr[0] + v15.arr[0]
186            + w1 + w3 + w4 + w5 + w6 + w9() + w11() + w12()
187            + w13.arr[0] + w14.arr[0] + w15.arr[0]
188            - 16;
189 }
190
191
192 #ifdef __cplusplus
193 extern "C" {
194 #endif
195 int w1;
196 static int w2;
197 int w3 = 0;
198 int w4 = 1;
199 const int w5 = 0;
200 const int w6 = 1;
201 const char* w7 = "\01foo";
202 const char w8[] = "\01bar";
203 int w9(void) { return w2 + 1; }
204 int (*w10) (void);
205 int (*w11) (void) = w9;
206 int (*const w12) (void) = w9;
207 large w13;
208 large w14 = { { 0 } };
209 large w15 = { { 1 } };
210 #ifdef __cplusplus
211 }
212 #endif
213 ]])
214
215 AT_DATA(dlselfsyms,
216 [[w1
217 w3
218 w4
219 w5
220 w6
221 w7
222 w8
223 w9
224 w10
225 w11
226 w12
227 w13
228 w14
229 w15
230 ]])
231
232
233 AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c -o sub/a.lo],
234          [0],[ignore],[ignore])
235 AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c b.c -o sub/b.lo],
236          [0],[ignore],[ignore])
237 AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS -DLIBA_DLL_IMPORT $CFLAGS -c main.c],
238          [0],[ignore],[ignore])
239 AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c main.c -o main-static.lo],
240          [0],[ignore],[ignore])
241 AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS -DLIBA_DLL_IMPORT $CFLAGS -c dlself.c -o sub3/dlself.lo],
242          [0],[ignore],[ignore])
243 AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c dlself.c -o sub3/dlself-static.lo],
244          [0],[ignore],[ignore])
245
246 case $allow_undefined_flag in
247   unsupported) undef_opts=-no-undefined ;;
248   *)           undef_opts='"" -no-undefined' ;;
249 esac
250
251 # expose problems with the regex:
252 touch vfoo v.bar
253
254 for l1 in $undef_opts
255 do
256   for l2 in '' '-export-symbols-regex "v.*"' '-export-symbols asyms'
257   do
258     for l3 in '' '-rpath /nonexistent'
259     do
260       linkargs="$l1 $l2 $l3"
261       for rel in '' ./ `pwd`/
262       do
263         LT_AT_CHECK([eval '$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o "$rel"sub2/liba.la "$rel"sub/a.lo' $linkargs],
264                  [0],[ignore],[ignore])
265         for st in '' '-static' '-no-install'
266         do
267           # if -static is not passed, and the library is shared, then we have
268           # to use -DLIBA_DLL_IMPORT, thus main.lo (and not main-static.lo).
269           case $st,$l3 in
270           -static,*) mst=-static ;;
271           *,-rpath*) mst= ;;
272           *) mst=-static ;;
273           esac
274
275           LT_AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $st -o "$rel"main$EXEEXT "$rel"main$mst.lo "$rel"sub2/liba.la],
276                    [0],[ignore],[ignore])
277           LT_AT_EXEC_CHECK([./main],[0])
278           for l10 in '' '-export-symbols dlselfsyms'
279           do
280             LT_AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $st -o "$rel"sub3/dlself$EXEEXT "$rel"sub3/dlself$mst.lo "$rel"sub2/liba.la sub/b.lo -dlopen self $l10],
281                      [0],[ignore],[ignore])
282             LT_AT_EXEC_CHECK([./sub3/dlself],[0])
283           done
284         done
285       done
286     done
287   done
288 done
289
290 AT_CLEANUP