[PATCH v2 1/3] Add xorg-gtest integration test framework

Peter Hutterer peter.hutterer at who-t.net
Tue May 15 16:18:44 PDT 2012


On Tue, May 15, 2012 at 11:05:25AM -0700, Chase Douglas wrote:
> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
> ---
>  configure.ac                            |   21 +++++-
>  m4/xorg-gtest.m4                        |  110 +++++++++++++++++++++++++++++++
>  test/integration/Makefile-xorg-gtest.am |   61 +++++++++++++++++
>  test/integration/Makefile.am            |    4 ++
>  4 files changed, 195 insertions(+), 1 deletion(-)
>  create mode 100644 m4/xorg-gtest.m4
>  create mode 100644 test/integration/Makefile-xorg-gtest.am
>  create mode 100644 test/integration/Makefile.am
> 
> diff --git a/configure.ac b/configure.ac
> index 4afac82..fe350c9 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -35,7 +35,7 @@ AM_MAINTAINER_MODE
>  # Require xorg-macros minimum of 1.14 for XORG_COMPILER_BRAND in XORG_DEFAULT_OPTIONS
>  m4_ifndef([XORG_MACROS_VERSION],
>            [m4_fatal([must install xorg-macros 1.14 or later before running autoconf/autogen])])
> -XORG_MACROS_VERSION(1.14)
> +XORG_MACROS_VERSION(1.17)
>  XORG_DEFAULT_OPTIONS
>  XORG_WITH_DOXYGEN(1.6.1)
>  XORG_CHECK_SGML_DOCTOOLS(1.8)
> @@ -45,6 +45,7 @@ XORG_WITH_XMLTO(0.0.20)
>  XORG_WITH_FOP
>  XORG_WITH_XSLTPROC
>  XORG_ENABLE_UNIT_TESTS
> +XORG_ENABLE_INTEGRATION_TESTS
>  XORG_LD_WRAP([optional])
>  
>  m4_ifndef([XORG_FONT_MACROS_VERSION], [m4_fatal([must install fontutil 1.1 or later before running autoconf/autogen])])
> @@ -2123,6 +2124,23 @@ AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$XEPHYR" = xyes])
>  AM_CONDITIONAL(BUILD_KDRIVEFBDEVLIB, [test "x$KDRIVE" = xyes && test "x$KDRIVEFBDEVLIB" = xyes])
>  AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes])
>  
> +dnl ---------------------------------------------------------------------------
> +dnl Tests section.
> +dnl ---------------------------------------------------------------------------
> +
> +if [test "x$XORG" = xyes && test "x$enable_integration_tests" != xno]; then
> +    AC_PROG_CXX
> +    CHECK_XORG_GTEST
> +    AM_CONDITIONAL(ENABLE_XORG_GTEST_TESTS, [test "x$have_xorg_gtest" = xyes])
> +    if [test "x$have_xorg_gtest" = xyes]; then
> +        AC_MSG_NOTICE([xorg-gtest is available, tests will be built])
> +    elif [test "x$enable_integration_tests" = xyes]; then
> +        AC_MSG_ERROR([xorg-gtest is not available])
> +    else
> +        AC_MSG_NOTICE([xorg-gtest is not available, tests will not be built])
> +    fi
> +fi
> +
>  dnl and the rest of these are generic, so they're in config.h
>  dnl 
>  dnl though, thanks to the passing of some significant amount of time, the
> @@ -2255,6 +2273,7 @@ hw/kdrive/linux/Makefile
>  hw/kdrive/src/Makefile
>  test/Makefile
>  test/xi2/Makefile
> +test/integration/Makefile
>  xserver.ent
>  xorg-server.pc
>  ])
> diff --git a/m4/xorg-gtest.m4 b/m4/xorg-gtest.m4
> new file mode 100644
> index 0000000..52dd5aa
> --- /dev/null
> +++ b/m4/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"])

I've had a diff for this in my xorg-gtest tree (forgot to send it out,
sorry) that uses the include path from the source if one is given. Right
now, I have to specify source and include path, though both essentially
point to the right directory.

http://patchwork.freedesktop.org/patch/10339/

> +
> +  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

does anyone actually use the term "Linux input device recording playback"
instead of just calling it evemu?

> +                               (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"])

no AC_DEFINE for HAVE_EVEMU? that seems to be the traditional way
might be worth having a test-config.h.in for hese things

> +
> +  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/test/integration/Makefile-xorg-gtest.am b/test/integration/Makefile-xorg-gtest.am
> new file mode 100644
> index 0000000..185381d
> --- /dev/null
> +++ b/test/integration/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

-w? really?

Cheers,
  Peter

> +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/test/integration/Makefile.am b/test/integration/Makefile.am
> new file mode 100644
> index 0000000..e70d642
> --- /dev/null
> +++ b/test/integration/Makefile.am
> @@ -0,0 +1,4 @@
> +if ENABLE_XORG_GTEST_TESTS
> +include $(top_srcdir)/test/integration/Makefile-xorg-gtest.am
> +check_LIBRARIES = $(XORG_GTEST_BUILD_LIBS)
> +endif
> -- 
> 1.7.9.5
> 


More information about the xorg-devel mailing list