[Pkg-telepathy-commits] [telepathy-glib] 03/111: Port unit tests to g_test_dbus_up/down

Simon McVittie smcv at debian.org
Wed Mar 19 18:07:22 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository telepathy-glib.

commit bfb21c309bcae17f74a27ac9435b4cbbdf1be767
Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Wed Apr 11 16:31:56 2012 +0200

    Port unit tests to g_test_dbus_up/down
    
    https://bugs.freedesktop.org/show_bug.cgi?id=55761
---
 configure.ac                                       |   6 +-
 tests/dbus/Makefile.am                             |  33 ++-----
 tests/dbus/account-channel-request.c               |   2 +-
 tests/dbus/account-manager.c                       |   2 +-
 tests/dbus/account-request.c                       |   2 +-
 tests/dbus/account.c                               |   2 +-
 tests/dbus/base-client.c                           |   2 +-
 tests/dbus/call-channel.c                          |   2 +-
 tests/dbus/channel-dispatch-operation.c            |   2 +-
 tests/dbus/channel-dispatcher.c                    |   2 +-
 tests/dbus/channel-manager-request-properties.c    |   2 +-
 tests/dbus/channel-request.c                       |   2 +-
 tests/dbus/channel.c                               |   2 +-
 tests/dbus/client-channel-factory.c                |   2 +-
 tests/dbus/client.c                                |   2 +-
 tests/dbus/cm-message.c                            |   2 +-
 tests/dbus/cm.c                                    |   2 +-
 tests/dbus/connection-aliasing.c                   |   2 +-
 tests/dbus/connection-balance.c                    |   2 +-
 tests/dbus/connection-error.c                      |   2 +-
 tests/dbus/connection-interests.c                  |   2 +-
 tests/dbus/connection.c                            |   2 +-
 tests/dbus/contact-list-client.c                   |   2 +-
 tests/dbus/contact-lists.c                         |   2 +-
 tests/dbus/contacts-slow-path.c                    |   2 +-
 tests/dbus/contacts.c                              |   2 +-
 .../services/spurious.service                      |   0
 tests/dbus/dbus-installed/session.conf.in          |  29 ------
 tests/dbus/dbus-tube.c                             |   2 +-
 .../dbus-uninstalled/services/spurious.service     |   3 -
 tests/dbus/dbus-uninstalled/session.conf.in        |  29 ------
 tests/dbus/dbus.c                                  |   2 +-
 tests/dbus/debug-client.c                          |   2 +-
 tests/dbus/error-enum.c                            |   4 +-
 tests/dbus/file-transfer-channel.c                 |   2 +-
 tests/dbus/get-interface-after-invalidate.c        |   2 +-
 tests/dbus/long-connection-name.c                  |   3 +
 tests/dbus/params-cm.c                             |   2 +-
 tests/dbus/properties.c                            |   2 +-
 tests/dbus/protocol-objects.c                      |   2 +-
 tests/dbus/proxy-preparation.c                     |   2 +-
 tests/dbus/room-list.c                             |   2 +-
 tests/dbus/run-test.sh.in                          |  13 ++-
 tests/dbus/self-handle.c                           |   2 +-
 tests/dbus/simple-approver.c                       |   2 +-
 tests/dbus/simple-handler.c                        |   2 +-
 tests/dbus/simple-observer.c                       |   2 +-
 tests/dbus/stream-tube.c                           |   2 +-
 tests/dbus/text-channel.c                          |   2 +-
 tests/dbus/tls-certificate.c                       |   2 +-
 tests/dbus/unsupported-interface.c                 |   2 +-
 tests/lib/util.c                                   |  62 +++++++++++-
 tests/lib/util.h                                   |   2 +
 tools/Makefile.am                                  |   2 -
 tools/with-session-bus.sh                          | 106 ---------------------
 55 files changed, 130 insertions(+), 246 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7dcf69d..1071ec5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -198,11 +198,11 @@ AC_SUBST(tpglibtestsdir)
 
 dnl Check for Glib
 PKG_CHECK_MODULES(GLIB,
-  [glib-2.0 >= 2.32.0, gobject-2.0 >= 2.32.0, gio-2.0 >= 2.32.0])
+  [glib-2.0 >= 2.34.0, gobject-2.0 >= 2.34.0, gio-2.0 >= 2.34.0])
 
 dnl MIN_REQUIRED must stay to 2.30 because of GValueArray
-AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_30], [Ignore post 2.32 deprecations])
-AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_32], [Prevent post 2.32 APIs])
+AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_30], [Ignore post 2.30 deprecations])
+AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_34], [Prevent post 2.34 APIs])
 
 dnl Check for GIO-Unix
 PKG_CHECK_MODULES(GIO_UNIX, [gio-unix-2.0],
diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index e446645..b03c612 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -287,9 +287,11 @@ TESTS_ENVIRONMENT = \
     G_SLICE=debug-blocks \
     G_DEBUG=fatal_warnings,fatal_criticals$(maybe_gc_friendly) \
     G_MESSAGES_DEBUG=all \
+    GIO_USE_VFS=local \
+    GSETTINGS_BACKEND=memory \
+    TP_TESTS_SERVICES_DIR=@abs_srcdir@/dbus-1/services \
+    DBUS_SESSION_BUS_ADDRESS=this-is-clearly-not-valid \
     $(top_srcdir)/tools/test-wrapper.sh \
-    sh $(top_srcdir)/tools/with-session-bus.sh \
-        --config-file=dbus-uninstalled/session.conf -- \
     $(EXTRA_TESTS_ENVIRONMENT)
 
 EXTRA_TESTS_ENVIRONMENT =
@@ -308,8 +310,6 @@ VALGRIND_TESTS_ENVIRONMENT = \
     $(VALGRIND) --suppressions=$(top_srcdir)/tests/tests.supp $(VALGRIND_FLAGS)
 
 BUILT_SOURCES = \
-	dbus-installed/session.conf \
-	dbus-uninstalled/session.conf \
 	_gen/errors-check.h \
 	_gen/svc.h \
 	_gen/svc.c \
@@ -324,10 +324,7 @@ distclean-local:
 	rm -rf _gen
 
 EXTRA_DIST = \
-    dbus-installed/session.conf.in \
-    dbus-installed/services/spurious.service \
-    dbus-uninstalled/session.conf.in \
-    dbus-uninstalled/services/spurious.service \
+    services/dbus-1/spurious.service \
     telepathy/managers/spurious.manager \
     telepathy/managers/test_manager_file.manager \
     telepathy/managers/test_manager_file_invalid.manager \
@@ -342,27 +339,11 @@ run-test.sh: run-test.sh.in
 		$< > $@
 	@chmod +x $@
 
-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" \
-		-e "s|[@]abs_top_srcdir[@]|@abs_top_srcdir@|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)
+service_files = services/dbus-1/spurious.service
 
 if ENABLE_INSTALLED_TESTS
-dbusservicedir = @tpglibtestsdir@/dbus-installed/services
+dbusservicedir = @tpglibtestsdir@/dbus-1/services
 dbusservice_DATA = $(service_files)
-
-dbusconfigdir = @tpglibtestsdir@/dbus-installed
-dbusconfig_DATA = $(conf_files)
 endif
 
 _gen/svc.h: _gen/svc.c
