3 # Copyright © 2016 Collabora Ltd.
5 # Permission is hereby granted, free of charge, to any person
6 # obtaining a copy of this software and associated documentation files
7 # (the "Software"), to deal in the Software without restriction,
8 # including without limitation the rights to use, copy, modify, merge,
9 # publish, distribute, sublicense, and/or sell copies of the Software,
10 # and to permit persons to whom the Software is furnished to do so,
11 # subject to the following conditions:
13 # The above copyright notice and this permission notice shall be
14 # included in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 export DBUS_DEBUG_OUTPUT=1
28 echo "# dbus-daemon binary: ${DBUS_TEST_DAEMON:=dbus-daemon}"
29 echo "# dbus-send binary: ${DBUS_TEST_DBUS_SEND:=dbus-send}"
31 if test -n "$DBUS_TEST_DATA"; then
32 echo "# test data: $DBUS_TEST_DATA"
33 config="--config-file=$DBUS_TEST_DATA/valid-config-files/session.conf"
34 elif test -n "$DBUS_TEST_DATADIR"; then
35 echo "# datadir: $DBUS_TEST_DATADIR"
36 config="--config-file=$DBUS_TEST_DATADIR/dbus-1/session.conf"
38 echo "# using standard session bus configuration"
42 if ! workdir="$(mktemp -d)"; then
43 echo "1..0 # SKIP - mktemp -d doesn't work"
49 unset DBUS_SESSION_BUS_ADDRESS
50 unset DBUS_SESSION_BUS_PID
51 rm -f "$workdir"/address "$workdir"/pid
53 ${DBUS_TEST_DAEMON} --fork --print-address=8 --print-pid=9 "$config" \
54 8>"$workdir/address" 9>"$workdir/pid"
56 export DBUS_SESSION_BUS_ADDRESS="$(cat "$workdir"/address)"
57 test -n "$DBUS_SESSION_BUS_ADDRESS"
58 DBUS_SESSION_BUS_PID="$(cat "$workdir"/pid)"
59 kill -0 "$DBUS_SESSION_BUS_PID"
61 ${DBUS_TEST_DBUS_SEND} --session --dest=org.freedesktop.DBus \
62 --type=method_call --print-reply / org.freedesktop.DBus.ListNames >&2
64 kill "$DBUS_SESSION_BUS_PID"
66 echo "ok 1 - normal dbus-daemon"
68 unset DBUS_SESSION_BUS_ADDRESS
69 unset DBUS_SESSION_BUS_PID
70 rm -f "$workdir"/address "$workdir"/pid
72 ${DBUS_TEST_DAEMON} --fork --print-address=8 --print-pid=9 "$config" \
73 8>"$workdir/address" 9>"$workdir/pid" <&-
75 export DBUS_SESSION_BUS_ADDRESS="$(cat "$workdir"/address)"
76 test -n "$DBUS_SESSION_BUS_ADDRESS"
77 DBUS_SESSION_BUS_PID="$(cat "$workdir"/pid)"
78 kill -0 "$DBUS_SESSION_BUS_PID"
80 ${DBUS_TEST_DBUS_SEND} --session --dest=org.freedesktop.DBus \
81 --type=method_call --print-reply / org.freedesktop.DBus.ListNames >&2
83 kill "$DBUS_SESSION_BUS_PID"
85 echo "ok 2 - dbus-daemon with stdin closed"
87 unset DBUS_SESSION_BUS_ADDRESS
88 unset DBUS_SESSION_BUS_PID
89 rm -f "$workdir"/address "$workdir"/pid
91 ${DBUS_TEST_DAEMON} --fork --print-address=8 --print-pid=9 "$config" \
92 8>"$workdir/address" 9>"$workdir/pid" <&- >&- 2>&-
94 export DBUS_SESSION_BUS_ADDRESS="$(cat "$workdir"/address)"
95 test -n "$DBUS_SESSION_BUS_ADDRESS"
96 DBUS_SESSION_BUS_PID="$(cat "$workdir"/pid)"
97 kill -0 "$DBUS_SESSION_BUS_PID"
99 ${DBUS_TEST_DBUS_SEND} --session --dest=org.freedesktop.DBus \
100 --type=method_call --print-reply / org.freedesktop.DBus.ListNames >&2
102 kill "$DBUS_SESSION_BUS_PID"
104 echo "ok 3 - dbus-daemon with stdin, stdout, stderr closed"