1 # stresstest.at -- Libtool stress test -*- Autotest -*-
3 # Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4 # Written by Ralf Wildenhues, 2005
6 # This file is part of GNU Libtool.
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.
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.
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.
25 # Test various flag and option combinations.
26 # Test linkage against objects in various sections.
28 # Note: This test is experimental, and might be too strict for some systems.
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)='`
35 mkdir sub sub2 sub3 2>/dev/null
38 [[/* all kinds of data items */
46 extern const int v5, v6;
47 extern const char *v7;
48 extern const char v8[];
49 extern int (*const v12) (void);
52 const char* v7 = "\01foo";
53 const char v8[] = "\01bar";
54 int v9(void) { return v2 + 1; }
56 int (*v11) (void) = v9;
57 int (*const v12) (void) = v9;
59 typedef struct { int arr[1000]; } large;
61 large v14 = { { 0 } };
62 large v15 = { { 1 } };
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
101 #if !defined(LIBA_SCOPE)
102 # define LIBA_SCOPE extern
104 #if !defined(LIBA_SCOPE_VAR)
105 # define LIBA_SCOPE_VAR extern
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[];
116 LIBA_SCOPE_VAR int (*v10) (void);
117 LIBA_SCOPE_VAR int (*v11) (void);
118 LIBA_SCOPE int (*const v12) (void);
123 typedef struct { int arr[1000]; } large;
124 LIBA_SCOPE_VAR large v13, v14, v15;
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]
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
145 #if !defined(LIBA_SCOPE)
146 # define LIBA_SCOPE extern
148 #if !defined(LIBA_SCOPE_VAR)
149 # define LIBA_SCOPE_VAR extern
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[];
160 LIBA_SCOPE_VAR int (*v10) (void);
161 LIBA_SCOPE_VAR int (*v11) (void);
162 LIBA_SCOPE int (*const v12) (void);
164 typedef struct { int arr[1000]; } large;
165 LIBA_SCOPE_VAR large v13, v14, v15;
169 extern const int w5, w6;
170 extern const char* w7;
171 extern const char w8[];
173 extern int (*w10) (void);
174 extern int (*w11) (void);
175 extern int (*const w12) (void);
176 extern large w13, w14, w15;
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]
201 const char* w7 = "\01foo";
202 const char w8[] = "\01bar";
203 int w9(void) { return w2 + 1; }
205 int (*w11) (void) = w9;
206 int (*const w12) (void) = w9;
208 large w14 = { { 0 } };
209 large w15 = { { 1 } };
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])
246 case $allow_undefined_flag in
247 unsupported) undef_opts=-no-undefined ;;
248 *) undef_opts='"" -no-undefined' ;;
251 # expose problems with the regex:
254 for l1 in $undef_opts
256 for l2 in '' '-export-symbols-regex "v.*"' '-export-symbols asyms'
258 for l3 in '' '-rpath /nonexistent'
260 linkargs="$l1 $l2 $l3"
261 for rel in '' ./ `pwd`/
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'
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).
270 -static,*) mst=-static ;;
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'
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])