diff --git a/tests/dbus/account-channel-request.c b/tests/dbus/account-channel-request.c
index 0de180b..7016338 100644
--- a/tests/dbus/account-channel-request.c
+++ b/tests/dbus/account-channel-request.c
@@ -1298,5 +1298,5 @@ main (int argc,
   g_test_add ("/account-channels/test-ft-props", Test, NULL,
       setup, test_ft_props, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/account-manager.c b/tests/dbus/account-manager.c
index 22de1c5..092933e 100644
--- a/tests/dbus/account-manager.c
+++ b/tests/dbus/account-manager.c
@@ -813,5 +813,5 @@ main (int argc,
               test_most_available_one_unset, teardown_service);
   g_test_add ("/am/most-available/two-unset", Test, NULL, setup_service,
               test_most_available_two_unset, teardown_service);
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/account-request.c b/tests/dbus/account-request.c
index bc3b7d2..055be2e 100644
--- a/tests/dbus/account-request.c
+++ b/tests/dbus/account-request.c
@@ -566,5 +566,5 @@ main (int argc,
   g_test_add ("/account-request/create-fail", Test, NULL, setup,
       test_create_fail, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/account.c b/tests/dbus/account.c
index b921f40..75d4710 100644
--- a/tests/dbus/account.c
+++ b/tests/dbus/account.c
@@ -975,5 +975,5 @@ main (int argc,
   g_test_add ("/account/addressing", Test, "later", setup_service,
       test_addressing, teardown_service);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/base-client.c b/tests/dbus/base-client.c
index 8433915..a4de836 100644
--- a/tests/dbus/base-client.c
+++ b/tests/dbus/base-client.c
@@ -1605,5 +1605,5 @@ main (int argc,
   g_test_add ("/cd/delegate-to-preferred-handler/supported", Test, NULL,
       setup, test_delegate_to_preferred_handler_supported, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/call-channel.c b/tests/dbus/call-channel.c
index 4e12a05..810c0f4 100644
--- a/tests/dbus/call-channel.c
+++ b/tests/dbus/call-channel.c
@@ -1086,5 +1086,5 @@ main (int argc,
   g_test_add ("/call/dtmf", Test, NULL, setup, test_dtmf,
       teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/channel-dispatch-operation.c b/tests/dbus/channel-dispatch-operation.c
index 31410ca..90406cf 100644
--- a/tests/dbus/channel-dispatch-operation.c
+++ b/tests/dbus/channel-dispatch-operation.c
@@ -945,5 +945,5 @@ main (int argc,
   g_test_add ("/cdo/destroy-channels", Test, NULL, setup_services,
       test_destroy_channels, teardown_services);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/channel-dispatcher.c b/tests/dbus/channel-dispatcher.c
index 94bc68e..b789226 100644
--- a/tests/dbus/channel-dispatcher.c
+++ b/tests/dbus/channel-dispatcher.c
@@ -74,5 +74,5 @@ main (int argc,
   /* tp_channel_dispatcher_present_channel_async() is tested in
    * test-base-client */
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/channel-manager-request-properties.c b/tests/dbus/channel-manager-request-properties.c
index 5a5ecf3..69aaa39 100644
--- a/tests/dbus/channel-manager-request-properties.c
+++ b/tests/dbus/channel-manager-request-properties.c
@@ -221,5 +221,5 @@ main (int argc,
   g_test_add ("/channel-manager-request-properties/target-id", Test, NULL, setup,
       test_target_id, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/channel-request.c b/tests/dbus/channel-request.c
index c09d939..7cb7ca0 100644
--- a/tests/dbus/channel-request.c
+++ b/tests/dbus/channel-request.c
@@ -440,5 +440,5 @@ main (int argc,
       test_immutable_properties, teardown);
   g_test_add ("/cr/properties", Test, NULL, setup, test_properties, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/channel.c b/tests/dbus/channel.c
index 0cec683..593681e 100644
--- a/tests/dbus/channel.c
+++ b/tests/dbus/channel.c
@@ -707,5 +707,5 @@ main (int argc,
   g_test_add ("/channel/contacts", Test, NULL, setup,
       test_contacts, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/client-channel-factory.c b/tests/dbus/client-channel-factory.c
index a3cbb26..92668ab 100644
--- a/tests/dbus/client-channel-factory.c
+++ b/tests/dbus/client-channel-factory.c
@@ -267,5 +267,5 @@ main (int argc,
   g_test_add ("/client-channel-factory/auto/dup", Test, NULL, setup,
       test_auto_dup, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/client.c b/tests/dbus/client.c
index 2bde19c..9146f4f 100644
--- a/tests/dbus/client.c
+++ b/tests/dbus/client.c
@@ -73,5 +73,5 @@ main (int argc,
 
   g_test_add ("/client/new", Test, NULL, setup, test_new, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/cm-message.c b/tests/dbus/cm-message.c
index 5e504b3..2c0f56d 100644
--- a/tests/dbus/cm-message.c
+++ b/tests/dbus/cm-message.c
@@ -341,5 +341,5 @@ main (int argc,
   g_test_add (TEST_PREFIX "take_message", Test, NULL, setup,
       test_take_message, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/cm.c b/tests/dbus/cm.c
index cd62488..3888277 100644
--- a/tests/dbus/cm.c
+++ b/tests/dbus/cm.c
@@ -1191,5 +1191,5 @@ main (int argc,
   g_test_add ("/cm/list", Test, GINT_TO_POINTER (USE_OLD_LIST),
       setup, test_list, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/connection-aliasing.c b/tests/dbus/connection-aliasing.c
index 3b5e6f8..ddadab8 100644
--- a/tests/dbus/connection-aliasing.c
+++ b/tests/dbus/connection-aliasing.c
@@ -161,5 +161,5 @@ main (int argc,
   g_test_add ("/conn/aliasing/user-set", Test, NULL,
       setup, test_user_set, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/connection-balance.c b/tests/dbus/connection-balance.c
index 4d022ab..b247e14 100644
--- a/tests/dbus/connection-balance.c
+++ b/tests/dbus/connection-balance.c
@@ -398,5 +398,5 @@ main (int argc,
       GSIZE_TO_POINTER (TP_TESTS_TYPE_SIMPLE_CONNECTION),
       setup, test_balance_unknown, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/connection-error.c b/tests/dbus/connection-error.c
index 1ade331..3d2e561 100644
--- a/tests/dbus/connection-error.c
+++ b/tests/dbus/connection-error.c
@@ -395,5 +395,5 @@ main (int argc,
   g_test_add ("/connection/detailed-error-vardict", Test, "variant", setup,
       test_detailed_error, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/connection-interests.c b/tests/dbus/connection-interests.c
index c850e55..7ffbda6 100644
--- a/tests/dbus/connection-interests.c
+++ b/tests/dbus/connection-interests.c
@@ -397,5 +397,5 @@ main (int argc,
   g_test_add ("/conn/interested-client", Test, NULL, setup,
       test_interested_client, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/connection.c b/tests/dbus/connection.c
index 0d26311..51a8872 100644
--- a/tests/dbus/connection.c
+++ b/tests/dbus/connection.c
@@ -446,5 +446,5 @@ main (int argc,
   g_test_add ("/conn/object_path", Test, NULL, setup,
       test_object_path, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/contact-list-client.c b/tests/dbus/contact-list-client.c
index 943645c..a3f878a 100644
--- a/tests/dbus/contact-list-client.c
+++ b/tests/dbus/contact-list-client.c
@@ -580,5 +580,5 @@ main (int argc,
   g_test_add ("/contact-list-client/contact-list/properties", Test,
       GUINT_TO_POINTER (TRUE), setup, test_contact_list_properties, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/contact-lists.c b/tests/dbus/contact-lists.c
index b97e693..f072ef7 100644
--- a/tests/dbus/contact-lists.c
+++ b/tests/dbus/contact-lists.c
@@ -2906,5 +2906,5 @@ main (int argc,
   g_test_add ("/contact-lists/download",
       Test, NULL, setup, test_download_contacts, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/contacts-slow-path.c b/tests/dbus/contacts-slow-path.c
index b7094c0..8c8b749 100644
--- a/tests/dbus/contacts-slow-path.c
+++ b/tests/dbus/contacts-slow-path.c
@@ -1297,5 +1297,5 @@ main (int argc,
   g_test_add ("/contacts-slow-path/one-by-id", Fixture, NULL, setup,
       test_one_by_id, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/contacts.c b/tests/dbus/contacts.c
index 9c070a7..9a4e9cc 100644
--- a/tests/dbus/contacts.c
+++ b/tests/dbus/contacts.c
@@ -3070,7 +3070,7 @@ main (int argc,
   g_test_add ("/contacts/self-contact", Fixture, NULL,
       setup_no_connect, test_self_contact, teardown);
 
-  ret = g_test_run ();
+  ret = tp_tests_run_with_bus ();
 
   g_assert (haze_remove_directory (dir));
   g_free (dir);
diff --git a/tests/dbus/dbus-installed/services/spurious.service b/tests/dbus/dbus-1/services/spurious.service
similarity index 100%
rename from tests/dbus/dbus-installed/services/spurious.service
rename to tests/dbus/dbus-1/services/spurious.service
diff --git a/tests/dbus/dbus-installed/session.conf.in b/tests/dbus/dbus-installed/session.conf.in
deleted file mode 100644
index 313c653..0000000
--- a/tests/dbus/dbus-installed/session.conf.in
+++ /dev/null
@@ -1,29 +0,0 @@
-<!-- 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>@tpglibtestsdir@/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/dbus-tube.c b/tests/dbus/dbus-tube.c
index ae9c831..90e5e44 100644
--- a/tests/dbus/dbus-tube.c
+++ b/tests/dbus/dbus-tube.c
@@ -514,5 +514,5 @@ main (int argc,
   g_test_add ("/dbus-tube/accept-invalidated-before-open", Test, NULL,
       setup, test_accept_invalidated_before_open, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/dbus-uninstalled/services/spurious.service b/tests/dbus/dbus-uninstalled/services/spurious.service
deleted file mode 100644
index d0d70aa..0000000
--- a/tests/dbus/dbus-uninstalled/services/spurious.service
+++ /dev/null
@@ -1,3 +0,0 @@
-[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
deleted file mode 100644
index 075ef74..0000000
--- a/tests/dbus/dbus-uninstalled/session.conf.in
+++ /dev/null
@@ -1,29 +0,0 @@
-<!-- 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_srcdir@/tests/dbus/dbus-uninstalled/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/dbus.c b/tests/dbus/dbus.c
index 3772856..3aec68f 100644
--- a/tests/dbus/dbus.c
+++ b/tests/dbus/dbus.c
@@ -342,5 +342,5 @@ main (int argc,
   g_test_add_func ("/dbus-daemon/cancel-watch-during-dispatch",
       cancel_watch_during_dispatch);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/debug-client.c b/tests/dbus/debug-client.c
index 50d07fa..ab5ce59 100644
--- a/tests/dbus/debug-client.c
+++ b/tests/dbus/debug-client.c
@@ -332,5 +332,5 @@ main (int argc,
   g_test_add ("/debug-client/get-messages-failed", Test, NULL, setup,
       test_get_messages_failed, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/error-enum.c b/tests/dbus/error-enum.c
index ef4cd1d..d5316a1 100644
--- a/tests/dbus/error-enum.c
+++ b/tests/dbus/error-enum.c
@@ -2,6 +2,8 @@
 
 #include <telepathy-glib/errors.h>
 
+#include "tests/lib/util.h"
+
 static void
 test_tp_errors (void)
 {
@@ -16,5 +18,5 @@ main (int argc,
 
   g_test_add_func ("/test-error-enum/TP_ERROR", test_tp_errors);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/file-transfer-channel.c b/tests/dbus/file-transfer-channel.c
index 3a167f7..b93ac6e 100644
--- a/tests/dbus/file-transfer-channel.c
+++ b/tests/dbus/file-transfer-channel.c
@@ -614,5 +614,5 @@ main (int argc,
   g_test_add ("/file-transfer-channel/provide/cancel", Test, NULL, setup,
       test_cancel_transfer, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/get-interface-after-invalidate.c b/tests/dbus/get-interface-after-invalidate.c
index 08adf6b..73cab5f 100644
--- a/tests/dbus/get-interface-after-invalidate.c
+++ b/tests/dbus/get-interface-after-invalidate.c
@@ -41,5 +41,5 @@ main (int argc,
   g_test_add_func ("/test-get-interface-after-invalidate",
       test_get_interface_after_invalidate);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/long-connection-name.c b/tests/dbus/long-connection-name.c
index bd34b16..8be0e20 100644
--- a/tests/dbus/long-connection-name.c
+++ b/tests/dbus/long-connection-name.c
@@ -35,6 +35,7 @@ int
 main (int argc,
       char **argv)
 {
+  TpDBusDaemon *dbus;
   TpTestsEchoConnection *service_conn;
   TpBaseConnection *service_conn_as_base;
   GError *error = NULL;
@@ -43,6 +44,7 @@ main (int argc,
 
   tp_tests_abort_after (10);
   g_type_init ();
+  dbus = tp_tests_dbus_daemon_dup_or_die ();
 
   MYASSERT (strlen (LONG_ACCOUNT_IS_LONG) == 256, "");
   service_conn = TP_TESTS_ECHO_CONNECTION (tp_tests_object_new_static_class (
@@ -63,6 +65,7 @@ main (int argc,
   MYASSERT (strlen (name) == 255, "");
 
   g_object_unref (service_conn);
+  g_object_unref (dbus);
   g_free (name);
   g_free (conn_path);
   return 0;
diff --git a/tests/dbus/params-cm.c b/tests/dbus/params-cm.c
index 9a4a6bb..0b7b761 100644
--- a/tests/dbus/params-cm.c
+++ b/tests/dbus/params-cm.c
@@ -362,5 +362,5 @@ main (int argc,
   g_test_add ("/params-cm/get-parameters-bad-proto", Test, NULL, setup,
       test_get_parameters_bad_proto, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/properties.c b/tests/dbus/properties.c
index a458c7c..336ab02 100644
--- a/tests/dbus/properties.c
+++ b/tests/dbus/properties.c
@@ -243,7 +243,7 @@ main (int argc, char **argv)
 
   g_test_add_data_func ("/properties/changed", &ctx, (GTestDataFunc) test_emit_changed);
 
-  g_test_run ();
+  tp_tests_run_with_bus ();
 
   g_object_unref (ctx.obj);
   g_object_unref (ctx.proxy);
diff --git a/tests/dbus/protocol-objects.c b/tests/dbus/protocol-objects.c
index dcaea52..827e843 100644
--- a/tests/dbus/protocol-objects.c
+++ b/tests/dbus/protocol-objects.c
@@ -559,5 +559,5 @@ main (int argc,
   g_test_add ("/protocol-objects/object-from-file", Test, NULL, setup,
       test_protocol_object_from_file, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/proxy-preparation.c b/tests/dbus/proxy-preparation.c
index 7d7638f..10e99d7 100644
--- a/tests/dbus/proxy-preparation.c
+++ b/tests/dbus/proxy-preparation.c
@@ -435,5 +435,5 @@ main (int argc,
   g_test_add ("/proxy-preparation/interface-later", Test, NULL, setup,
       test_interface_later, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/room-list.c b/tests/dbus/room-list.c
index 0b1be22..c1e3a87 100644
--- a/tests/dbus/room-list.c
+++ b/tests/dbus/room-list.c
@@ -316,5 +316,5 @@ main (int argc,
   g_test_add ("/room-list-channel/invalidated", Test, NULL, setup,
       test_invalidated, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/run-test.sh.in b/tests/dbus/run-test.sh.in
index 2e9648f..c9ecb6c 100644
--- a/tests/dbus/run-test.sh.in
+++ b/tests/dbus/run-test.sh.in
@@ -14,6 +14,14 @@ G_DEBUG=fatal_warnings,fatal_criticals
 export G_DEBUG
 libexec=@libexec@
 export libexec
+TP_TESTS_SERVICES_DIR=@tpglibtestsdir@/dbus-1/services
+export TP_TESTS_SERVICES_DIR
+GIO_USE_VFS=local
+export GIO_USE_VFS
+GSETTINGS_BACKEND=memory
+export GSETTINGS_BACKEND
+DBUS_SESSION_BUS_ADDRESS=this-is-clearly-not-valid
+export DBUS_SESSION_BUS_ADDRESS
 
 if [ -n "$1" ] ; then
   list="$1"
@@ -24,9 +32,6 @@ 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
+  @tpglibtestsdir@/tools/test-wrapper.sh @tpglibtestsdir@/$i
 done
 
diff --git a/tests/dbus/self-handle.c b/tests/dbus/self-handle.c
index a5224b5..0a88be8 100644
--- a/tests/dbus/self-handle.c
+++ b/tests/dbus/self-handle.c
@@ -379,5 +379,5 @@ main (int argc,
   g_test_add ("/self-handle/fails", Fixture, "archaic", setup,
       test_self_handle_fails, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/simple-approver.c b/tests/dbus/simple-approver.c
index 9995d9d..cbbf5e5 100644
--- a/tests/dbus/simple-approver.c
+++ b/tests/dbus/simple-approver.c
@@ -497,5 +497,5 @@ main (int argc,
   g_test_add ("/simple-approver/fail", Test, NULL, setup, test_fail,
       teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/simple-handler.c b/tests/dbus/simple-handler.c
index 691a8d9..1465934 100644
--- a/tests/dbus/simple-handler.c
+++ b/tests/dbus/simple-handler.c
@@ -513,5 +513,5 @@ main (int argc,
   g_test_add ("/simple-handler/fail", Test, NULL, setup, test_fail,
       teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/simple-observer.c b/tests/dbus/simple-observer.c
index 099efbc..4d64a84 100644
--- a/tests/dbus/simple-observer.c
+++ b/tests/dbus/simple-observer.c
@@ -479,5 +479,5 @@ main (int argc,
   g_test_add ("/simple-observer/fail", Test, NULL, setup, test_fail,
       teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/stream-tube.c b/tests/dbus/stream-tube.c
index 9b49465..34179ae 100644
--- a/tests/dbus/stream-tube.c
+++ b/tests/dbus/stream-tube.c
@@ -1129,5 +1129,5 @@ main (int argc,
   g_test_add ("/stream-tube/offer/bad-connection/sig-first", Test, NULL, setup,
       test_offer_bad_connection_sig_first, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/text-channel.c b/tests/dbus/text-channel.c
index dd4253c..4f38e34 100644
--- a/tests/dbus/text-channel.c
+++ b/tests/dbus/text-channel.c
@@ -1082,5 +1082,5 @@ main (int argc,
   g_test_add ("/text-channel/chat-state", Test, NULL, setup,
       test_chat_state, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/tls-certificate.c b/tests/dbus/tls-certificate.c
index ee67ff2..9aa2843 100644
--- a/tests/dbus/tls-certificate.c
+++ b/tests/dbus/tls-certificate.c
@@ -351,5 +351,5 @@ main (int argc,
   g_test_add ("/tls-certificate/invalidated", Test, NULL, setup,
       test_invalidated, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/dbus/unsupported-interface.c b/tests/dbus/unsupported-interface.c
index e459e62..98da098 100644
--- a/tests/dbus/unsupported-interface.c
+++ b/tests/dbus/unsupported-interface.c
@@ -266,5 +266,5 @@ main (int argc,
   g_test_add ("/unsupported/signal", Fixture, NULL,
       setup, test_unsupported_signal, teardown);
 
-  return g_test_run ();
+  return tp_tests_run_with_bus ();
 }
diff --git a/tests/lib/util.c b/tests/lib/util.c
index 96fd18b..3cf47e1 100644
--- a/tests/lib/util.c
+++ b/tests/lib/util.c
@@ -77,10 +77,70 @@ tp_tests_proxy_run_until_prepared_or_failed (gpointer proxy,
   return r;
 }
 
+static GTestDBus *test_dbus = NULL;
+
+static void
+start_dbus_session (void)
+{
+  g_assert (test_dbus == NULL);
+
+  g_type_init ();
+
+  /* Make sure we won't be using user's bus. This unsets more than
+   * g_test_dbus_unset() currently does (glib 2.36) */
+  g_unsetenv ("DISPLAY");
+  g_unsetenv ("DBUS_STARTER_ADDRESS");
+  g_unsetenv ("DBUS_STARTER_BUS_TYPE");
+  g_unsetenv ("DBUS_SESSION_BUS_ADDRESS");
+
+  test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
+  g_test_dbus_add_service_dir (test_dbus, g_getenv ("TP_TESTS_SERVICES_DIR"));
+  g_test_dbus_up (test_dbus);
+}
+
+static void
+stop_dbus_session (void)
+{
+  g_assert (test_dbus != NULL);
+  g_test_dbus_down (test_dbus);
+  g_clear_object (&test_dbus);
+}
+
+gint
+tp_tests_run_with_bus (void)
+{
+  gint ret;
+
+  if (test_dbus != NULL)
+    return g_test_run ();
+
+  start_dbus_session ();
+  ret = g_test_run ();
+  stop_dbus_session ();
+
+  return ret;
+}
+
 TpDBusDaemon *
 tp_tests_dbus_daemon_dup_or_die (void)
 {
-  TpDBusDaemon *d = tp_dbus_daemon_dup (NULL);
+  TpDBusDaemon *d;
+
+  if (test_dbus == NULL)
+    {
+      /* HACK: Some tests are not yet ported to GTest and thus are not using
+       * tp_tests_run_with_bus(). In that case we make sure to start the dbus
+       * session before aquiring the TpDBusDaemon and we stop the session when
+       * the daemon is disposed. In a perfect world this should not be needed.
+       */
+      start_dbus_session ();
+      d = tp_dbus_daemon_dup (NULL);
+      g_object_weak_ref ((GObject *) d, (GWeakNotify) stop_dbus_session, NULL);
+    }
+  else
+    {
+       d = tp_dbus_daemon_dup (NULL);
+    }
 
   /* In a shared library, this would be very bad (see fd.o #18832), but in a
    * regression test that's going to be run under a temporary session bus,
diff --git a/tests/lib/util.h b/tests/lib/util.h
index 7c75765..bc682ae 100644
--- a/tests/lib/util.h
+++ b/tests/lib/util.h
@@ -13,6 +13,8 @@
 
 #include <telepathy-glib/telepathy-glib.h>
 
+gint tp_tests_run_with_bus (void);
+
 TpDBusDaemon *tp_tests_dbus_daemon_dup_or_die (void);
 
 void tp_tests_proxy_run_until_dbus_queue_processed (gpointer proxy);
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 761ee03..0fd42f8 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -9,7 +9,6 @@ telepathy-glib-env: telepathy-glib-env.in Makefile
 if ENABLE_INSTALLED_TESTS
 toolsdir = @tpglibtestsdir@/tools
 tools_SCRIPTS = \
-	with-session-bus.sh \
 	test-wrapper.sh \
 	libglibcodegen.py \
 	libtpcodegen.py \
@@ -44,7 +43,6 @@ EXTRA_DIST = \
     telepathy-glib.supp \
     telepathy-glib-env.in \
     test-wrapper.sh \
-    with-session-bus.sh \
     xincludator.py
 
 CLEANFILES = libtpcodegen.pyc libtpcodegen.pyo libglibcodegen.pyc libglibcodegen.pyo $(noinst_SCRIPTS)
diff --git a/tools/with-session-bus.sh b/tools/with-session-bus.sh
deleted file mode 100755
index 0afa593..0000000
--- a/tools/with-session-bus.sh
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/bin/sh
-# with-session-bus.sh - run a program with a temporary D-Bus session daemon
-#
-# The canonical location of this program is the telepathy-glib tools/
-# directory, please synchronize any changes with that copy.
-#
-# Copyright (C) 2007-2008 Collabora Ltd. <http://www.collabora.co.uk/>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved.
-
-set -e
-
-me=with-session-bus
-
-dbus_daemon_args="--print-address=5 --print-pid=6 --fork"
-sleep=0
-
-usage ()
-{
-  echo "usage: $me [options] -- program [program_options]" >&2
-  echo "Requires write access to the current directory." >&2
-  echo "" >&2
-  echo "If \$WITH_SESSION_BUS_FORK_DBUS_MONITOR is set, fork dbus-monitor" >&2
-  echo "with the arguments in \$WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT." >&2
-  echo "The output of dbus-monitor is saved in $me-<pid>.dbus-monitor-logs" >&2
-  exit 2
-}
-
-while test "z$1" != "z--"; do
-  case "$1" in
-  --sleep=*)
-    sleep="$1"
-    sleep="${sleep#--sleep=}"
-    shift
-    ;;
-  --session)
-    dbus_daemon_args="$dbus_daemon_args --session"
-    shift
-    ;;
-  --config-file=*)
-    # FIXME: assumes config file doesn't contain any special characters
-    dbus_daemon_args="$dbus_daemon_args $1"
-    shift
-    ;;
-  *)
-    usage
-    ;;
-  esac
-done
-shift
-if test "z$1" = "z"; then usage; fi
-
-exec 5> $me-$$.address
-exec 6> $me-$$.pid
-
-cleanup ()
-{
-  pid=`head -n1 $me-$$.pid`
-  if test -n "$pid" ; then
-    if [ -n "$VERBOSE_TESTS" ]; then
-      echo "Killing temporary bus daemon: $pid" >&2
-    fi
-    kill -INT "$pid"
-  fi
-  rm -f $me-$$.address
-  rm -f $me-$$.pid
-}
-
-trap cleanup INT HUP TERM
-dbus-daemon $dbus_daemon_args
-
-if [ -n "$VERBOSE_TESTS" ]; then
-  { echo -n "Temporary bus daemon is "; cat $me-$$.address; } >&2
-  { echo -n "Temporary bus daemon PID is "; head -n1 $me-$$.pid; } >&2
-fi
-
-e=0
-
-# These might be non-null when run from e.g. gnome-terminal 3.8, which uses
-# an activatable service for its windows; we don't want to inherit them either
-unset DBUS_STARTER_ADDRESS
-unset DBUS_STARTER_BUS_TYPE
-
-DBUS_SESSION_BUS_ADDRESS="`cat $me-$$.address`"
-export DBUS_SESSION_BUS_ADDRESS
-DBUS_SESSION_BUS_PID="`cat $me-$$.pid`"
-export DBUS_SESSION_BUS_PID
-
-if [ -n "$WITH_SESSION_BUS_FORK_DBUS_MONITOR" ] ; then
-  echo -n "Forking dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT" >&2
-  dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT \
-        > $me-$$.dbus-monitor-logs 2>&1 &
-fi
-
-"$@" || e=$?
-
-if test $sleep != 0; then
-  sleep $sleep
-fi
-
-trap - INT HUP TERM
-cleanup
-
-exit $e

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-glib.git



More information about the Pkg-telepathy-commits mailing list