>From 02dce94738c3e8f2670d9997bf9e144ade8a7691 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Fri, 6 Dec 2013 09:43:26 +0100 Subject: [PATCH] tests: check mixing C program with C++ module. --- Makefile.am | 1 + tests/c-cpp.at | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 0 deletions(-) create mode 100755 tests/c-cpp.at diff --git a/Makefile.am b/Makefile.am index fe269ed..1d76d63 100644 --- a/Makefile.am +++ b/Makefile.am @@ -668,6 +668,7 @@ TESTSUITE_AT = tests/testsuite.at \ tests/template.at \ tests/ctor.at \ tests/exceptions.at \ + tests/c-cpp.at \ tests/early-libtool.at \ tests/no-executables.at \ tests/deplibs-ident.at \ diff --git a/tests/c-cpp.at b/tests/c-cpp.at new file mode 100755 index 0000000..825c55a --- /dev/null +++ b/tests/c-cpp.at @@ -0,0 +1,75 @@ +# c-cpp.at -- check mixing languages -*- Autotest -*- +# +# Copyright (C) 2013 Free Software Foundation, Inc. +# Written by Peter Rosin +# +# This file is part of GNU Libtool. +# +# GNU Libtool is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# GNU Libtool is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, +# or obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#### + + +AT_SETUP([mixing C and C++]) +LT_AT_TAG([CXX]) +AT_KEYWORDS([libtool]) + +AT_DATA(libcpp.cpp, +[[ +#include + +using namespace std; + +extern "C" int +hello(void) +{ + cout << "hello" << endl; + return 0; +} +]]) + +AT_DATA(cprog.c, +[[ +int hello(void); + +int +main(void) +{ + hello(); + return 0; +} +]]) + +LT_AT_HOST_DATA([expout], +[[hello +]]) + +AT_CHECK([$LIBTOOL --tag=CXX --mode=compile $CXX $CPPFLAGS $CXXFLAGS \ + -c libcpp.cpp -o libcpp.lo], [0], [ignore], [ignore]) +AT_CHECK([$LIBTOOL --tag=CC --mode=compile $CC $CPPFLAGS \ + -c cprog.c -o cprog.lo], [0], [ignore], [ignore]) + +AT_CHECK([$LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS \ + -no-undefined -module -rpath /somewhere \ + -o libcpp.la libcpp.lo], + [0], [ignore], [ignore]) +AT_CHECK([$LIBTOOL --tag=CC --mode=link $CC $CFLAGS $LDFLAGS \ + -o cprog$EXEEXT cprog.lo -dlpreopen libcpp.la], + [0], [ignore], [ignore]) + +LT_AT_NOINST_EXEC_CHECK([./cprog$EXEEXT], [-dlopen libcpp.la], [], [expout]) + +AT_CLEANUP -- 1.7.9