[next] telepathy-glib: tests: don' t create GTestDBus in tp_tests_dbus_daemon_dup_or_die

Simon McVittie smcv at kemper.freedesktop.org
Wed Mar 19 13:00:51 PDT 2014


Module: telepathy-glib
Branch: next
Commit: 92e21a267f4b86560041419eb78a2fd661b2e1da
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=92e21a267f4b86560041419eb78a2fd661b2e1da

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Tue Mar 18 16:41:46 2014 +0000

tests: don't create GTestDBus in tp_tests_dbus_daemon_dup_or_die

Doing weak-ref magic with the TpDBusDaemon returned by
tp_tests_dbus_daemon_dup_or_die() was causing some rather
hard-to-track-down test failures in the Logger tests.

The problem is that g_test_dbus_down() calls g_object_run_dispose()
on the GDBusConnection, after which it is unusable (the "worker"
has been destroyed, and many methods just crash). That's fine
if nothing was holding a reference. Unfortunately, various Telepathy
and Logger objects that behave like singletons hold a reference
to the GDBusConnection.

This meant that this life-cycle was OK:

    / tp_tests_dbus_daemon_dup_or_die()
    |  / tp_dbus_daemon_dup()
    |  |  [test-case 1]
    |  \ g_object_unref()
    |  / tp_dbus_daemon_dup()
    |  |  [test-case 2]
    |  \ g_object_unref()
    \ g_object_unref()

but this will often crash:

    / tp_tests_dbus_daemon_dup_or_die()
    |  [test-case 1]
    \ g_object_unref()

    / tp_tests_dbus_daemon_dup_or_die()
    |  [test-case 2]
    \ g_object_unref()

As a first step towards fixing that, let's implement "explicit is
better than implicit": always manage GTestDBus explicitly
(via either its own API or tp_tests_run_with_bus), and never
create it implicitly.

Reviewed-by: Xavier Claessens

---

 tests/dbus/call-cancellation.c                |    9 +++++
 tests/dbus/channel-introspect.c               |    9 +++++
 tests/dbus/cli-group.c                        |    8 +++++
 tests/dbus/contacts-bug-19101.c               |    8 +++++
 tests/dbus/contacts-mixin.c                   |    8 +++++
 tests/dbus/disconnection.c                    |    8 +++++
 tests/dbus/example-no-protocols.c             |    8 +++++
 tests/dbus/finalized-in-invalidated-handler.c |    8 +++++
 tests/dbus/group-mixin.c                      |    8 +++++
 tests/dbus/handle-repo.c                      |    9 +++++
 tests/dbus/handle-set.c                       |    8 +++++
 tests/dbus/long-connection-name.c             |   10 ++++++
 tests/dbus/message-mixin.c                    |    9 +++++
 tests/dbus/self-presence.c                    |    9 +++++
 tests/dbus/text-respawn.c                     |    8 +++++
 tests/lib/util.c                              |   48 +++++--------------------
 16 files changed, 135 insertions(+), 40 deletions(-)

Diff:   http://cgit.freedesktop.org/telepathy/telepathy-glib/diff/?id=92e21a267f4b86560041419eb78a2fd661b2e1da


More information about the telepathy-commits mailing list