Merge branch 'dbus-1.4'
[platform/upstream/dbus.git] / tools / run-with-tmp-session-bus.sh
index ce077d7..c39999f 100755 (executable)
@@ -1,10 +1,10 @@
-#! /bin/bash
+#! /bin/sh
 
 SCRIPTNAME=$0
 WRAPPED_SCRIPT=$1
 shift
 
-function die() 
+die() 
 {
     if ! test -z "$DBUS_SESSION_BUS_PID" ; then
         echo "killing message bus "$DBUS_SESSION_BUS_PID >&2
@@ -19,34 +19,45 @@ if test -z "$DBUS_TOP_BUILDDIR" ; then
 fi
 
 ## convenient to be able to ctrl+C without leaking the message bus process
-trap 'die "Received SIGINT"' SIGINT
+trap 'die "Received SIGINT"' INT
 
 CONFIG_FILE=./run-with-tmp-session-bus.conf
 SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files"
 ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'`
 echo "escaped service dir is: $ESCAPED_SERVICE_DIR" >&2
 
+if test -z "$SOURCE_CONFIG_FILE"; then
+    SOURCE_CONFIG_FILE="$DBUS_TOP_BUILDDIR/bus/session.conf";
+fi
 ## create a configuration file based on the standard session.conf
-cat $DBUS_TOP_BUILDDIR/bus/session.conf |  \
-    sed -e 's/<servicedir>.*$/<servicedir>'$ESCAPED_SERVICE_DIR'<\/servicedir>/g' |  \
+cat $SOURCE_CONFIG_FILE |  \
+    sed -e 's/<standard_session_servicedirs.*$/<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
+if ! test -e "$DBUS_TOP_BUILDDIR"/bus/dbus-daemon ; then
+    die "$DBUS_TOP_BUILDDIR/bus/dbus-daemon does not exist"
+fi
 
+PATH="$DBUS_TOP_BUILDDIR"/bus:$PATH
+export PATH
+
+## the libtool script found by the path search should already do this, but
+LD_LIBRARY_PATH=$DBUS_TOP_BUILDDIR/dbus/.libs:$LD_LIBRARY_PATH
+export LD_LIBRARY_PATH
 unset DBUS_SESSION_BUS_ADDRESS
 unset DBUS_SESSION_BUS_PID
 
 echo "Running $DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE" >&2
 
+DBUS_USE_TEST_BINARY=1 
+export DBUS_USE_TEST_BINARY
 eval `$DBUS_TOP_BUILDDIR/tools/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"
+    die "Failed to launch message bus for test script to run"
 fi
 
 echo "Started bus pid $DBUS_SESSION_BUS_PID at $DBUS_SESSION_BUS_ADDRESS" >&2