diff options
author | Alban Crequy <alban.crequy@collabora.co.uk> | 2011-10-04 16:57:03 +0100 |
---|---|---|
committer | Alban Crequy <alban.crequy@collabora.co.uk> | 2011-11-04 16:44:25 +0000 |
commit | e745c29573950efcb7ffd7c0b6184582c4365c05 (patch) | |
tree | b4fe4824eb2e7f9b32863e3ce7c58026708ab2b3 | |
parent | 45b8e51b72b95646ad855807d0b0f9d89737edf1 (diff) |
tests: add --enable-installed-tests
This configure option makes it possible to install the tests in
/usr/lib/telepathy-glib-tests and run them without the sources.
The dbus configuration moved to tests/dbus/dbus-installed for the installed
tests and is duplicated into tests/dbus/dbus-uninstalled for the uninstalled
tests.
https://bugs.freedesktop.org/show_bug.cgi?id=41455
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | configure.ac | 20 | ||||
-rw-r--r-- | tests/Makefile.am | 28 | ||||
-rw-r--r-- | tests/dbus/Makefile.am | 69 | ||||
-rw-r--r-- | tests/dbus/dbus-installed/services/spurious.service (renamed from tests/dbus/dbus-1/services/spurious.service) | 0 | ||||
-rw-r--r-- | tests/dbus/dbus-installed/session.conf.in (renamed from tests/dbus/dbus-1/session.conf.in) | 3 | ||||
-rw-r--r-- | tests/dbus/dbus-uninstalled/services/spurious.service | 3 | ||||
-rw-r--r-- | tests/dbus/dbus-uninstalled/session.conf.in | 29 | ||||
-rw-r--r-- | tests/dbus/run-test.sh.in | 32 | ||||
-rw-r--r-- | tools/Makefile.am | 10 |
10 files changed, 180 insertions, 22 deletions
@@ -76,12 +76,16 @@ stamp-h1 tags /telepathy-glib-0.* /telepathy-glib/tmp-introspect*/ -tests/dbus/dbus-1/session.conf +tests/dbus/dbus-installed/session.conf +tests/dbus/dbus-uninstalled/session.conf +tests/dbus/run-test.sh tests/dbus/test-* +tests/dbus/tpglib-dbus-tests.list tests/test-* /tests/tools/actual.h /tests/tools/actual-body.h /tests/tools/actual-gtk-doc.h +tests/tpglib-tests.list tools/telepathy-glib-env /vala/telepathy-glib-generated.gi /vala/telepathy-glib.files @@ -90,4 +94,4 @@ tools/telepathy-glib-env /valgrind.log capture-*.log .\#* -\#*\#
\ No newline at end of file +\#*\# diff --git a/configure.ac b/configure.ac index fd775084..8621ad28 100644 --- a/configure.ac +++ b/configure.ac @@ -170,17 +170,35 @@ fi AC_SUBST(COVERAGE_CFLAGS) +AC_ARG_ENABLE([installed-tests], + AC_HELP_STRING([--enable-installed-tests], + [make tests installable]), + [installed_tests=$enableval], [installed_tests=no]) + +if test x$installed_tests = xyes; then + AC_DEFINE(ENABLE_INSTALLED_TESTS, [], + [Make tests installable]) +fi +AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], [test "x$installed_tests" = xyes]) + AC_ARG_ENABLE([installed-examples], AC_HELP_STRING([--enable-installed-examples], [install examples as well as the library]), [enable_installed_examples="$enableval"], - [enable_installed_examples=no]) + [enable_installed_examples=$installed_tests]) AM_CONDITIONAL([INSTALL_EXAMPLES], [test "$enable_installed_examples" = yes]) +if test x$installed_tests = xyes -a x$enable_installed_examples != xyes; then + AC_MSG_ERROR([examples must be installed when tests are installed.]) +fi + dnl docs/Makefile.am needs to know whether it's an out of tree build dnl (srcdir != builddir) AM_CONDITIONAL([OUT_OF_TREE_BUILD], [test "z$ac_srcdir" != z.]) +tpglibtestsdir=${libdir}/telepathy-glib-tests +AC_SUBST(tpglibtestsdir) + dnl Check for Glib PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.28.0, gobject-2.0 >= 2.28.0, gio-2.0 >= 2.28.0]) diff --git a/tests/Makefile.am b/tests/Makefile.am index 88e4fc89..63abac55 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,7 +4,7 @@ SUBDIRS = \ dbus \ tools -noinst_PROGRAMS = \ +programs_list = \ test-asv \ test-capabilities \ test-availability-cmp \ @@ -17,9 +17,26 @@ noinst_PROGRAMS = \ test-signal-connect-object \ test-util \ test-debug-domain \ - test-contact-search-result + test-contact-search-result \ + $(NULL) + +if HAVE_CXX +programs_list += \ + test-util-cxx +endif -TESTS = $(noinst_PROGRAMS) \ +if ENABLE_INSTALLED_TESTS +testsdir = @tpglibtestsdir@ +tests_PROGRAMS = $(programs_list) +tests_DATA = tpglib-tests.list +else +noinst_PROGRAMS = $(programs_list) +endif + +tpglib-tests.list: + $(AM_V_GEN)echo $(programs_list) > $@ + +TESTS = $(programs_list) \ all-errors-documented.py TESTS_ENVIRONMENT = \ @@ -44,7 +61,7 @@ VALGRIND_TESTS_ENVIRONMENT = \ check-valgrind: $(MAKE) check-TESTS \ maybe_gc_friendly=,gc-friendly \ - TESTS='$$(noinst_PROGRAMS)' \ + TESTS='$$(programs_list)' \ TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" $(MAKE) -C dbus check-valgrind @@ -137,8 +154,5 @@ AM_CFLAGS = $(ERROR_CFLAGS) AM_CXXFLAGS = $(ERROR_CXXFLAGS) if HAVE_CXX -noinst_PROGRAMS += \ - test-util-cxx - test_util_cxx_SOURCES = util-cxx.cpp endif diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am index e72718f6..048f841c 100644 --- a/tests/dbus/Makefile.am +++ b/tests/dbus/Makefile.am @@ -1,4 +1,4 @@ -noinst_PROGRAMS = \ +tests_list = \ test-account \ test-account-channel-request \ test-account-manager \ @@ -60,7 +60,26 @@ noinst_PROGRAMS = \ test-text-respawn \ test-unsupported-interface -TESTS = $(noinst_PROGRAMS) +if ENABLE_INSTALLED_TESTS +managersdir = @tpglibtestsdir@/telepathy/managers/ +managers_DATA = \ + telepathy/managers/spurious.manager \ + telepathy/managers/test_manager_file_invalid.manager \ + telepathy/managers/test_manager_file.manager \ + $(NULL) + +testsdir = @tpglibtestsdir@ +tests_PROGRAMS = $(tests_list) +tests_SCRIPTS = run-test.sh +tests_DATA = tpglib-dbus-tests.list +else +noinst_PROGRAMS = $(tests_list) +endif + +TESTS = $(tests_list) + +tpglib-dbus-tests.list: + $(AM_V_GEN)echo $(tests_list) > $@ LDADD = \ $(top_builddir)/tests/lib/libtp-glib-tests.la \ @@ -256,7 +275,7 @@ TESTS_ENVIRONMENT = \ G_DEBUG=fatal_warnings,fatal_criticals$(maybe_gc_friendly) \ $(top_srcdir)/tools/test-wrapper.sh \ sh $(top_srcdir)/tools/with-session-bus.sh \ - --config-file=dbus-1/session.conf -- \ + --config-file=dbus-uninstalled/session.conf -- \ $(EXTRA_TESTS_ENVIRONMENT) EXTRA_TESTS_ENVIRONMENT = @@ -275,10 +294,13 @@ VALGRIND_TESTS_ENVIRONMENT = \ $(VALGRIND) --suppressions=$(top_srcdir)/tests/tests.supp $(VALGRIND_FLAGS) BUILT_SOURCES = \ - dbus-1/session.conf \ + dbus-installed/session.conf \ + dbus-uninstalled/session.conf \ _gen/errors-check.h \ _gen/svc.h \ - _gen/svc.c + _gen/svc.c \ + run-test.sh \ + $(NULL) CLEANFILES = \ $(BUILT_SOURCES) @@ -288,17 +310,44 @@ distclean-local: rm -rf _gen EXTRA_DIST = \ - dbus-1/session.conf.in \ - dbus-1/services/spurious.service \ + dbus-installed/session.conf.in \ + dbus-installed/services/spurious.service \ + dbus-uninstalled/session.conf.in \ + dbus-uninstalled/services/spurious.service \ telepathy/managers/spurious.manager \ telepathy/managers/test_manager_file.manager \ telepathy/managers/test_manager_file_invalid.manager \ - with-properties.xml + with-properties.xml \ + run-test.sh.in \ + $(NULL) + +run-test.sh: run-test.sh.in + $(AM_V_GEN)sed \ + -e "s|[@]tpglibtestsdir[@]|@tpglibtestsdir@|g" \ + -e "s|[@]libexec[@]|${libexecdir}|g" \ + $< > $@ + @chmod +x $@ -dbus-1/%.conf: $(srcdir)/dbus-1/%.conf.in - $(AM_V_at)$(mkdir_p) dbus-1 +dbus-uninstalled/%.conf: $(srcdir)/dbus-uninstalled/%.conf.in + $(AM_V_at)$(mkdir_p) dbus-uninstalled $(AM_V_GEN)sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" $< > $@ +dbus-installed/%.conf: $(srcdir)/dbus-installed/%.conf.in + $(AM_V_at)$(mkdir_p) dbus-installed + $(AM_V_GEN)sed -e "s|[@]tpglibtestsdir[@]|@tpglibtestsdir@|g" $< > $@ + +service_files = dbus-installed/services/spurious.service +conf_in_files = dbus-installed/session.conf.in +conf_files = $(conf_in_files:.conf.in=.conf) + +if ENABLE_INSTALLED_TESTS +dbusservicedir = @tpglibtestsdir@/dbus-installed/services +dbusservice_DATA = $(service_files) + +dbusconfigdir = @tpglibtestsdir@/dbus-installed +dbusconfig_DATA = $(conf_files) +endif + _gen/svc.c _gen/svc.h: with-properties.xml \ $(top_srcdir)/tools/glib-ginterface-gen.py \ Makefile.am diff --git a/tests/dbus/dbus-1/services/spurious.service b/tests/dbus/dbus-installed/services/spurious.service index d0d70aa0..d0d70aa0 100644 --- a/tests/dbus/dbus-1/services/spurious.service +++ b/tests/dbus/dbus-installed/services/spurious.service diff --git a/tests/dbus/dbus-1/session.conf.in b/tests/dbus/dbus-installed/session.conf.in index 52fe1801..313c653d 100644 --- a/tests/dbus/dbus-1/session.conf.in +++ b/tests/dbus/dbus-installed/session.conf.in @@ -12,7 +12,7 @@ <listen>unix:tmpdir=/tmp</listen> - <servicedir>@abs_top_builddir@/tests/dbus/dbus-1/services/</servicedir> + <servicedir>@tpglibtestsdir@/dbus-installed/services/</servicedir> <policy context="default"> <!-- Allow everything to be sent --> @@ -26,5 +26,4 @@ <!-- This is included last so local configuration can override what's in this standard file --> - </busconfig> diff --git a/tests/dbus/dbus-uninstalled/services/spurious.service b/tests/dbus/dbus-uninstalled/services/spurious.service new file mode 100644 index 00000000..d0d70aa0 --- /dev/null +++ b/tests/dbus/dbus-uninstalled/services/spurious.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.freedesktop.Telepathy.ConnectionManager.spurious +Exec=/bin/false diff --git a/tests/dbus/dbus-uninstalled/session.conf.in b/tests/dbus/dbus-uninstalled/session.conf.in new file mode 100644 index 00000000..fcb73274 --- /dev/null +++ b/tests/dbus/dbus-uninstalled/session.conf.in @@ -0,0 +1,29 @@ +<!-- Copied from telepathy-gabble (which doubtless copied it from somewhere + else) and modified. + This configuration file controls the per-user-login-session message bus. + Add a session-local.conf and edit that rather than changing this + file directly. --> + +<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> +<busconfig> + <!-- Our well-known bus type, don't change this --> + <type>session</type> + + <listen>unix:tmpdir=/tmp</listen> + + <servicedir>@abs_top_builddir@/tests/dbus/dbus-installed/services/</servicedir> + + <policy context="default"> + <!-- Allow everything to be sent --> + <allow send_destination="*" eavesdrop="true"/> + <!-- Allow everything to be received --> + <allow eavesdrop="true"/> + <!-- Allow anyone to own anything --> + <allow own="*"/> + </policy> + + <!-- This is included last so local configuration can override what's + in this standard file --> + +</busconfig> diff --git a/tests/dbus/run-test.sh.in b/tests/dbus/run-test.sh.in new file mode 100644 index 00000000..2e9648f0 --- /dev/null +++ b/tests/dbus/run-test.sh.in @@ -0,0 +1,32 @@ +#!/bin/sh + +script_fullname=`readlink -e "@tpglibtestsdir@/run-test.sh"` +if [ `readlink -e "$0"` != "$script_fullname" ] ; then + echo "This script is meant to be installed at $script_fullname" + exit 1 +fi + +XDG_DATA_DIRS=@tpglibtestsdir@:$XDG_DATA_DIRS +export XDG_DATA_DIRS +G_SLICE=debug-blocks +export G_SLICE +G_DEBUG=fatal_warnings,fatal_criticals +export G_DEBUG +libexec=@libexec@ +export libexec + +if [ -n "$1" ] ; then + list="$1" +else + echo "Usage: $0 testname" + exit 1 +fi + +for i in $list ; do + echo "Testing $i" + @tpglibtestsdir@/tools/test-wrapper.sh \ + sh @tpglibtestsdir@/tools/with-session-bus.sh \ + --config-file=@tpglibtestsdir@/dbus-installed/session.conf \ + -- @tpglibtestsdir@/$i +done + diff --git a/tools/Makefile.am b/tools/Makefile.am index 96cc60f5..2f99e025 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -6,6 +6,16 @@ telepathy-glib-env: telepathy-glib-env.in Makefile sed -e 's![@]abs_top_builddir[@]!$(abs_top_builddir)!' $< > $@ chmod +x $@ +if ENABLE_INSTALLED_TESTS +toolsdir = @tpglibtestsdir@/tools +tools_SCRIPTS = \ + with-session-bus.sh \ + test-wrapper.sh \ + libglibcodegen.py \ + libtpcodegen.py \ + $(NULL) +endif + EXTRA_DIST = \ c-constants-gen.py \ check-coding-style.mk \ |