diff options
author | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2012-04-11 16:31:56 +0200 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2013-09-26 08:15:13 -0400 |
commit | bfb21c309bcae17f74a27ac9435b4cbbdf1be767 (patch) | |
tree | 33eb161869b045a8000d932d298853925b556372 /tests | |
parent | d6c2580681fa9e84b6375331babef7f4e3962875 (diff) | |
download | telepathy-glib-bfb21c309bcae17f74a27ac9435b4cbbdf1be767.tar.gz |
Port unit tests to g_test_dbus_up/down
https://bugs.freedesktop.org/show_bug.cgi?id=55761
Diffstat (limited to 'tests')
52 files changed, 127 insertions, 135 deletions
diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am index e446645e6..b03c61276 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 0de180b5c..7016338ad 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 22de1c59d..092933e77 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 bc3b7d2b6..055be2e89 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 b921f4068..75d471054 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 843391510..a4de836e1 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 4e12a056e..810c0f423 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 31410ca18..90406cfc8 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 94bc68e3a..b789226aa 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 5a5ecf342..69aaa3913 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 c09d9390f..7cb7ca0b5 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 0cec68374..593681ea8 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 a3cbb26e0..92668ab6a 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 2bde19c3e..9146f4f1e 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 5e504b3eb..2c0f56da4 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 cd6248853..3888277d2 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 3b5e6f89d..ddadab8d5 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 4d022aba3..b247e1404 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 1ade331a8..3d2e5613e 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 c850e555c..7ffbda639 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 0d2631133..51a887227 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 943645c36..a3f878a16 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 b97e69371..f072ef7e6 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 b7094c0e2..8c8b7491e 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 9c070a732..9a4e9cc1e 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 index d0d70aa04..d0d70aa04 100644 --- a/tests/dbus/dbus-installed/services/spurious.service +++ b/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 313c653d1..000000000 --- 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 ae9c83149..90e5e44df 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 d0d70aa04..000000000 --- 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 075ef7421..000000000 --- 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 3772856a0..3aec68f22 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 50d07fae4..ab5ce5914 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 ef4cd1d31..d5316a13c 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 3a167f763..b93ac6eb3 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 08adf6b7c..73cab5f18 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 bd34b1635..8be0e20f5 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 9a4a6bb75..0b7b761f5 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 a458c7c3a..336ab0240 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 dcaea52f2..827e843da 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 7d7638fd5..10e99d724 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 0b1be2232..c1e3a874a 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 2e9648f0b..c9ecb6cb5 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 a5224b5c5..0a88be86b 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 9995d9db6..cbbf5e5e9 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 691a8d997..1465934c9 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 099efbc36..4d64a8438 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 9b4946567..34179ae5b 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 dd4253ca1..4f38e3456 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 ee67ff23e..9aa2843f8 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 e459e6206..98da098ab 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 96fd18bee..3cf47e1ff 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 7c7576528..bc682ae17 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); |