9 if ! test -z "$DBUS_SESSION_BUS_PID" ; then
10 echo "killing message bus "$DBUS_SESSION_BUS_PID >&2
11 kill -9 $DBUS_SESSION_BUS_PID
13 echo $SCRIPTNAME: $* >&2
17 if test -z "$DBUS_TOP_BUILDDIR" ; then
18 die "Must set DBUS_TOP_BUILDDIR"
21 ## convenient to be able to ctrl+C without leaking the message bus process
22 trap 'die "Received SIGINT"' INT
24 CONFIG_FILE=./run-with-tmp-session-bus.conf
25 SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files"
26 ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'`
27 echo "escaped service dir is: $ESCAPED_SERVICE_DIR" >&2
29 ## create a configuration file based on the standard session.conf
30 cat $DBUS_TOP_BUILDDIR/bus/session.conf | \
31 sed -e 's/<servicedir>.*$/<servicedir>'$ESCAPED_SERVICE_DIR'<\/servicedir>/g' | \
32 sed -e 's/<include.*$//g' \
35 echo "Created configuration file $CONFIG_FILE" >&2
37 if ! test -e "$DBUS_TOP_BUILDDIR"/bus/dbus-daemon ; then
38 die "$DBUS_TOP_BUILDDIR/bus/dbus-daemon does not exist"
41 export PATH="$DBUS_TOP_BUILDDIR"/bus:$PATH
42 ## the libtool script found by the path search should already do this, but
43 export LD_LIBRARY_PATH=$DBUS_TOP_BUILDDIR/dbus/.libs:$LD_LIBRARY_PATH
45 unset DBUS_SESSION_BUS_ADDRESS
46 unset DBUS_SESSION_BUS_PID
48 echo "Running $DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE" >&2
50 eval `$DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE`
52 if test -z "$DBUS_SESSION_BUS_PID" ; then
53 die "Failed to launch message bus for test script to run"
56 echo "Started bus pid $DBUS_SESSION_BUS_PID at $DBUS_SESSION_BUS_ADDRESS" >&2
58 # Execute wrapped script
59 echo "Running $WRAPPED_SCRIPT $@" >&2
60 $WRAPPED_SCRIPT "$@" || die "script \"$WRAPPED_SCRIPT\" failed"
62 kill -TERM $DBUS_SESSION_BUS_PID || die "Message bus vanished! should not have happened" && echo "Killed daemon $DBUS_SESSION_BUS_PID" >&2
66 ## be sure it really died
67 kill -9 $DBUS_SESSION_BUS_PID > /dev/null 2>&1 || true