diff options
author | Simon McVittie <smcv@debian.org> | 2011-01-31 17:37:59 +0000 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2011-01-31 17:37:59 +0000 |
commit | 24fbe571516161d48b499d587f9adb3e683dbf88 (patch) | |
tree | 7d70909156dcf587d91f693b8e1216eb4e0465e1 /test/name-test/test-activation-forking.py | |
parent | 9b72896b3730a9fceb961be28bb95762a7b4e9d6 (diff) | |
download | dbus-24fbe571516161d48b499d587f9adb3e683dbf88.tar.gz |
Imported Upstream version 1.2.24upstream/1.2.24
Diffstat (limited to 'test/name-test/test-activation-forking.py')
-rw-r--r-- | test/name-test/test-activation-forking.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/test/name-test/test-activation-forking.py b/test/name-test/test-activation-forking.py new file mode 100644 index 00000000..0d820754 --- /dev/null +++ b/test/name-test/test-activation-forking.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +import os,sys + +try: + import gobject + import dbus + import dbus.mainloop.glib +except: + print "Failed import, aborting test" + sys.exit(0) + +dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) +loop = gobject.MainLoop() + +exitcode = 0 + +bus = dbus.SessionBus() +bus_iface = dbus.Interface(bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus'), 'org.freedesktop.DBus') + +o = bus.get_object('org.freedesktop.DBus.TestSuiteForkingEchoService', '/org/freedesktop/TestSuite') +i = dbus.Interface(o, 'org.freedesktop.TestSuite') + +# Start it up +reply = i.Echo("hello world") +print "TestSuiteForkingEchoService initial reply OK" + +def ignore(*args, **kwargs): + pass + +# Now monitor for exits, when that happens, start it up again. +# The goal here is to try to hit any race conditions in activation. +counter = 0 +def on_forking_echo_owner_changed(name, old, new): + global counter + global o + global i + if counter > 10: + print "Activated 10 times OK, TestSuiteForkingEchoService pass" + loop.quit() + return + counter += 1 + if new == '': + o = bus.get_object('org.freedesktop.DBus.TestSuiteForkingEchoService', '/org/freedesktop/TestSuite') + i = dbus.Interface(o, 'org.freedesktop.TestSuite') + i.Echo("counter %r" % counter) + i.Exit(reply_handler=ignore, error_handler=ignore) + +bus_iface.connect_to_signal('NameOwnerChanged', on_forking_echo_owner_changed, arg0='org.freedesktop.DBus.TestSuiteForkingEchoService') + +i.Exit(reply_handler=ignore, error_handler=ignore) + +def check_counter(): + if counter == 0: + print "Failed to get NameOwnerChanged for TestSuiteForkingEchoService" + sys.exit(1) +gobject.timeout_add(15000, check_counter) + +loop.run() +sys.exit(0) |