Imported Upstream version 1.5.12
[platform/upstream/dbus.git] / test / name-test / run-test-systemserver.sh
1 #! /bin/sh
2 die()
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
13 SCRIPTNAME=$0
14 MODE=$1
15
16 ## so the tests can complain if you fail to use the script to launch them
17 DBUS_TEST_NAME_RUN_TEST_SCRIPT=1
18 export DBUS_TEST_NAME_RUN_TEST_SCRIPT
19
20 SOURCE_CONFIG_FILE=$DBUS_TOP_SRCDIR/test/name-test/tmp-session-like-system.conf
21 export SOURCE_CONFIG_FILE
22 # Rerun ourselves with tmp session bus if we're not already
23 if 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
27 fi 
28
29 if test -n "$DBUS_TEST_MONITOR"; then
30   dbus-monitor --session &
31 fi
32
33 echo "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
35 if ! 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
41 fi
42
43 echo "running test echo signal"
44 if test "x$PYTHON" = "x:"; then
45   echo "Skipped test-echo-signal: Python interpreter not found"
46 elif ! $PYTHON $DBUS_TOP_SRCDIR/test/name-test/test-wait-for-echo.py; then
47   echo "Failed test-wait-for-echo"
48   exit 1
49 fi
50
51 exit 0