]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test: implement GLib-style "installed tests"
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 26 Jan 2015 15:47:22 +0000 (15:47 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 3 Feb 2015 16:19:01 +0000 (16:19 +0000)
We run each test twice:

* once with the system's session.conf, as an integration test
  (test-cases that need a special configuration are automatically
  skipped)
* once with our special test configuration files, which provide better
  coverage

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
configure.ac
test/Makefile.am

index c7616a905d08d8bf75005dabef7177967768c45d..b9b3ce3c6fce2cedad5a364e6efd87ea53d02b40 100644 (file)
@@ -1816,6 +1816,7 @@ echo "
         Building modular tests:   ${enable_modular_tests}
             - with GLib:          ${with_glib}
             - with dbus-glib:     ${with_dbus_glib}
+        Installing tests:         ${enable_installed_tests}
         Building verbose mode:    ${enable_verbose_mode}
         Building assertions:      ${enable_asserts}
         Building checks:          ${enable_checks}
index 294291bbe3301d1e4ffd75930dc1883197a3ae98..ec761605aa7cd62432c2d51fb629b2b45ccc2a2a 100644 (file)
@@ -136,9 +136,11 @@ manual_tcp_LDADD = $(top_builddir)/dbus/libdbus-internal.la
 
 EXTRA_DIST = dbus-test-runner
 
-testexecdir = $(libdir)/dbus-1.0/test
+testexecdir = $(libexecdir)/installed-tests/dbus
+testmetadir = $(datadir)/installed-tests/dbus
 
 testexec_PROGRAMS =
+testmeta_DATA =
 
 installable_tests = \
        test-shell \
@@ -166,6 +168,9 @@ installable_manual_tests += \
        $(NULL)
 endif DBUS_WITH_GLIB
 
+installable_test_meta = $(installable_tests:=.test)
+installable_test_meta_with_config = $(installable_tests:=_with_config.test)
+
 installcheck_tests =
 installcheck_environment = \
        XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR \
@@ -241,6 +246,9 @@ installcheck_tests += $(installable_tests)
 
 if DBUS_ENABLE_INSTALLED_TESTS
   testexec_PROGRAMS += $(installable_tests) $(installable_manual_tests)
+
+  testmeta_DATA += $(installable_test_meta)
+  testmeta_DATA += $(installable_test_meta_with_config)
 else !DBUS_ENABLE_INSTALLED_TESTS
   noinst_PROGRAMS += $(installable_tests) $(installable_manual_tests)
 endif !DBUS_ENABLE_INSTALLED_TESTS
@@ -414,14 +422,19 @@ install-data-local: install-config-local
 
 install-config-local: installable-config-local
 if DBUS_ENABLE_INSTALLED_TESTS
-       $(AM_V_gen)set -e; \
+       $(AM_V_GEN)set -e; \
        for F in $(static_data); do \
-               install -m644 "$(srcdir)/$$F" "$(testexecdir)/$$F"; \
-       done
+               install -d "$(DESTDIR)$(testexecdir)/$${F%/*}"; \
+               install -m644 "$(srcdir)/$$F" "$(DESTDIR)$(testexecdir)/$$F"; \
+       done; \
        for F in $(in_data); do \
-               install -d "$${F%/*}";
-               install -m644 "installable/$${F%.in}" "$(testexecdir)/$${F%.in}"; \
+               install -d "$(DESTDIR)$(testexecdir)/$${F%/*}"; \
+               install -m644 "installable/$${F%.in}" "$(DESTDIR)$(testexecdir)/$${F%.in}"; \
        done
+       ln -nfs $(sysconfdir)/dbus-1/session.conf $(DESTDIR)$(testexecdir)/data/valid-config-files/session.conf
+       ln -nfs $(sysconfdir)/dbus-1/session.d $(DESTDIR)$(testexecdir)/data/valid-config-files/session.d
+       ln -nfs $(sysconfdir)/dbus-1/system.conf $(DESTDIR)$(testexecdir)/data/valid-config-files/system.conf
+       ln -nfs $(sysconfdir)/dbus-1/system.d $(DESTDIR)$(testexecdir)/data/valid-config-files/system.d
 else
        @:
 endif
@@ -452,3 +465,17 @@ CLEANFILES = \
 $(imported_data): data/valid-config-files/%.conf: $(top_builddir)/bus/%.conf
        $(AM_V_at)$(MKDIR_P) data/valid-config-files
        $(AM_V_GEN)cp $< $@
+
+$(installable_test_meta): %.test: % Makefile
+       $(AM_V_GEN) ( \
+               echo '[Test]'; \
+               echo 'Type=session'; \
+               echo 'Exec=env DBUS_TEST_HOME=$$(pwd)/home.tmp $(testexecdir)/$*'; \
+       ) > $@.tmp && mv $@.tmp $@
+
+$(installable_test_meta_with_config): %_with_config.test: % Makefile
+       $(AM_V_GEN) ( \
+               echo '[Test]'; \
+               echo 'Type=session'; \
+               echo 'Exec=env DBUS_TEST_HOME=$$(pwd)/home.tmp DBUS_TEST_DATA=$(testexecdir)/data $(testexecdir)/$*'; \
+       ) > $@.tmp && mv $@.tmp $@