summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Douglas <chase.douglas@canonical.com>2012-03-08 14:51:40 -0800
committerChase Douglas <chase.douglas@canonical.com>2012-03-19 15:06:10 -0700
commit852b504288ca579a06b741b4588ee1b98b1b45f5 (patch)
treef331546bee53e40cb977d752acd68f7cc8f6564f
parent3f019e8272e33869312a7b5a94af94e14c81cd15 (diff)
Ship xorg-gtest.m4 and Makefile-xorg-gtest.am
See README for instructions on how to use them. Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
-rw-r--r--Makefile.am2
-rw-r--r--README72
-rw-r--r--aclocal/Makefile.am27
-rw-r--r--aclocal/xorg-gtest.m4110
-rw-r--r--configure.ac1
-rw-r--r--src/Makefile-xorg-gtest.am61
-rw-r--r--src/Makefile.am5
7 files changed, 272 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am
index 2542b44..8e0a0c6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,7 @@
# SOFTWARE.
#
-SUBDIRS = data doc include src examples
+SUBDIRS = aclocal data doc include src examples
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xorg-gtest.pc
diff --git a/README b/README
index 6b79f05..7a44075 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-X.Org dummy testing environment for Google Test
+X.Org GTest testing environment for Google Test
===============================================
Provides a Google Test environment for starting and stopping
@@ -7,6 +7,70 @@ environment is defined in header environment.h. Please refer to
the Google test documentation for information on how to add a custom
environment.
-Moreover, a custom main()-function that takes care of setting up the
-environment is provided in libxtestingenvironment_main.a. This library can be
-used as a replacement for libgtest_main.a
+Moreover, a custom main() function that takes care of setting up the
+environment is provided in xorg-gtest_main.cpp. This can be used as a
+replacement for libgtest_main.a
+
+Using X.org GTest in a project
+==============================
+
+The X.org GTest does not provide precompiled libraries. Each project must build
+the X.org GTest sources. To facilitate this, aclocal and automake include files
+are provided. Perform the following to integrate xorg-gtest into an autotools-
+based project.
+
+Add the following line to the top level Makefile.am for your project:
+
+ACLOCAL_AMFLAGS = -I m4 --install
+
+This will ensure the latest xorg-gtest.m4 macro installed on your system is
+copied into aclocal/. If a user runs autoreconf, they will already have the
+macro even if they don't have xorg-gtest installed.
+
+Call CHECK_XORG_GTEST from configure.ac This will set the value of
+$have_xorg_gtest and set $(XORG_GTEST_CPPFLAGS) and $(XORG_GTEST_CXXFLAGS).
+
+The last step is to modify your test automake rules for compiling and using
+xorg-gtest. There are two methods to do this: simplified or manual.
+
+Simplified
+----------
+
+This method requires less changes to your Makefile.am, but has a few drawbacks:
+
+* xorg-gtest is compiled only once. If you need multiple versions of xorg-gtest
+ or gtest compiled with different flags, you will need to use the manual
+ method.
+* The flags used to compile xorg-gtest must be the same as the flags used to
+ compile the tests. This means any flags other than XORG_GTEST_CPPFLAGS and
+ XORG_GTEST_CXXFLAGS must be provided through the AM_CPPFLAGS and AM_CXXFLAGS
+ variables.
+
+Copy Makefile-xorg-gtest.am into your project.
+
+In your test Makefile.am, add:
+
+include $(top_srcdir)/path/to/Makefile-xorg-gtest.am
+
+Append $(XORG_GTEST_BUILD_LIBS) to check_LIBRARIES.
+
+Append CPPFLAGS with $(XORG_GTEST_CPPFLAGS) and CXXFLAGS with
+$(XORG_GTEST_CXXFLAGS) for any testing source objects.
+
+Finally, link against $(XORG_GTEST_LIBS). If you want the xorg-gtest main()
+integration, link against $(XORG_GTEST_MAIN_LIBS) as well.
+
+Manual
+------
+
+This method is more flexible, but it requires the user to modify the Makefile.am
+file manually. It is recommended that the user be familiar with automake before
+attempting.
+
+Copy the contents of Makefile-xorg-gtest.am into your Makefile.am file. Adjust
+the compilation flags as needed, keeping in mind that all non-warning flags must
+match the flags used when compiling the test cases. Remove the gtest and/or
+xorg-gtest main() library targets if you will not use them. Copy the gtest and
+xorg-gtest library targets if multiple builds with different compilation flags
+are needed. Finally, link the tests with the appropriate gtest and xorg-gtest
+libraries and their dependencies: libpthread and libX11.
diff --git a/aclocal/Makefile.am b/aclocal/Makefile.am
new file mode 100644
index 0000000..3ea9969
--- /dev/null
+++ b/aclocal/Makefile.am
@@ -0,0 +1,27 @@
+#
+# Makefile for the src subdirectory of xorg-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.
+#
+
+aclocaldir = $(datadir)/aclocal
+dist_aclocal_DATA = xorg-gtest.m4
diff --git a/aclocal/xorg-gtest.m4 b/aclocal/xorg-gtest.m4
new file mode 100644
index 0000000..52dd5aa
--- /dev/null
+++ b/aclocal/xorg-gtest.m4
@@ -0,0 +1,110 @@
+# serial 1
+
+# 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])],
+ [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_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
+ [$GTEST_SOURCE/src/gtest_main.cc],
+ [have_gtest=yes],
+ [have_gtest=no])
+
+ AS_IF([test "x$have_gtest_source" = xyes],
+ [AC_SUBST(GTEST_CPPFLAGS)]
+ [AC_SUBST(GTEST_SOURCE)])
+]) # _CHECK_GTEST
+
+# CHECK_XORG_GTEST([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Checks whether the xorg-gtest source is available on the system. Allows for
+# adjusting the include and source path. Sets have_xorg_gtest=yes if the source
+# is present. Sets XORG_GTEST_CPPFLAGS and XORG_GTEST_SOURCE to the preprocessor
+# flags and source location respectively. Sets XORG_GTEST_LIBS to all the
+# libraries needed to link against a built xorg-gtest library.
+#
+# Both default actions are no-ops.
+AC_DEFUN([CHECK_XORG_GTEST],
+[
+ AC_REQUIRE([_CHECK_GTEST])
+
+ PKG_CHECK_EXISTS([xorg-gtest],
+ [have_xorg_gtest=yes],
+ [have_xorg_gtest=no])
+
+ XORG_GTEST_SOURCE=`$PKG_CONFIG --variable=sourcedir --print-errors xorg-gtest`
+ XORG_GTEST_CPPFLAGS=`$PKG_CONFIG --variable=CPPflags --print-errors xorg-gtest`
+ XORG_GTEST_CPPFLAGS="$GTEST_CPPFLAGS $XORG_GTEST_CPPFLAGS"
+ XORG_GTEST_CPPFLAGS="$XORG_GTEST_CPPFLAGS -I$XORG_GTEST_SOURCE"
+
+ PKG_CHECK_MODULES(X11, [x11], [have_x11=yes], [have_x11=no])
+
+ # Check if we should include support for utouch-evemu
+ AC_ARG_WITH([evemu],
+ [AS_HELP_STRING([--with-evemu],
+ [support Linux input device recording playback
+ (default: enabled if available)])],
+ [],
+ [with_evemu=check])
+
+ AS_IF([test "x$with_evemu" = xyes],
+ [PKG_CHECK_MODULES(EVEMU, [utouch-evemu], [have_xorg_gtest_evemu=yes])],
+ [test "x$with_evemu" = xcheck],
+ [PKG_CHECK_MODULES(EVEMU,
+ [utouch-evemu],
+ [have_xorg_gtest_evemu=yes],
+ [have_xorg_gtest_evemu=no])])
+ AS_IF([test "x$have_xorg_gtest_evemu" = xyes],
+ [XORG_GTEST_CPPFLAGS="$XORG_GTEST_CPPFLAGS -DHAVE_EVEMU"])
+
+ AS_IF([test "x$have_gtest" != xyes -o "x$have_x11" != xyes],
+ [have_xorg_gtest=no])
+
+ AS_IF([test "x$have_xorg_gtest" = xyes],
+ [AC_SUBST(XORG_GTEST_SOURCE)]
+ [AC_SUBST(XORG_GTEST_CPPFLAGS)]
+
+ # Get BASE_CXXFLAGS and STRICT_CXXFLAGS
+ [XORG_MACROS_VERSION(1.17)]
+ [AC_LANG_PUSH([C++])]
+ [XORG_STRICT_OPTION]
+ [AC_LANG_POP]
+ [$1],
+ [$2])
+
+]) # CHECK_XORG_GTEST
diff --git a/configure.ac b/configure.ac
index 37a6dc0..2d70801 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,6 +74,7 @@ AS_IF([test "x$enable_integration_tests" = xyes -a \
AM_CONDITIONAL(ENABLE_XORG_GTEST_TESTS, [test "x$have_dummy_module" = xyes ])
AC_CONFIG_FILES([Makefile
+ aclocal/Makefile
data/Makefile
doc/Makefile
examples/Makefile
diff --git a/src/Makefile-xorg-gtest.am b/src/Makefile-xorg-gtest.am
new file mode 100644
index 0000000..185381d
--- /dev/null
+++ b/src/Makefile-xorg-gtest.am
@@ -0,0 +1,61 @@
+# 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.
+#
+
+XORG_GTEST_BUILD_LIBS = \
+ libgtest.a \
+ libgtest_main.a \
+ libxorg-gtest.a \
+ libxorg-gtest_main.a
+
+nodist_libgtest_a_SOURCES = $(GTEST_SOURCE)/src/gtest-all.cc
+libgtest_a_CPPFLAGS = $(GTEST_CPPFLAGS) $(AM_CPPFLAGS) -w
+libgtest_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS)
+
+nodist_libgtest_main_a_SOURCES = $(GTEST_SOURCE)/src/gtest_main.cc
+libgtest_main_a_CPPFLAGS = $(GTEST_CPPFLAGS) $(AM_CPPFLAGS) -w
+libgtest_main_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS)
+
+nodist_libxorg_gtest_a_SOURCES = $(XORG_GTEST_SOURCE)/src/xorg-gtest-all.cpp
+libxorg_gtest_a_CPPFLAGS = \
+ $(XORG_GTEST_CPPFLAGS) \
+ $(GTEST_CPPFLAGS) \
+ $(AM_CPPFLAGS) \
+ -w
+libxorg_gtest_a_CXXFLAGS = \
+ $(XORG_GTEST_CXXFLAGS) \
+ $(GTEST_CXXFLAGS) \
+ $(AM_CPPFLAGS)
+
+nodist_libxorg_gtest_main_a_SOURCES = \
+ $(XORG_GTEST_SOURCE)/src/xorg-gtest_main.cpp
+libxorg_gtest_main_a_CPPFLAGS = \
+ $(XORG_GTEST_CPPFLAGS) \
+ $(GTEST_CPPFLAGS) \
+ $(AM_CPPFLAGS) \
+ -w
+libxorg_gtest_main_a_CXXFLAGS = \
+ $(XORG_GTEST_CXXFLAGS) \
+ $(GTEST_CXXFLAGS) \
+ $(AM_CXXFLAGS)
+
+XORG_GTEST_LIBS = libxorg-gtest.a libgtest.a -lpthread $(X11_LIBS)
+XORG_GTEST_MAIN_LIBS = libxorg-gtest_main.a
diff --git a/src/Makefile.am b/src/Makefile.am
index c5a8413..148f1f2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,4 +35,7 @@ libxorg_gtest_main_sources = \
xorg-gtest_main.cpp
srcinstalldir = $(prefix)/src/xorg-gtest/src
-dist_srcinstall_DATA = $(libxorg_gtest_sources) $(libxorg_gtest_main_sources)
+dist_srcinstall_DATA = \
+ Makefile-xorg-gtest.am \
+ $(libxorg_gtest_sources) \
+ $(libxorg_gtest_main_sources)