From 2760681970f133676a096fa262716ee61f51c332 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 20 Jul 2016 13:31:50 +0100 Subject: [PATCH 10/10] test-dbus-daemon-fork: exercise closed stdin, stdout, stderr Signed-off-by: Simon McVittie --- test/test-dbus-daemon-fork.sh | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/test/test-dbus-daemon-fork.sh b/test/test-dbus-daemon-fork.sh index aefc2c6..1a7175d 100755 --- a/test/test-dbus-daemon-fork.sh +++ b/test/test-dbus-daemon-fork.sh @@ -44,7 +44,7 @@ if ! workdir="$(mktemp -d)"; then exit 0 fi -echo "1..1" +echo "1..3" unset DBUS_SESSION_BUS_ADDRESS unset DBUS_SESSION_BUS_PID @@ -65,4 +65,42 @@ kill "$DBUS_SESSION_BUS_PID" echo "ok 1 - normal dbus-daemon" +unset DBUS_SESSION_BUS_ADDRESS +unset DBUS_SESSION_BUS_PID +rm -f "$workdir"/address "$workdir"/pid + +${DBUS_TEST_DAEMON} --fork --print-address=8 --print-pid=9 "$config" \ + 8>"$workdir/address" 9>"$workdir/pid" <&- + +export DBUS_SESSION_BUS_ADDRESS="$(cat "$workdir"/address)" +test -n "$DBUS_SESSION_BUS_ADDRESS" +DBUS_SESSION_BUS_PID="$(cat "$workdir"/pid)" +kill -0 "$DBUS_SESSION_BUS_PID" + +${DBUS_TEST_DBUS_SEND} --session --dest=org.freedesktop.DBus \ + --type=method_call --print-reply / org.freedesktop.DBus.ListNames >&2 + +kill "$DBUS_SESSION_BUS_PID" + +echo "ok 2 - dbus-daemon with stdin closed" + +unset DBUS_SESSION_BUS_ADDRESS +unset DBUS_SESSION_BUS_PID +rm -f "$workdir"/address "$workdir"/pid + +${DBUS_TEST_DAEMON} --fork --print-address=8 --print-pid=9 "$config" \ + 8>"$workdir/address" 9>"$workdir/pid" <&- >&- 2>&- + +export DBUS_SESSION_BUS_ADDRESS="$(cat "$workdir"/address)" +test -n "$DBUS_SESSION_BUS_ADDRESS" +DBUS_SESSION_BUS_PID="$(cat "$workdir"/pid)" +kill -0 "$DBUS_SESSION_BUS_PID" + +${DBUS_TEST_DBUS_SEND} --session --dest=org.freedesktop.DBus \ + --type=method_call --print-reply / org.freedesktop.DBus.ListNames >&2 + +kill "$DBUS_SESSION_BUS_PID" + +echo "ok 3 - dbus-daemon with stdin, stdout, stderr closed" + rm -r "$workdir" -- 2.8.1