After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 697348 - GTestDBus should unset DBUS_STARTER_ADDRESS, DBUS_STARTER_BUS_TYPE
GTestDBus should unset DBUS_STARTER_ADDRESS, DBUS_STARTER_BUS_TYPE
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gdbus
unspecified
Other Linux
: Normal normal
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-04-05 13:02 UTC by Simon McVittie
Modified: 2013-10-29 17:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GTestDBus: Make sure it replaces the STARTER bus as well (1.38 KB, patch)
2013-10-28 18:56 UTC, Xavier Claessens
none Details | Review
Tests: fix indentation in dbus-appinfo code (3.30 KB, patch)
2013-10-28 18:56 UTC, Xavier Claessens
none Details | Review
GTestDBus: Make sure only DBUS_SESSION_BUS_ADDRESS is set by default (1.38 KB, patch)
2013-10-28 20:30 UTC, Xavier Claessens
none Details | Review
Tests: fix indentation in dbus-appinfo code (3.30 KB, patch)
2013-10-28 21:22 UTC, Xavier Claessens
rejected Details | Review
Tests: add _g_test_dbus_run() and use it where possible (5.16 KB, patch)
2013-10-28 21:22 UTC, Xavier Claessens
accepted-commit_now Details | Review
Tests: It is useless to unset "DBUS_SESSION_BUS_ADDRESS" manually (1.39 KB, patch)
2013-10-28 21:22 UTC, Xavier Claessens
accepted-commit_now Details | Review
GTestDBus: Make sure only DBUS_SESSION_BUS_ADDRESS is set by default (1.22 KB, patch)
2013-10-28 21:22 UTC, Xavier Claessens
accepted-commit_now Details | Review

Description Simon McVittie 2013-04-05 13:02:36 UTC
The actual terminal in gnome-terminal 3.8 is an activatable service, so it has DBUS_STARTER_ADDRESS in its environment. telepathy-glib (and possibly other libraries) prefers DBUS_STARTER_ADDRESS over DBUS_SESSION_BUS_ADDRESS when looking for "the bus with Telepathy on it", but GTestDBus doesn't clear or set the former, only the latter; so we end up trying to use the real bus when run under a recent gnome-terminal.

See Bug #697261 and <https://bugs.freedesktop.org/show_bug.cgi?id=63119>.

This affects both g_test_dbus_unset() and g_test_dbus_up().
Comment 1 Xavier Claessens 2013-10-28 18:56:14 UTC
Created attachment 258332 [details] [review]
GTestDBus: Make sure it replaces the STARTER bus as well

This breaks dbus-appinfo unit test for some reason. That test now
waits undefinitly on the "activate" action that never happens. I
don't understand why.
Comment 2 Xavier Claessens 2013-10-28 18:56:31 UTC
Created attachment 258333 [details] [review]
Tests: fix indentation in dbus-appinfo code
Comment 3 Simon McVittie 2013-10-28 19:08:59 UTC
Review of attachment 258332 [details] [review]:

> This breaks dbus-appinfo unit test for some reason

Well, presumably that's not desirable :-)

::: gio/gtestdbus.c
@@ +761,3 @@
   g_setenv ("DBUS_SESSION_BUS_ADDRESS", self->priv->bus_address, TRUE);
+  g_setenv ("DBUS_STARTER_ADDRESS", self->priv->bus_address, TRUE);
+  g_setenv ("DBUS_STARTER_BUS_TYPE", "session", TRUE);

If you make sure g_test_dbus_unset() has been called instead, does that work any better?

I think the environment that tests normally ought to use is: DBUS_SESSION_BUS_ADDRESS set, DISPLAY cleared, DBUS_STARTER_* cleared.
Comment 4 Xavier Claessens 2013-10-28 20:30:08 UTC
Created attachment 258342 [details] [review]
GTestDBus: Make sure only DBUS_SESSION_BUS_ADDRESS is set by default

g_test_dbus_unset() now also unset DBUS_STARTER_ADDRESS and
DBUS_STARTER_BUS_TYPE.

This breaks dbus-appinfo unit test because unsetting DISPLAY
makes dbus-launch fail to init x11. I don't understand why
all other unit tests still pass, though.
Comment 5 Xavier Claessens 2013-10-28 20:32:00 UTC
and if I comment out the g_unsetenv ("DISPLAY"); some other unit tests then fails...

