Bug 32550

Summary: servicetest.sync_dbus might not be enough in some cases
Product: Telepathy Reporter: Jonny Lamb <jonny.lamb>
Component: gabbleAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium Keywords: patch
Version: git master   
Hardware: Other   
OS: All   
URL: http://git.collabora.co.uk/?p=user/jonny/telepathy-gabble.git;a=shortlog;h=refs/heads/sync-dbus
Whiteboard: review+
i915 platform: i915 features:

Description Jonny Lamb 2010-12-21 07:36:33 UTC
I was using sync_dbus in a mission-control test to make MC spin its mainloop enough so I could assert one method was not being called before I returned from a call that had previously been made. However, sync_dbus alone was not enough as apparently libdbus returns from Ping calls synchronously so it didn't turn the main loop enough. Calling sync_dbus a few times made it work, but it showed the test was going to be racy. This is what I did:

    # Waste a little time here and there.  We can't call sync_dbus
    # here because it calls Ping and libdbus returns from Ping
    # synchronously and doesn't turn the main loop handle enough.
    call_async(q, cd_props, 'Get', cs.CD_IFACE_OP_LIST, 'DispatchOperations')
    event = q.expect('dbus-return', method='Get')

This works in my case because there was no other Get method call, but it would be bad to replace sync_dbus with this as it could grab the dbus method return from some other call, which is obviously bad.

So, we need a better sync_dbus. Ideas?
Comment 1 Simon McVittie 2011-01-03 03:58:16 UTC
Perhaps make an async call to org.freedesktop.Telepathy.Tests.SyncDBusDummyMethod and expect the error?
Comment 2 Jonny Lamb 2011-01-03 08:01:18 UTC
Neat idea. Here's a patch. make check passes. I'm putting it here because gabble is pretty much the canonical location for servicetest.py.
Comment 3 Simon McVittie 2011-01-03 09:15:30 UTC
Looks good.
Comment 4 Jonny Lamb 2011-01-03 09:23:58 UTC
Thanks.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.