1 # lt_dlopen.at -- test libltdl functionality -*- Autotest -*-
3 # Copyright (C) 2009 Free Software Foundation, Inc.
4 # This file is part of GNU Libtool.
6 # GNU Libtool is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; either version 2 of
9 # the License, or (at your option) any later version.
11 # GNU Libtool is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Libtool; see the file COPYING. If not, a copy
18 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
19 # or obtained by writing to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 AT_SETUP([lt_dlopen error messages])
24 AT_KEYWORDS([libltdl])
26 # The bug is not fixed:
29 # This test only works if the system allows undefined symbols.
30 eval `$LIBTOOL --config | grep '^allow_undefined_flag='`
31 AT_CHECK([test unsupported != "$allow_undefined_flag" || exit 77])
38 main (int argc, char* argv[])
41 lt_dlhandle plugin_handle;
45 fprintf (stderr, "usage: %s plugin\n", argv[0]);
50 plugin_handle = lt_dlopenext (argv[1]);
51 if (NULL != plugin_handle)
53 printf ("plugin opened successfully!\n");
54 lt_dlclose (plugin_handle);
58 printf ("plugin failed to open: %s\n", lt_dlerror());
66 AT_DATA([good-plugin.c],
71 AT_DATA([missing-symbol-plugin.c],
72 [[/* On systems that allow undefined symbols, this will compile,
73 but the symbol "foo" won't be found at runtime */
78 : ${LTDLINCL="-I$abs_top_srcdir/libltdl"}
79 : ${LIBLTDL="$abs_builddir/../libltdl/libltdlc.la"}
81 CPPFLAGS="$LTDLINCL $CPPFLAGS"
85 AT_CHECK([$CC $CPPFLAGS $CFLAGS -c main.c], [], [ignore], [ignore])
86 for file in good-plugin.c missing-symbol-plugin.c; do
87 AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c $file],
88 [], [ignore], [ignore])
90 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o good-plugin.la -rpath $libdir ]dnl
91 [-module -avoid-version good-plugin.lo], [], [ignore], [ignore])
92 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o missing-symbol-plugin.la -rpath $libdir]dnl
93 [-module -avoid-version missing-symbol-plugin.lo], [], [ignore], [ignore])
95 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT ]dnl
96 [-dlopen good-plugin.la -dlopen missing-symbol-plugin.la $LIBLTDL],
97 [], [ignore], [ignore])
99 LT_AT_EXEC_CHECK([./main], [], [ignore], [ignore], [./good-plugin.la])
100 LT_AT_EXEC_CHECK([./main], [1], [ignore], [stderr], [./missing-symbol-plugin.la])
101 AT_CHECK([grep 'missing symbol' stderr], [], [ignore])