[telepathy-salut/master] avahitest.py: add check_ipv6_enabled

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Wed Apr 1 08:23:40 PDT 2009


---
 tests/twisted/avahitest.py |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/tests/twisted/avahitest.py b/tests/twisted/avahitest.py
index f9e7ecf..07b5d11 100644
--- a/tests/twisted/avahitest.py
+++ b/tests/twisted/avahitest.py
@@ -3,7 +3,7 @@ Infrastructure for testing avahi
 """
 
 import servicetest
-from servicetest import Event
+from servicetest import Event, TimeoutError
 import dbus
 import dbus.glib
 import avahi
@@ -180,6 +180,21 @@ class AvahiAnnouncer:
     def stop(self):
         self.entry.Free()
 
+def check_ipv6_enabled(q, announcer):
+    # Avahi doesn't complain if we try to announce an IPv6 service with a
+    # not IPv6 enabled Avahi (http://www.avahi.org/ticket/264) so we try to
+    # resolve our own service to check if it has been actually announced.
+    service = AvahiService(q, announcer.bus, announcer.server,
+        avahi.IF_UNSPEC, announcer.proto, announcer.name,
+        announcer.type, get_domain_name(), avahi.PROTO_INET6, 0)
+    service.resolve()
+
+    try:
+        q.expect('service-resolved', service=service)
+        return True
+    except TimeoutError:
+        return False
+
 if __name__ == '__main__':
     from twisted.internet import reactor
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list