diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2011-04-14 11:55:42 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-04-14 11:55:54 +0100 |
commit | dd20af3cbd95eb062394c0fd530f16f06d490fe8 (patch) | |
tree | 3847f1af17cb3ff2229653166959fb587eb81c78 | |
parent | 30a4c00c471a8e2592e9f3e86e73c43b79b7c648 (diff) | |
parent | 427e6d6a221b0f7f383a96faae8c6e185eb2af83 (diff) |
Merge branch 'test-failures-due-to-fd-limit'
Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r-- | plugins/test.c | 17 | ||||
-rw-r--r-- | src/conn-util.c | 14 | ||||
-rw-r--r-- | tests/twisted/Makefile.am | 1 | ||||
-rw-r--r-- | tests/twisted/connect/torture.py | 20 | ||||
-rw-r--r-- | tests/twisted/gabbletest.py | 4 | ||||
-rw-r--r-- | tests/twisted/jingle/jingletest2.py | 4 | ||||
-rw-r--r-- | tests/twisted/jingle/outgoing-basics.py | 14 | ||||
-rw-r--r-- | tests/twisted/presence/invisible_helper.py | 5 | ||||
-rw-r--r-- | tests/twisted/servicetest.py | 18 |
9 files changed, 59 insertions, 38 deletions
diff --git a/plugins/test.c b/plugins/test.c index ab9ec82af..678df2d8f 100644 --- a/plugins/test.c +++ b/plugins/test.c @@ -505,7 +505,10 @@ test_channel_manager_set_property ( switch (property_id) { case PROP_CONNECTION: - self->connection = g_value_dup_object (value); + /* Not reffing this: the connection owns all channel managers, so it + * must outlive us. Taking a reference leads to a cycle. + */ + self->connection = g_value_get_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -555,17 +558,6 @@ test_channel_manager_constructed (GObject *object) } static void -test_channel_manager_dispose (GObject *object) -{ - TestChannelManager *self = TEST_CHANNEL_MANAGER (object); - - if (G_OBJECT_CLASS (test_channel_manager_parent_class)->dispose != NULL) - G_OBJECT_CLASS (test_channel_manager_parent_class)->dispose (object); - - tp_clear_object (&self->connection); -} - -static void test_channel_manager_class_init (TestChannelManagerClass *klass) { GObjectClass *oclass = G_OBJECT_CLASS (klass); @@ -573,7 +565,6 @@ test_channel_manager_class_init (TestChannelManagerClass *klass) oclass->set_property = test_channel_manager_set_property; oclass->get_property = test_channel_manager_get_property; oclass->constructed = test_channel_manager_constructed; - oclass->dispose = test_channel_manager_dispose; g_object_class_install_property (oclass, PROP_CONNECTION, g_param_spec_object ("connection", "Gabble Connection", diff --git a/src/conn-util.c b/src/conn-util.c index be224c5e6..5b3a3ddf6 100644 --- a/src/conn-util.c +++ b/src/conn-util.c @@ -39,13 +39,17 @@ conn_util_send_iq_cb (GObject *source_object, reply = wocky_porter_send_iq_finish (porter, res, &error); if (reply != NULL) - g_simple_async_result_set_op_res_gpointer (result, reply, - (GDestroyNotify) g_object_unref); + { + g_simple_async_result_set_op_res_gpointer (result, reply, + (GDestroyNotify) g_object_unref); + } else - g_simple_async_result_set_from_error (result, error); - - g_simple_async_result_complete_in_idle (result); + { + g_simple_async_result_set_from_error (result, error); + g_clear_error (&error); + } + g_simple_async_result_complete (result); g_object_unref (result); } diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index cf41d832f..65c110c78 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -310,6 +310,7 @@ BUILT_SOURCES = config.py EXTRA_DIST = \ $(TWISTED_TESTS) \ bytestream.py \ + connect/torture.py \ constants.py \ gabbletest.py \ httptest.py \ diff --git a/tests/twisted/connect/torture.py b/tests/twisted/connect/torture.py new file mode 100644 index 000000000..add5b7ce8 --- /dev/null +++ b/tests/twisted/connect/torture.py @@ -0,0 +1,20 @@ +""" +This test does nothing besides connect, and then disconnect as soon as the +session is established, two thousand times. It was used to smoke out a bug +where connections were leaked (which ultimately meant that new connections +could not be established, since the file descriptors were leaked too); it may +also be useful for profiling the connection process (and test framework). +""" +from gabbletest import exec_test + +def test(q, bus, conn, stream): + pass + +def main(): + for i in xrange(0, 2000): + print i + exec_test(test) + print "we partied like it's %i" % i + +if __name__ == '__main__': + main() diff --git a/tests/twisted/gabbletest.py b/tests/twisted/gabbletest.py index 95a3d9dfe..3496c9513 100644 --- a/tests/twisted/gabbletest.py +++ b/tests/twisted/gabbletest.py @@ -597,7 +597,7 @@ def exec_test_deferred(fun, params, protocol=None, timeout=None, signal=kw['member'], args=map(unwrap, args), interface=kw['interface'])) - bus.add_signal_receiver( + match_all_signals = bus.add_signal_receiver( signal_receiver, None, # signal name None, # interface @@ -664,6 +664,8 @@ def exec_test_deferred(fun, params, protocol=None, timeout=None, traceback.print_exc() error = e + match_all_signals.remove() + if error is None: d.addBoth((lambda *args: reactor.crash())) else: diff --git a/tests/twisted/jingle/jingletest2.py b/tests/twisted/jingle/jingletest2.py index 044bde44b..65943b800 100644 --- a/tests/twisted/jingle/jingletest2.py +++ b/tests/twisted/jingle/jingletest2.py @@ -7,6 +7,7 @@ # This can be used in parallel with the old API, but should # obsolete it in time. +from functools import partial from twisted.words.xish import domish, xpath import random from gabbletest import sync_stream, exec_test @@ -824,8 +825,7 @@ class JingleTest2: def test_dialects(f, dialects): for dialect in dialects: - exec_test( - lambda q, bus, conn, stream: f(dialect(), q, bus, conn, stream)) + exec_test(partial(f, dialect())) def test_all_dialects(f): dialectmap = { "jingle015": JingleProtocol015, diff --git a/tests/twisted/jingle/outgoing-basics.py b/tests/twisted/jingle/outgoing-basics.py index eb7168cae..15bf6eb77 100644 --- a/tests/twisted/jingle/outgoing-basics.py +++ b/tests/twisted/jingle/outgoing-basics.py @@ -2,7 +2,7 @@ Test basic outgoing call handling, using CreateChannel and all three variations of RequestChannel. """ - +from functools import partial import dbus from twisted.words.xish import xpath @@ -337,11 +337,7 @@ if __name__ == '__main__': test_all_dialects(request_anonymous) test_all_dialects(request_anonymous_and_add) test_all_dialects(request_nonymous) - test_all_dialects(lambda j, q, b, c, s: - create(j, q, b, c, s, peer='foo@gw.bar.com')) - test_all_dialects(lambda j, q, b, c, s: - request_anonymous(j, q, b, c, s, peer='foo@gw.bar.com')) - test_all_dialects(lambda j, q, b, c, s: - request_anonymous_and_add(j, q, b, c, s, peer='foo@gw.bar.com')) - test_all_dialects(lambda j, q, b, c, s: - request_nonymous(j, q, b, c, s, peer='foo@gw.bar.com')) + test_all_dialects(partial(create, peer='foo@gw.bar.com')) + test_all_dialects(partial(request_anonymous, peer='foo@gw.bar.com')) + test_all_dialects(partial(request_anonymous_and_add, peer='foo@gw.bar.com')) + test_all_dialects(partial(request_nonymous, peer='foo@gw.bar.com')) diff --git a/tests/twisted/presence/invisible_helper.py b/tests/twisted/presence/invisible_helper.py index 2b8488130..60af038b9 100644 --- a/tests/twisted/presence/invisible_helper.py +++ b/tests/twisted/presence/invisible_helper.py @@ -46,8 +46,9 @@ class ManualPrivacyListStream(XmppXmlStream): class ValidInvisibleListStream(ManualPrivacyListStream): """This stream class pretends to be a server which supports privacy lists. It has exactly one stored list, named 'invisible', which satisfies Gabble's - idea of what an invisible list should look like. Activating that list, or the Any attempts to modify the - stored lists, or activate one, will fail. + idea of what an invisible list should look like. Activating that list, or + disabling the active list, will succeed; any attempts to activate or modify + other lists will fail. The intention is that this class could be used to run presence tests unrelated to invisibility against a server which supports invisibility.""" diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py index 1771ddaf4..976622c8d 100644 --- a/tests/twisted/servicetest.py +++ b/tests/twisted/servicetest.py @@ -414,12 +414,17 @@ def call_async(test, proxy, method, *args, **kw): method_proxy(*args, **kw) def sync_dbus(bus, q, conn): - # Dummy D-Bus method call + # Dummy D-Bus method call. We can't use DBus.Peer.Ping() because libdbus + # replies to that message immediately, rather than handing it up to + # dbus-glib and thence Gabble, which means that Ping()ing Gabble doesn't + # ensure that it's processed all D-Bus messages prior to our ping. + # # This won't do the right thing unless the proxy has a unique name. assert conn.object.bus_name.startswith(':') - root_object = bus.get_object(conn.object.bus_name, '/') - call_async( - q, dbus.Interface(root_object, 'org.freedesktop.Telepathy.Tests'), 'DummySyncDBus') + root_object = bus.get_object(conn.object.bus_name, '/', introspect=False) + call_async(q, + dbus.Interface(root_object, 'org.freedesktop.Telepathy.Tests'), + 'DummySyncDBus') q.expect('dbus-error', method='DummySyncDBus') class ProxyWrapper: @@ -475,11 +480,12 @@ def wrap_channel(chan, type_, extra=None): def make_connection(bus, event_func, name, proto, params): cm = bus.get_object( tp_name_prefix + '.ConnectionManager.%s' % name, - tp_path_prefix + '/ConnectionManager/%s' % name) + tp_path_prefix + '/ConnectionManager/%s' % name, + introspect=False) cm_iface = dbus.Interface(cm, tp_name_prefix + '.ConnectionManager') connection_name, connection_path = cm_iface.RequestConnection( - proto, params) + proto, dbus.Dictionary(params, signature='sv')) conn = wrap_connection(bus.get_object(connection_name, connection_path)) return conn |