summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANIFEST.in2
-rw-r--r--setup.py29
-rw-r--r--test/dbus_python_check.py48
-rwxr-xr-xtest/run-test.sh39
-rwxr-xr-xtest/test-client.py307
-rwxr-xr-xtest/test-service.py142
-rwxr-xr-xtools/run-with-tmp-session-bus.sh65
-rw-r--r--tools/session.conf24
8 files changed, 642 insertions, 14 deletions
diff --git a/MANIFEST.in b/MANIFEST.in
index c94ad7d..41ab0b4 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -7,5 +7,5 @@ include dbus/dbus_bindings.pyx
include dbus/dbus_glib_bindings.pyx
include dbus/dbus_bindings.pxd.in
include dbus/dbus_bindings.pxd
-
+recursive-include test *.py *.sh
diff --git a/setup.py b/setup.py
index 5b18002..65b2845 100644
--- a/setup.py
+++ b/setup.py
@@ -10,6 +10,9 @@ from Pyrex.Distutils import build_ext
import extract
+sys.path.append("test")
+from dbus_python_check import dbus_python_check
+
def remove(filename):
if os.path.exists(filename):
os.remove(filename)
@@ -74,19 +77,19 @@ setup(
author_email='johnp@redhat.com',
maintainer='John (J5) Palmieri',
maintainer_email='johnp@redhat.com',
- package_dir={'':'dbus'},
+ package_dir={'dbus':'dbus'},
py_modules=[
- "_dbus",
- "exceptions",
- "glib",
- "__init__",
- "matchrules",
- "service",
- "types",
- "decorators",
- "introspect_parser",
- "proxies",
- "_util",
+ "dbus/_dbus",
+ "dbus/exceptions",
+ "dbus/glib",
+ "dbus/__init__",
+ "dbus/matchrules",
+ "dbus/service",
+ "dbus/types",
+ "dbus/decorators",
+ "dbus/introspect_parser",
+ "dbus/proxies",
+ "dbus/_util",
],
ext_modules=[
Extension("dbus_bindings", ["dbus/dbus_bindings.pyx"],
@@ -102,7 +105,7 @@ setup(
],
),
],
- cmdclass={'build_ext': build_ext, 'clean': full_clean}
+ cmdclass={'build_ext': build_ext, 'clean': full_clean, 'check': dbus_python_check}
)
# vim:ts=4:sw=4:tw=80:si:ai:showmatch:et
diff --git a/test/dbus_python_check.py b/test/dbus_python_check.py
new file mode 100644
index 0000000..fb6f010
--- /dev/null
+++ b/test/dbus_python_check.py
@@ -0,0 +1,48 @@
+"""dbus_python_check
+
+Implements the Distutils 'check' command.
+"""
+
+# created 2006/07/12, John (J5) Palmieri
+
+__revision__ = "0.1"
+
+from distutils.core import Command
+from distutils.command.build import build
+from distutils.dist import Distribution
+import os
+
+class dbus_python_check (Command):
+
+ # Brief (40-50 characters) description of the command
+ description = "Runs tests in this package"
+
+ # List of option tuples: long name, short name (None if no short
+ # name), and help string.
+ user_options = [('help', '?',
+ "Shows Help"),
+ ]
+
+
+ def initialize_options (self):
+ self.dummy = None
+
+ # initialize_options()
+
+
+ def finalize_options (self):
+ pass
+ # finalize_options()
+
+ def run (self):
+ b = build(self.distribution)
+ b.finalize_options()
+ b.run()
+ top_builddir = os.path.join (os.getcwd(), b.build_lib)
+ cmd = 'DBUS_TOP_BUILDDIR="%s" test/run-test.sh'%top_builddir
+ print cmd
+ os.system (cmd)
+
+ # run()
+
+# class check
diff --git a/test/run-test.sh b/test/run-test.sh
new file mode 100755
index 0000000..6aa01cb
--- /dev/null
+++ b/test/run-test.sh
@@ -0,0 +1,39 @@
+#! /bin/bash
+
+function die()
+{
+ if ! test -z "$DBUS_SESSION_BUS_PID" ; then
+ echo "killing message bus "$DBUS_SESSION_BUS_PID >&2
+ kill -9 $DBUS_SESSION_BUS_PID
+ fi
+ echo $SCRIPTNAME: $* >&2
+
+ exit 1
+}
+
+
+SCRIPTNAME=$0
+MODE=$1
+
+## so the tests can complain if you fail to use the script to launch them
+export DBUS_TEST_PYTHON_RUN_TEST_SCRIPT=1
+export LD_LIBRARY_PATH="$DBUS_TOP_BUILDDIR/dbus"
+# Rerun ourselves with tmp session bus if we're not already
+if test -z "$DBUS_TEST_PYTHON_IN_RUN_TEST"; then
+ DBUS_TEST_PYTHON_IN_RUN_TEST=1
+ export DBUS_TEST_PYTHON_IN_RUN_TEST
+ exec tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE
+fi
+
+#create service file
+SERVICE_DIR=test/data/valid-service-files/
+SERVICE_FILE=$SERVICE_DIR/test-python.service
+mkdir -p $SERVICE_DIR
+echo "[D-BUS Service]" > $SERVICE_FILE
+echo "Name=org.freedesktop.DBus.TestSuitePythonService" >> $SERVICE_FILE
+echo "Exec=`pwd`/test/test-service.py" >> $SERVICE_FILE
+
+
+echo "running test-client.py"
+test/test-client.py || die "test-client.py failed"
+
diff --git a/test/test-client.py b/test/test-client.py
new file mode 100755
index 0000000..a68e4c8
--- /dev/null
+++ b/test/test-client.py
@@ -0,0 +1,307 @@
+#!/usr/bin/env python
+import sys
+import os
+import unittest
+import time
+
+builddir = os.environ["DBUS_TOP_BUILDDIR"]
+pydir = builddir
+
+sys.path.insert(0, pydir)
+sys.path.insert(0, pydir + 'dbus')
+
+import dbus
+import dbus_bindings
+import gobject
+import dbus.glib
+import dbus.service
+
+pkg = dbus.__file__
+if not pkg.startswith(pydir):
+ raise Exception("DBus modules (%s) are not being picked up from the package"%pkg)
+
+if not dbus_bindings.__file__.startswith(pydir):
+ raise Exception("DBus modules (%s) are not being picked up from the package"%dbus_bindings.__file__)
+
+test_types_vals = [1, 12323231, 3.14159265, 99999999.99,
+ "dude", "123", "What is all the fuss about?", "gob@gob.com",
+ u'\\u310c\\u310e\\u3114', u'\\u0413\\u0414\\u0415',
+ u'\\u2200software \\u2203crack', u'\\xf4\\xe5\\xe8',
+ [1,2,3], ["how", "are", "you"], [1.23,2.3], [1], ["Hello"],
+ (1,2,3), (1,), (1,"2",3), ("2", "what"), ("you", 1.2),
+ {1:"a", 2:"b"}, {"a":1, "b":2}, #{"a":(1,"B")},
+ {1:1.1, 2:2.2}, [[1,2,3],[2,3,4]], [["a","b"],["c","d"]],
+ True, False,
+ dbus.Int16(-10), dbus.UInt16(10),
+ #([1,2,3],"c", 1.2, ["a","b","c"], {"a": (1,"v"), "b": (2,"d")})
+ ]
+
+class TestDBusBindings(unittest.TestCase):
+ def setUp(self):
+ self.bus = dbus.SessionBus()
+ self.remote_object = self.bus.get_object("org.freedesktop.DBus.TestSuitePythonService", "/org/freedesktop/DBus/TestSuitePythonObject")
+ self.iface = dbus.Interface(self.remote_object, "org.freedesktop.DBus.TestSuiteInterface")
+
+ def testInterfaceKeyword(self):
+ #test dbus_interface parameter
+ print self.remote_object.Echo("dbus_interface on Proxy test Passed", dbus_interface = "org.freedesktop.DBus.TestSuiteInterface")
+ print self.iface.Echo("dbus_interface on Interface test Passed", dbus_interface = "org.freedesktop.DBus.TestSuiteInterface")
+ self.assert_(True)
+
+ def testIntrospection(self):
+ #test introspection
+ print "\n********* Introspection Test ************"
+ print self.remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable")
+ print "Introspection test passed"
+ self.assert_(True)
+
+ def testPythonTypes(self):
+ #test sending python types and getting them back
+ print "\n********* Testing Python Types ***********"
+
+ for send_val in test_types_vals:
+ print "Testing %s"% str(send_val)
+ recv_val = self.iface.Echo(send_val)
+ self.assertEquals(send_val, recv_val)
+
+ def testBenchmarkIntrospect(self):
+ print "\n********* Benchmark Introspect ************"
+ a = time.time()
+ print a
+ print self.iface.GetComplexArray()
+ b = time.time()
+ print b
+ print "Delta: %f" % (b - a)
+ self.assert_(True)
+
+ def testAsyncCalls(self):
+ #test sending python types and getting them back async
+ print "\n********* Testing Async Calls ***********"
+
+
+ main_loop = gobject.MainLoop()
+ class async_check:
+ def __init__(self, test_controler, expected_result, do_exit):
+ self.expected_result = expected_result
+ self.do_exit = do_exit
+ self.test_controler = test_controler
+
+ def callback(self, val):
+ try:
+ if self.do_exit:
+ main_loop.quit()
+
+ self.test_controler.assertEquals(val, self.expected_result)
+ except Exception, e:
+ print "%s:\n%s" % (e.__class__, e)
+
+ def error_handler(self, error):
+ print error
+ if self.do_exit:
+ main_loop.quit()
+
+ self.test_controler.assert_(val, False)
+
+ last_type = test_types_vals[-1]
+ for send_val in test_types_vals:
+ print "Testing %s"% str(send_val)
+ check = async_check(self, send_val, last_type == send_val)
+ recv_val = self.iface.Echo(send_val,
+ reply_handler = check.callback,
+ error_handler = check.error_handler)
+
+ main_loop.run()
+
+ def testStrictMarshalling(self):
+ print "\n********* Testing strict return & signal marshalling ***********"
+
+ # these values are the same as in the server, and the
+ # methods should only succeed when they are called with
+ # the right value number, because they have out_signature
+ # decorations, and return an unmatching type when called
+ # with a different number
+ values = ["", ("",""), ("","",""), [], {}, ["",""], ["","",""]]
+ methods = [
+ (self.iface.ReturnOneString, 'SignalOneString', set([0]), set([0])),
+ (self.iface.ReturnTwoStrings, 'SignalTwoStrings', set([1, 5]), set([5])),
+ (self.iface.ReturnStruct, 'SignalStruct', set([1, 5]), set([1])),
+ # all of our test values are sequences so will marshall correctly into an array :P
+ (self.iface.ReturnArray, 'SignalArray', set(range(len(values))), set([3, 5, 6])),
+ (self.iface.ReturnDict, 'SignalDict', set([0, 3, 4]), set([4]))
+ ]
+
+ for (method, signal, success_values, return_values) in methods:
+ print "\nTrying correct behaviour of", method._method_name
+ for value in range(len(values)):
+ try:
+ ret = method(value)
+ except Exception, e:
+ print "%s(%r) raised %s" % (method._method_name, values[value], e.__class__)
+
+ # should fail if it tried to marshal the wrong type
+ self.assert_(value not in success_values, "%s should succeed when we ask it to return %r\n%s\n%s" % (method._method_name, values[value], e.__class__, e))
+ else:
+ print "%s(%r) returned %r" % (method._method_name, values[value], ret)
+
+ # should only succeed if it's the right return type
+ self.assert_(value in success_values, "%s should fail when we ask it to return %r" % (method._method_name, values[value]))
+
+ # check the value is right too :D
+ returns = map(lambda n: values[n], return_values)
+ self.assert_(ret in returns, "%s should return one of %r" % (method._method_name, returns))
+
+ print "\nTrying correct emission of", signal
+ for value in range(len(values)):
+ try:
+ self.iface.EmitSignal(signal, value)
+ except Exception, e:
+ print "EmitSignal(%s, %r) raised %s" % (signal, values[value], e.__class__)
+
+ # should fail if it tried to marshal the wrong type
+ self.assert_(value not in success_values, "EmitSignal(%s) should succeed when we ask it to return %r\n%s\n%s" % (signal, values[value], e.__class__, e))
+ else:
+ print "EmitSignal(%s, %r) appeared to succeed" % (signal, values[value])
+
+ # should only succeed if it's the right return type
+ self.assert_(value in success_values, "EmitSignal(%s) should fail when we ask it to return %r" % (signal, values[value]))
+
+ # FIXME: wait for the signal here
+
+ print
+
+ def testInheritance(self):
+ print "\n********* Testing inheritance from dbus.method.Interface ***********"
+ ret = self.iface.CheckInheritance()
+ print "CheckInheritance returned %s" % ret
+ self.assert_(ret, "overriding CheckInheritance from TestInterface failed")
+
+ def testAsyncMethods(self):
+ print "\n********* Testing asynchronous method implementation *******"
+ for (async, fail) in ((False, False), (False, True), (True, False), (True, True)):
+ try:
+ val = ('a', 1, False, [1,2], {1:2})
+ print "calling AsynchronousMethod with %s %s %s" % (async, fail, val)
+ ret = self.iface.AsynchronousMethod(async, fail, val)
+ except Exception, e:
+ print "%s:\n%s" % (e.__class__, e)
+ self.assert_(fail)
+ else:
+ self.assert_(not fail)
+ print val, ret
+ self.assert_(val == ret)
+
+ def testBusInstanceCaching(self):
+ print "\n********* Testing dbus.Bus instance sharing *********"
+
+ # unfortunately we can't test the system bus here
+ # but the codepaths are the same
+ for (cls, type, func) in ((dbus.SessionBus, dbus.Bus.TYPE_SESSION, dbus.Bus.get_session), (dbus.StarterBus, dbus.Bus.TYPE_STARTER, dbus.Bus.get_starter)):
+ print "\nTesting %s:" % cls.__name__
+
+ share_cls = cls()
+ share_type = dbus.Bus(bus_type=type)
+ share_func = func()
+
+ private_cls = cls(private=True)
+ private_type = dbus.Bus(bus_type=type, private=True)
+ private_func = func(private=True)
+
+ print " - checking shared instances are the same..."
+ self.assert_(share_cls == share_type, '%s should equal %s' % (share_cls, share_type))
+ self.assert_(share_type == share_func, '%s should equal %s' % (share_type, share_func))
+
+ print " - checking private instances are distinct from the shared instance..."
+ self.assert_(share_cls != private_cls, '%s should not equal %s' % (share_cls, private_cls))
+ self.assert_(share_type != private_type, '%s should not equal %s' % (share_type, private_type))
+ self.assert_(share_func != private_func, '%s should not equal %s' % (share_func, private_func))
+
+ print " - checking private instances are distinct from each other..."
+ self.assert_(private_cls != private_type, '%s should not equal %s' % (private_cls, private_type))
+ self.assert_(private_type != private_func, '%s should not equal %s' % (private_type, private_func))
+ self.assert_(private_func != private_cls, '%s should not equal %s' % (private_func, private_cls))
+
+ def testSenderName(self):
+ print '\n******** Testing sender name keyword ********'
+ myself = self.iface.WhoAmI()
+ print "I am", myself
+
+ def testBusNameCreation(self):
+ print '\n******** Testing BusName creation ********'
+ test = [('org.freedesktop.DBus.Python.TestName', True),
+ ('org.freedesktop.DBus.Python.TestName', True),
+ ('org.freedesktop.DBus.Python.InvalidName&^*%$', False)]
+ # Do some more intelligent handling/testing of queueing vs success?
+ # ('org.freedesktop.DBus.TestSuitePythonService', False)]
+ # For some reason this actually succeeds
+ # ('org.freedesktop.DBus', False)]
+
+ # make a method call to ensure the test service is active
+ self.iface.Echo("foo")
+
+ names = {}
+ for (name, succeed) in test:
+ try:
+ print "requesting %s" % name
+ busname = dbus.service.BusName(name)
+ except Exception, e:
+ print "%s:\n%s" % (e.__class__, e)
+ self.assert_(not succeed, 'did not expect registering bus name %s to fail' % name)
+ else:
+ print busname
+ self.assert_(succeed, 'expected registering bus name %s to fail'% name)
+ if name in names:
+ self.assert_(names[name] == busname, 'got a new instance for same name %s' % name)
+ print "instance of %s re-used, good!" % name
+ else:
+ names[name] = busname
+
+ del busname
+
+ print
+
+ del names
+
+ bus = dbus.Bus()
+ ret = dbus.dbus_bindings.bus_name_has_owner(bus._connection, 'org.freedesktop.DBus.Python.TestName')
+ self.assert_(not ret, 'deleting reference failed to release BusName org.freedesktop.DBus.Python.TestName')
+
+""" Remove this for now
+class TestDBusPythonToGLibBindings(unittest.TestCase):
+ def setUp(self):
+ self.bus = dbus.SessionBus()
+ self.remote_object = self.bus.get_object("org.freedesktop.DBus.TestSuiteGLibService", "/org/freedesktop/DBus/Tests/MyTestObject")
+ self.iface = dbus.Interface(self.remote_object, "org.freedesktop.DBus.Tests.MyObject")
+
+ def testIntrospection(self):
+ #test introspection
+ print "\n********* Introspection Test ************"
+ print self.remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable")
+ print "Introspection test passed"
+ self.assert_(True)
+
+ def testCalls(self):
+ print "\n********* Call Test ************"
+ result = self.iface.ManyArgs(1000, 'Hello GLib', 2)
+ print result
+ self.assert_(result == [2002.0, 'HELLO GLIB'])
+
+ arg0 = {"Dude": 1, "john": "palmieri", "python": 2.4}
+ result = self.iface.ManyStringify(arg0)
+ print result
+
+ print "Call test passed"
+ self.assert_(True)
+
+ def testPythonTypes(self):
+ print "\n********* Testing Python Types ***********"
+
+ for send_val in test_types_vals:
+ print "Testing %s"% str(send_val)
+ recv_val = self.iface.EchoVariant(send_val)
+ self.assertEquals(send_val, recv_val)
+"""
+if __name__ == '__main__':
+ gobject.threads_init()
+ dbus.glib.init_threads()
+
+ unittest.main()
diff --git a/test/test-service.py b/test/test-service.py
new file mode 100755
index 0000000..975ea79
--- /dev/null
+++ b/test/test-service.py
@@ -0,0 +1,142 @@
+#!/usr/bin/env python
+import sys
+import os
+
+builddir = os.environ["DBUS_TOP_BUILDDIR"]
+pydir = builddir
+
+sys.path.insert(0, pydir)
+sys.path.insert(0, pydir + 'dbus')
+
+import dbus
+
+if not dbus.__file__.startswith(pydir):
+ os.system("echo %s> /tmp/dbus.log"%pydir)
+ raise Exception("DBus modules are not being picked up from the package")
+
+import dbus.service
+import dbus.glib
+import gobject
+import random
+
+class TestInterface(dbus.service.Interface):
+ @dbus.service.method("org.freedesktop.DBus.TestSuiteInterface", in_signature='', out_signature='b')
+ def CheckInheritance(self):
+ return False
+
+class TestObject(dbus.service.Object, TestInterface):
+ def __init__(self, bus_name, object_path="/org/freedesktop/DBus/TestSuitePythonObject"):
+ dbus.service.Object.__init__(self, bus_name, object_path)
+
+ """ Echo whatever is sent
+ """
+ @dbus.service.method("org.freedesktop.DBus.TestSuiteInterface")
+ def Echo(self, arg):
+ return arg
+
+ @dbus.service.method("org.freedesktop.DBus.TestSuiteInterface")
+ def GetComplexArray(self):
+ ret = []
+ for i in range(0,100):
+ ret.append((random.randint(0,100), random.randint(0,100), str(random.randint(0,100))))
+
+ return dbus.Array(ret, signature="(uus)")
+
+ def returnValue(self, test):
+ if test == 0:
+ return ""
+ elif test == 1:
+ return "",""
+ elif test == 2:
+ return "","",""
+ elif test == 3:
+ return []
+ elif test == 4:
+ return {}
+ elif test == 5:
+ return ["",""]
+ elif test == 6:
+ return ["","",""]
+
+ @dbus.service.method("org.freedesktop.DBus.TestSuiteInterface", in_signature='u', out_signature='s')
+ def ReturnOneString(self, test):
+ return self.returnValue(test)
+
+ @dbus.service.method("org.freedesktop.DBus.TestSuiteInterface", in_signature='u', out_signature='ss')
+ def ReturnTwoStrings(self, test):
+ return self.returnValue(test)
+
+ @dbus.service.method("org.freedesktop.DBus.TestSuiteInterface", in_signature='u', out_signature='(ss)')
+ def ReturnStruct(self, test):
+ return self.returnValue(test)
+
+ @dbus.service.method("org.freedesktop.DBus.TestSuiteInterface", in_signature='u', out_signature='as')
+ def ReturnArray(self, test):
+ return self.returnValue(test)
+
+ @dbus.service.method("org.freedesktop.DBus.TestSuiteInterface", in_signature='u', out_signature='a{ss}')
+ def ReturnDict(self, test):
+ return self.returnValue(test)
+
+ @dbus.service.signal("org.freedesktop.DBus.TestSuiteInterface", signature='s')
+ def SignalOneString(self, test):
+ pass
+
+ @dbus.service.signal("org.freedesktop.DBus.TestSuiteInterface", signature='ss')
+ def SignalTwoStrings(self, test, test2):
+ pass
+
+ @dbus.service.signal("org.freedesktop.DBus.TestSuiteInterface", signature='(ss)')
+ def SignalStruct(self, test):
+ pass
+
+ @dbus.service.signal("org.freedesktop.DBus.TestSuiteInterface", signature='as')
+ def SignalArray(self, test):
+ pass
+
+ @dbus.service.signal("org.freedesktop.DBus.TestSuiteInterface", signature='a{ss}')
+ def SignalDict(self, test):
+ pass
+
+ @dbus.service.method("org.freedesktop.DBus.TestSuiteInterface", in_signature='su', out_signature='')
+ def EmitSignal(self, signal, value):
+ sig = getattr(self, signal, None)
+ assert(sig != None)
+
+ val = self.returnValue(value)
+ # make two string case work by passing arguments in by tuple
+ if (signal == 'SignalTwoStrings' and (value == 1 or value == 5)):
+ val = tuple(val)
+ else:
+ val = tuple([val])
+
+ sig(*val)
+
+ def CheckInheritance(self):
+ return True
+
+ @dbus.service.method('org.freedesktop.DBus.TestSuiteInterface', in_signature='bbv', out_signature='v', async_callbacks=('return_cb', 'error_cb'))
+ def AsynchronousMethod(self, async, fail, variant, return_cb, error_cb):
+ try:
+ if async:
+ gobject.timeout_add(500, self.AsynchronousMethod, False, fail, variant, return_cb, error_cb)
+ return
+ else:
+ if fail:
+ raise RuntimeError
+ else:
+ return_cb(variant)
+
+ return False # do not run again
+ except Exception, e:
+ error_cb(e)
+
+ @dbus.service.method('org.freedesktop.DBus.TestSuiteInterface', in_signature='', out_signature='s', sender_keyword='sender')
+ def WhoAmI(self, sender):
+ return sender
+
+session_bus = dbus.SessionBus()
+name = dbus.service.BusName("org.freedesktop.DBus.TestSuitePythonService", bus=session_bus)
+object = TestObject(name)
+loop = gobject.MainLoop()
+loop.run()
diff --git a/tools/run-with-tmp-session-bus.sh b/tools/run-with-tmp-session-bus.sh
new file mode 100755
index 0000000..0ebf228
--- /dev/null
+++ b/tools/run-with-tmp-session-bus.sh
@@ -0,0 +1,65 @@
+#! /bin/bash
+
+SCRIPTNAME=$0
+WRAPPED_SCRIPT=$1
+shift
+
+function die()
+{
+ if ! test -z "$DBUS_SESSION_BUS_PID" ; then
+ echo "killing message bus "$DBUS_SESSION_BUS_PID >&2
+ kill -9 $DBUS_SESSION_BUS_PID
+ fi
+ echo $SCRIPTNAME: $* >&2
+ exit 1
+}
+
+if test -z "$DBUS_TOP_BUILDDIR" ; then
+ die "Must set DBUS_TOP_BUILDDIR"
+fi
+
+## convenient to be able to ctrl+C without leaking the message bus process
+trap 'die "Received SIGINT"' SIGINT
+
+CONFIG_FILE=./run-with-tmp-session-bus.conf
+SERVICE_DIR="`pwd`/test/data/valid-service-files"
+ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'`
+echo "escaped service dir is: $ESCAPED_SERVICE_DIR" >&2
+
+## create a configuration file based on the standard session.conf
+cat tools/session.conf | \
+ sed -e 's/<servicedir>.*$/<servicedir>'$ESCAPED_SERVICE_DIR'<\/servicedir>/g' | \
+ sed -e 's/<include.*$//g' \
+ > $CONFIG_FILE
+
+echo "Created configuration file $CONFIG_FILE" >&2
+
+export PATH=$DBUS_TOP_BUILDDIR/bus:$PATH
+## the libtool script found by the path search should already do this, but
+export LD_LIBRARY_PATH=$DBUS_TOP_BUILDDIR/dbus/.libs:$LD_LIBRARY_PATH
+
+unset DBUS_SESSION_BUS_ADDRESS
+unset DBUS_SESSION_BUS_PID
+
+#export DBUS_VERBOSE=1
+echo "Running dbus-launch --sh-syntax --config-file=$CONFIG_FILE" >&2
+eval `dbus-launch --sh-syntax --config-file=$CONFIG_FILE`
+
+if test -z "$DBUS_SESSION_BUS_PID" ; then
+ die "Failed to launch message bus for introspection generation to run"
+fi
+
+echo "Started bus pid $DBUS_SESSION_BUS_PID at $DBUS_SESSION_BUS_ADDRESS" >&2
+
+# Execute wrapped script
+echo "Running $WRAPPED_SCRIPT $@" >&2
+$WRAPPED_SCRIPT "$@" || die "script \"$WRAPPED_SCRIPT\" failed"
+
+kill -TERM $DBUS_SESSION_BUS_PID || die "Message bus vanished! should not have happened" && echo "Killed daemon $DBUS_SESSION_BUS_PID" >&2
+
+sleep 2
+
+## be sure it really died
+kill -9 $DBUS_SESSION_BUS_PID > /dev/null 2>&1 || true
+
+exit 0
diff --git a/tools/session.conf b/tools/session.conf
new file mode 100644
index 0000000..73a38f1
--- /dev/null
+++ b/tools/session.conf
@@ -0,0 +1,24 @@
+<!-- This configuration file controls the per-user-login-session message bus.
+ Add a session-local.conf and edit that rather than changing this
+ file directly. -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <!-- Our well-known bus type, don't change this -->
+ <type>session</type>
+
+ <listen>unix:tmpdir=./</listen>
+
+ <servicedir></servicedir>
+
+ <policy context="default">
+ <!-- Allow everything to be sent -->
+ <allow send_destination="*"/>
+ <!-- Allow everything to be received -->
+ <allow eavesdrop="true"/>
+ <!-- Allow anyone to own anything -->
+ <allow own="*"/>
+ </policy>
+
+</busconfig>