summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-03-04 14:41:37 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-03-04 14:41:37 +0000
commit705971b509e1c60419444f228825533080c4ae34 (patch)
treef8cf8010084a274eed80e7b2049d7b8a1dbc4105
parent49611f121fa10d1497e46ab9aa6a7448cb89cd86 (diff)
downloadlibguestfs-705971b509e1c60419444f228825533080c4ae34.tar.gz
libguestfs-705971b509e1c60419444f228825533080c4ae34.tar.xz
libguestfs-705971b509e1c60419444f228825533080c4ae34.zip
Test header file under C++.
-rw-r--r--.gitignore1
-rw-r--r--configure.ac7
-rw-r--r--tests/c-api/Makefile.am14
-rw-r--r--tests/c-api/test-just-header-cxx.cpp34
4 files changed, 56 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 785e763b..db2ba9d1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -360,6 +360,7 @@ tests/c-api/test-create-handle
tests/c-api/test-debug-to-file
tests/c-api/test*.img
tests/c-api/test-just-header
+tests/c-api/test-just-header-cxx
tests/c-api/test-last-errno
tests/c-api/test.log
tests/c-api/test-private-data
diff --git a/configure.ac b/configure.ac
index 1eb94922..0a2e6629 100644
--- a/configure.ac
+++ b/configure.ac
@@ -686,6 +686,13 @@ AS_IF([test "x$enable_fuse" != "xno"],
AC_MSG_WARN([FUSE library and headers are missing, so optional FUSE module won't be built])])])
AM_CONDITIONAL([HAVE_FUSE],[test "x$enable_fuse" != "xno"])
+dnl Check for C++ (optional, we just use this to test the header works).
+AC_PROG_CXX
+
+dnl The C++ compiler test is pretty useless because even if it fails
+dnl it sets CXX=g++. So test the compiler actually works.
+AM_CONDITIONAL([HAVE_CXX], [$CXX --version])
+
dnl Check for OCaml (optional, for OCaml bindings).
OCAMLC=no
OCAMLFIND=no
diff --git a/tests/c-api/Makefile.am b/tests/c-api/Makefile.am
index 2ba31066..d5b605d8 100644
--- a/tests/c-api/Makefile.am
+++ b/tests/c-api/Makefile.am
@@ -46,6 +46,11 @@ TESTS = \
test-user-cancel \
test-debug-to-file
+if HAVE_CXX
+check_PROGRAMS += test-just-header-cxx
+TESTS += test-just-header-cxx
+endif
+
# The API behind this test is not baked yet.
#if HAVE_LIBVIRT
#check_PROGRAMS += test-add-libvirt-dom
@@ -82,6 +87,15 @@ test_just_header_CFLAGS = \
test_just_header_LDADD = \
$(top_builddir)/src/libguestfs.la
+if HAVE_CXX
+test_just_header_cxx_SOURCES = test-just-header-cxx.cpp
+test_just_header_cxx_CXXFLAGS = \
+ -I$(top_srcdir)/src -I$(top_builddir)/src \
+ $(WARN_CFLAGS) $(WERROR_CFLAGS)
+test_just_header_cxx_LDADD = \
+ $(top_builddir)/src/libguestfs.la
+endif
+
test_create_handle_SOURCES = test-create-handle.c
test_create_handle_CFLAGS = \
-I$(top_srcdir)/src -I$(top_builddir)/src \
diff --git a/tests/c-api/test-just-header-cxx.cpp b/tests/c-api/test-just-header-cxx.cpp
new file mode 100644
index 00000000..fc6a8c43
--- /dev/null
+++ b/tests/c-api/test-just-header-cxx.cpp
@@ -0,0 +1,34 @@
+/* libguestfs
+ * Copyright (C) 2010 Red Hat Inc.
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __cplusplus
+#error "this test should be compiled with a C++ compiler"
+#endif
+
+/* Check that just including the header and nothing else works, ie.
+ * that there are no implicit dependencies in the header file.
+ */
+
+#include "guestfs.h"
+
+int
+main (int argc, char *argv[])
+{
+ guestfs_h *g = guestfs_create ();
+ return 0;
+}