1 # lalib-syntax.at -- parsing .la files robustly -*- Autotest -*-
3 # Copyright (C) 2009-2019, 2021-2024 Free Software Foundation, Inc.
5 # This file is part of GNU Libtool.
7 # GNU Libtool is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of
10 # the License, or (at your option) any later version.
12 # GNU Libtool is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Libtool; see the file COPYING. If not, a copy
19 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
20 # or obtained by writing to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 AT_SETUP([syntax of .la files])
25 AT_KEYWORDS([libtool])
26 AT_KEYWORDS([libltdl])
28 AT_XFAIL_IF([:]) dnl libltdl does not consistently return non-NULL lt_dlerror
36 main (int argc, char* argv[])
39 lt_dlhandle plugin_handle;
43 fprintf (stderr, "usage: %s plugin\n", argv[0]);
48 plugin_handle = lt_dlopenext (argv[1]);
49 if (NULL != plugin_handle)
51 printf ("plugin opened successfully!\n");
52 lt_dlclose (plugin_handle);
56 const char *error = lt_dlerror ();
57 assert (error != NULL);
58 printf ("plugin failed to open: %s\n", error);
67 [[int foo (void) { return 0; }
70 : ${LTDLINCL="-I$abs_top_srcdir/libltdl"}
71 : ${LIBLTDL="$abs_builddir/../libltdl/libltdlc.la"}
73 # Skip this test when called from:
74 # make distcheck DISTCHECK_CONFIGURE_FLAGS=--disable-ltdl-install
75 AT_CHECK([case $LIBLTDL in #(
76 */_inst/lib/*) test -f "$LIBLTDL" || (exit 77) ;;
79 CPPFLAGS="$CPPFLAGS $LTDLINCL"
81 AT_CHECK([$CC $CPPFLAGS $CFLAGS -c main.c], [], [ignore], [ignore])
82 AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c module.c],
83 [], [ignore], [ignore])
84 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o module.la module.lo ]dnl
85 [-module -avoid-version -rpath /somewhere], [], [ignore], [ignore])
86 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT $LIBLTDL],
87 [], [ignore], [ignore])
90 # Several bogus test cases.
92 AT_DATA([missing-closing-quote.la],
93 [[# missing-closing-quote.la - a libtool library file
94 # Generated by libtool
96 library_names='module.so module.so module.so'
97 old_library='module.a'
103 AT_DATA([wrong-quotes.la],
104 [[# wrong-quotes.la - a libtool library file
105 # Generated by libtool
107 library_names='module.so module.so module.so'
108 old_library='module.a'
114 AT_DATA([no-dlname.la],
115 [[# no-dlname.la - a libtool library file
116 # Generated by libtool
122 AT_DATA([nonexistent-dlname.la],
123 [[# nonexistent-dlname.la - a libtool library file
124 # Generated by libtool
125 dlname='does-not-exist.so'
131 for file in ./missing-closing-quote.la ./wrong-quotes.la \
132 ./no-dlname.la ./nonexistent-dlname.la; do
133 LT_AT_EXEC_CHECK([./main], [1], [stdout], [ignore], [$file])
134 AT_CHECK([$GREP 'plugin failed to open' stdout], [], [ignore])