1#! /bin/sh
2die()
3{
4    if ! test -z "$DBUS_SESSION_BUS_PID" ; then
5        echo "killing message bus "$DBUS_SESSION_BUS_PID >&2
6        kill -9 $DBUS_SESSION_BUS_PID
7    fi
8    echo $SCRIPTNAME: $* >&2
9
10    exit 1
11}
12
13SCRIPTNAME=$0
14MODE=$1
15
16## so the tests can complain if you fail to use the script to launch them
17DBUS_TEST_NAME_RUN_TEST_SCRIPT=1
18export DBUS_TEST_NAME_RUN_TEST_SCRIPT
19
20SOURCE_CONFIG_FILE=$DBUS_TOP_SRCDIR/test/name-test/tmp-session-like-system.conf
21export SOURCE_CONFIG_FILE
22# Rerun ourselves with tmp session bus if we're not already
23if test -z "$DBUS_TEST_NAME_IN_SYS_RUN_TEST"; then
24  DBUS_TEST_NAME_IN_SYS_RUN_TEST=1
25  export DBUS_TEST_NAME_IN_SYS_RUN_TEST
26  exec $DBUS_TOP_SRCDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE
27fi 
28
29if test -n "$DBUS_TEST_MONITOR"; then
30  dbus-monitor --session &
31fi
32
33echo "running test-expected-echo-fail"
34${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/tools/dbus-send --print-reply --dest=org.freedesktop.DBus.TestSuiteEchoService /org/freedesktop/TestSuite org.freedesktop.TestSuite.Echo string:hi >echo-error-output.tmp 2>&1
35if ! grep -q 'DBus.Error' echo-error-output.tmp; then
36  echo "Didn't get expected failure; output was:"
37  echo "====="
38  cat echo-error-output.tmp
39  echo "====="
40  exit 1
41fi
42
43echo "running test echo signal"
44if test "x$PYTHON" = "x:"; then
45  echo "Skipped test-echo-signal: Python interpreter not found"
46elif ! $PYTHON $DBUS_TOP_SRCDIR/test/name-test/test-wait-for-echo.py; then
47  echo "Failed test-wait-for-echo"
48  exit 1
49fi
50
51exit 0
52