summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac34
-rw-r--r--examples/Makefile.am42
-rw-r--r--m4/gtest.m471
3 files changed, 121 insertions, 26 deletions
diff --git a/configure.ac b/configure.ac
index 1082886..40a97f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,21 +20,23 @@ AC_PROG_LIBTOOL
# Checks for programs.
AC_PROG_CXX
+AC_PROG_RANLIB
AC_LANG([C++])
-# Require X.Org macros 1.16 or later for XORG_TESTSET_CFLAG
+# Require X.Org macros 1.17 or later for XORG_ENABLE_INTEGRATION_TESTS
m4_ifndef([XORG_MACROS_VERSION],
- [m4_fatal([must install xorg-macros 1.16 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.16)
+ [m4_fatal([must install xorg-macros 1.17 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.17)
XORG_DEFAULT_OPTIONS
+XORG_ENABLE_INTEGRATION_TESTS([yes])
PKG_CHECK_MODULES(XSERVER, x11)
# Check for Google Test
-AC_CHECK_GTEST
+CHECK_GTEST
-AS_IF([test "x$ac_cv_lib_gtest_main" != xyes],
+AS_IF([test "x$have_gtest" != xyes],
AC_MSG_ERROR([package 'gtest' not found]))
AC_SUBST([GTEST_CPPFLAGS])
@@ -53,6 +55,28 @@ AS_IF([test "x$with_evemu" == xyes],
AM_CONDITIONAL([HAVE_EVEMU], [test "x$have_evemu" = "xyes"])
AS_IF([test "x$have_evemu" = xyes], [AC_DEFINE([HAVE_EVEMU])])
+# Check if we can build integration tests
+AS_IF([test "x$enable_integration_tests" != xno],
+ [AC_MSG_CHECKING([for X.org server])]
+ [PKG_CHECK_EXISTS([xorg-server],
+ [have_xorg_server=yes],
+ [have_xorg_server=no])]
+ [AC_MSG_RESULT([$have_xorg_server])])
+AS_IF([test "x$enable_integration_tests" = xyes -a \
+ "x$have_xorg_server" != xyes],
+ [AC_MSG_ERROR([X.org server required for integration tests])])
+
+AS_IF([test "x$have_xorg_server" = xyes],
+ [MODULES=`$PKG_CONFIG --variable=moduledir --print-errors xorg-server`
+ test "x$?" = "x0" && have_modules=yes])
+AS_IF([test "x$have_modules" = xyes],
+ [AC_CHECK_FILE([$MODULES/drivers/dummy_drv.so], [have_dummy_module=yes])])
+AS_IF([test "x$enable_integration_tests" = xyes -a \
+ "x$have_dummy_module" != xyes],
+ [AC_MSG_ERROR([X.org Dummy video driver required for integration tests])])
+
+AM_CONDITIONAL(ENABLE_XORG_GTEST_TESTS, [test "x$have_dummy_module" = xyes ])
+
AC_CONFIG_FILES([Makefile
data/Makefile
doc/Makefile
diff --git a/examples/Makefile.am b/examples/Makefile.am
index fcaca2b..5c41732 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -24,12 +24,44 @@
# SOFTWARE.
#
-noinst_PROGRAMS = xorg-gtest-example
+check_LIBRARIES = libgtest.a libxorg-gtest.a libxorg-gtest_main.a
-xorg_gtest_example_SOURCES = xorg-gtest-example.cpp
+AM_CPPFLAGS = $(GTEST_CPPFLAGS)
+AM_CXXFLAGS = $(XSERVER_CFLAGS) $(BASE_CXXFLAGS)
+
+nodist_libgtest_a_SOURCES = $(GTEST_SOURCE)/src/gtest-all.cc
+libgtest_a_CPPFLAGS = $(AM_CPPFLAGS) -w
+libgtest_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS)
+
+libxorg_gtest_a_SOURCES = $(top_srcdir)/src/xorg-gtest-all.cpp
+libxorg_gtest_a_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir) \
+ -DDUMMY_CONF_PATH="\"$(top_srcdir)/data/xorg/gtest/dummy.conf\""
+libxorg_gtest_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS)
+
+libxorg_gtest_main_a_SOURCES = $(top_srcdir)/src/xorg-gtest_main.cpp
+libxorg_gtest_main_a_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)
+libxorg_gtest_main_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS)
-AM_CPPFLAGS = -I$(top_srcdir)/include
-AM_CXXFLAGS = $(XSERVER_CFLAGS) $(GTEST_CPPFLAGS) $(BASE_CXXFLAGS)
+check_PROGRAMS = xorg-gtest-example
+
+if ENABLE_XORG_GTEST_TESTS
+TESTS = $(check_PROGRAMS)
+endif
+
+xorg_gtest_example_SOURCES = xorg-gtest-example.cpp
-xorg_gtest_example_LDADD = $(top_builddir)/src/libxorg-gtest.la $(top_builddir)/src/libxorg-gtest_main.la -lgtest -lpthread -lX11
+xorg_gtest_example_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/include
+xorg_gtest_example_LDADD = \
+ libgtest.a \
+ libxorg-gtest.a \
+ libxorg-gtest_main.a \
+ -lpthread \
+ $(XSERVER_LIBS) \
+ $(EVEMU_LIBS)
diff --git a/m4/gtest.m4 b/m4/gtest.m4
index cd41b21..2de334c 100644
--- a/m4/gtest.m4
+++ b/m4/gtest.m4
@@ -1,24 +1,63 @@
-# Checks whether the gtest library is available on the system
-# Allows for adjusting the include and library path.
-# Sets have_gtest=yes if the library is present and
-# reports the compiler and linker flags in
-# GTEST_CXXFLAGS AND GTEST_LDFLAGS, respectively.
-AC_DEFUN([AC_CHECK_GTEST],
+# Copyright (C) 2012 Canonical, Ltd.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+# Checks whether the gtest source is available on the system. Allows for
+# adjusting the include and source path. Sets have_gtest=yes if the source is
+# present. Sets GTEST_CPPFLAGS and GTEST_SOURCE to the preprocessor flags and
+# source location respectively.
+AC_DEFUN([CHECK_GTEST],
[
AC_ARG_WITH([gtest-include-path],
- [AS_HELP_STRING([--with-gtest-include-path],
- [location of the Google test headers, defaults to /usr/include])],
- [GTEST_CPPFLAGS="-I$withval"])
+ [AS_HELP_STRING([--with-gtest-include-path],
+ [location of the Google test headers])],
+ [GTEST_CPPFLAGS="-I$withval"])
+
+ AC_ARG_WITH([gtest-source-path],
+ [AS_HELP_STRING([--with-gtest-source-path],
+ [location of the Google test sources, defaults to /usr/src/gtest])],
+ [GTEST_SOURCE="$withval"],
+ [GTEST_SOURCE="/usr/src/gtest"])
+
+ GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE"
- AC_ARG_WITH([gtest-lib-path],
- [AS_HELP_STRING([--with-gtest-lib-path], [location of the Google test libraries])],
- [GTEST_LDFLAGS="-L$withval -lpthread"],
- [GTEST_LDFLAGS='-lpthread'])
+ AC_LANG_PUSH([C++])
- AC_LANG_PUSH(C++)
+ tmp_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $GTEST_CPPFLAGS"
- AC_CHECK_LIB([gtest], [main], [:], [:], [$GTEST_LDFLAGS])
+ AC_CHECK_HEADER([gtest/gtest.h])
+
+ CPPFLAGS="$tmp_CPPFLAGS"
AC_LANG_POP
-]) # AC_CHECK_GTEST
+ AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
+ [$GTEST_SOURCE/src/gtest_main.cc],
+ [have_gtest_source=yes],
+ [have_gtest_source=no])
+
+ AS_IF([test "x$ac_cv_header_gtest_gtest_h" = xyes -a \
+ "x$have_gtest_source" = xyes],
+ [have_gtest=yes]
+ [AC_SUBST(GTEST_CPPFLAGS)]
+ [AC_SUBST(GTEST_SOURCE)],
+ [have_gtest=no])
+]) # CHECK_GTEST