Simon: I'm counting on your expert eyes to understand what's going on here :p
Comment 6 Xavier Claessens 2013-10-28 21:22:14 UTC
Created attachment 258345 [details] [review]
Tests: fix indentation in dbus-appinfo code
Comment 7 Xavier Claessens 2013-10-28 21:22:23 UTC
Created attachment 258346 [details] [review]
Tests: add _g_test_dbus_run() and use it where possible

This is to avoid having again the subtil bug in dbus-appinfo.c:
session_bus_down() was called before g_test_run() so the test was
running on the user's dbus session.
Comment 8 Xavier Claessens 2013-10-28 21:22:31 UTC
Created attachment 258347 [details] [review]
Tests: It is useless to unset "DBUS_SESSION_BUS_ADDRESS" manually

If the goal is to make sure we don't have a dbus connection, it has
to call g_test_dbus_unset() instead which is much more complete.

In this case, g_test_dbus_unset() is called already, so it should be
fine.
Comment 9 Xavier Claessens 2013-10-28 21:22:39 UTC
Created attachment 258348 [details] [review]
GTestDBus: Make sure only DBUS_SESSION_BUS_ADDRESS is set by default

g_test_dbus_unset() now also unset DBUS_STARTER_ADDRESS and
DBUS_STARTER_BUS_TYPE.
Comment 10 Xavier Claessens 2013-10-28 21:26:48 UTC
I'm now pondering adding g_test_dbus_unset() inside g_test_init() to make damn sure we'll never run a test that use user's session. I know g_test_init() is not part of libgio, but g_test_dbus_unset() does not use any of libgio, so it's doable.

It will probably have side effects for tests that use dbus indirectly, but I think it is actually good to see all those tests messing with user's session failing.
Comment 11 Xavier Claessens 2013-10-28 21:29:02 UTC
(In reply to comment #10)
> I'm now pondering adding g_test_dbus_unset() inside g_test_init() to make damn
> sure we'll never run a test that use user's session. I know g_test_init() is
> not part of libgio, but g_test_dbus_unset() does not use any of libgio, so it's
> doable.
> 
> It will probably have side effects for tests that use dbus indirectly, but I
> think it is actually good to see all those tests messing with user's session
> failing.

Actually no, that would break tests that use wrapper like with-session-bus.sh. We probably can't force them to port their tests to GTestDBus.
Comment 12 Simon McVittie 2013-10-29 12:55:03 UTC
Review of attachment 258345 [details] [review]:

This is a matter of taste, but I prefer Xavier's version.
Comment 13 Simon McVittie 2013-10-29 12:56:36 UTC
Review of attachment 258346 [details] [review]:

I like this.
Comment 14 Simon McVittie 2013-10-29 12:57:02 UTC
Review of attachment 258347 [details] [review]:

Looks good to me.
Comment 15 Simon McVittie 2013-10-29 12:57:43 UTC
Review of attachment 258348 [details] [review]:

Looks good to me, and should fix the "Telepathy in gnome-terminal" use-case.
Comment 16 Allison Karlitskaya (desrt) 2013-10-29 17:11:42 UTC
Review of attachment 258345 [details] [review]:

I prefer mine :)
Comment 17 Allison Karlitskaya (desrt) 2013-10-29 17:12:49 UTC
Review of attachment 258346 [details] [review]:

This is a nice improvement.  Thanks!
Comment 18 Allison Karlitskaya (desrt) 2013-10-29 17:14:31 UTC
Review of attachment 258348 [details] [review]:

Looks good as well.  Go ahead.
Comment 19 Allison Karlitskaya (desrt) 2013-10-29 17:16:06 UTC
Review of attachment 258347 [details] [review]:

Agreed.

This testcase is both good and bad in the sense that it's doing the up/down per test (good), but that it is having to do it manually (bad)....

Having a support for this in gtester in some form or another would be nice...
Comment 20 Allison Karlitskaya (desrt) 2013-10-29 17:17:33 UTC
Review of attachment 258346 [details] [review]:

Maybe call it session_bus_run_tests() to match the rest of the stuff in that file...  You'll need to rebase this patch anyway since it no longer applies.
Comment 21 Xavier Claessens 2013-10-29 17:46:03 UTC
Thanks. I skipped attachment #258345 [details], renamed _g_test_dbus_run() to session_bus_run() and pushed to master.