summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-01-19 10:59:03 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-01-31 09:11:56 +1000
commit4bc52aba794c3054535e0c2af174b26144d39002 (patch)
tree7b63fcc23660ba28829623991f9e6e389a6080a7 /configure.ac
parent23ed0b11c24582caa6465c8fa083e8e830ce6a75 (diff)
downloadxf86-input-wacom-4bc52aba794c3054535e0c2af174b26144d39002.tar.gz
Add a testing framework for the driver.
This uses glib's testing framework provided glib-devel was available at configure time (same as the X server's testing framework). How this works: The wacom driver is recompiled for the testing framework and linked into the wacom-tests binary (there's a warning about that but ignore that). Since the .so uses a number of symbols from the Xorg binary, these are provided as stubs in fake-symbols.c. Additional binaries can be added through the check_PROGRAMS automake variable. The driver will be rebuild without static symbols for the test, allowing each function call to be tested. To run the tests, run 'make check'. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Ping Cheng <pinglinux@gmail.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac54
1 files changed, 54 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index c8296aa..45d1d89 100644
--- a/configure.ac
+++ b/configure.ac
@@ -98,6 +98,59 @@ AC_ARG_WITH([xorg-conf-dir],
[configdir="$sysconfigdir"])
AC_SUBST(configdir)
AM_CONDITIONAL(HAS_XORG_CONF_DIR, [test "x$sysconfigdir" != "x"])
+
+# enalbe unit-tests if glib-devel is available
+AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
+ [Enable unit-tests (default: auto)]),
+ [UNITTESTS=$enableval],
+ [UNITTESTS=auto])
+
+# If unittests aren't explicitly disabled, check for required support
+if test "x$UNITTESTS" != xno ; then
+ PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.16],
+ [HAVE_GLIB=yes], [HAVE_GLIB=no])
+
+ # Check if linker supports -wrap, passed via compiler flags
+ # When cross-compiling, reports no, since unit tests run from
+ # "make check", so would be running on build machine, not target
+ AC_MSG_CHECKING([whether the linker supports -wrap])
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -Wl,-wrap,exit"
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+ void __wrap_exit (int s)
+ {
+ __real_exit (0);
+ }]],
+ [[exit (1);]])],
+ [linker_can_wrap="yes"],
+ [linker_can_wrap="no"],
+ [linker_can_wrap="no"])
+ AC_MSG_RESULT([$linker_can_wrap])
+ LDFLAGS="$save_LDFLAGS"
+fi
+
+if test "x$UNITTESTS" = xauto; then
+ if test "x$HAVE_GLIB" = xyes && test "x$linker_can_wrap" = xyes; then
+ UNITTESTS=yes
+ else
+ UNITTESTS=no
+ fi
+fi
+if test "x$UNITTESTS" = xyes; then
+ if test "x$HAVE_GLIB" = xno; then
+ AC_MSG_ERROR([glib required to build unit tests])
+ fi
+ if test "x$linker_can_wrap" = xno; then
+ AC_MSG_ERROR([ld -wrap support required to build unit tests])
+ fi
+ AC_DEFINE(UNITTESTS, 1, [Enable unit tests])
+ AC_SUBST([GLIB_LIBS])
+ AC_SUBST([GLIB_CFLAGS])
+fi
+AM_CONDITIONAL(UNITTESTS, [test "x$UNITTESTS" = xyes])
+
+
+
# -----------------------------------------------------------------------------
AC_CONFIG_FILES([Makefile
@@ -106,5 +159,6 @@ AC_CONFIG_FILES([Makefile
man/Makefile
include/Makefile
tools/Makefile
+ test/Makefile
xorg-wacom.pc])
AC_OUTPUT