[conduit: 91/138] Env object to manage running a session bus for the duration of the tests. Not even sure it works yet
- From: John Carr <johncarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [conduit: 91/138] Env object to manage running a session bus for the duration of the tests. Not even sure it works yet
- Date: Thu, 21 May 2009 03:34:34 -0400 (EDT)
commit 29ae66c969c9556a6532296b1ef6c57f568dd6f7
Author: John Carr <john carr unrouted co uk>
Date: Mon May 4 15:58:37 2009 -0700
Env object to manage running a session bus for the duration of the tests. Not even sure it works yet though.
---
test/soup/env/fake-dbus.py | 34 ++++++++++++++++++++++++++++++++++
test/soup/env/fake-session-bus.conf | 12 ++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/test/soup/env/fake-dbus.py b/test/soup/env/fake-dbus.py
new file mode 100644
index 0000000..aa6fd19
--- /dev/null
+++ b/test/soup/env/fake-dbus.py
@@ -0,0 +1,34 @@
+
+import os
+import signal
+import subprocess
+
+import soup
+
+class Dbus(soup.env.EnvironmentWrapper):
+
+ def prepare_environment(self):
+ conffile = os.path.join(os.path.dirname(__file__), "fake-session-bus.conf")
+ daemonargs = ['dbus-daemon', '--fork', '--config-file=%s' % conffile, '--print-pid=1', '--print-address=1']
+
+ #FIXME: Probably belongs in build system, but at same time i dont want to depend on a damned build system :)
+ open(conffile,'w').write(open(conffile+'.in','r').read().replace('@top_builddir@', soup.get_root()))
+
+ # start our own dbus daemon :) :)
+ dbus = subprocess.Popen(daemonargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = dbus.communicate()
+
+ # make sure we have something like what a proper daemon would give us...
+ daemon_resp = out.split()
+ assert len(daemon_resp) == 2
+ assert daemon_resp[0].startswith('unix:abstract=')
+ assert daemon_resp[1].isdigit()
+
+ self.address, self.pid = daemon_resp
+
+ # lets use this session bus when we run tests
+ os.environ['DBUS_SESSION_BUS_ADDRESS'] = self.address
+
+ def finalize_environment(self):
+ os.kill(int(self.pid), signal.SIGINT)
+
diff --git a/test/soup/env/fake-session-bus.conf b/test/soup/env/fake-session-bus.conf
new file mode 100644
index 0000000..f9b4433
--- /dev/null
+++ b/test/soup/env/fake-session-bus.conf
@@ -0,0 +1,12 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd";>
+<busconfig>
+ <type>session</type>
+ <listen>unix:tmpdir=/tmp</listen>
+ <servicedir>/home/john/Projects/conduit/test/soup/tmp/dbus</servicedir>
+ <policy context="default">
+ <allow send_destination="*" eavesdrop="true"/>
+ <allow eavesdrop="true"/>
+ <allow own="*"/>
+ </policy>
+</busconfig>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]