]> code.delx.au - pulseaudio/blob - src/tests/test-daemon.sh
sink-input, source-output: Add hooks for mute changes
[pulseaudio] / src / tests / test-daemon.sh
1 #!/bin/sh
2 #
3 # This script is modified from dbus's run-with-temp-session-bus.sh.
4 #
5
6 SCRIPTNAME="$0"
7
8 die()
9 {
10 if ! test -z "$DBUS_SESSION_BUS_PID" ; then
11 echo "killing message bus "$DBUS_SESSION_BUS_PID >&2
12 kill -9 $DBUS_SESSION_BUS_PID
13 fi
14 echo $SCRIPTNAME: $* >&2
15 exit 1
16 }
17
18 ## convenient to be able to ctrl+C without leaking the message bus process
19 trap 'die "Received SIGINT"' INT
20
21 unset DBUS_SESSION_BUS_ADDRESS
22 unset DBUS_SESSION_BUS_PID
23
24 echo "Running dbus-launch --sh-syntax" >&2
25
26 eval `dbus-launch --sh-syntax`
27
28 if test -z "$DBUS_SESSION_BUS_PID" ; then
29 die "Failed to launch message bus for test script to run"
30 fi
31
32 echo "Started bus pid $DBUS_SESSION_BUS_PID at $DBUS_SESSION_BUS_ADDRESS" >&2
33
34 TEMP_PULSE_DIR=`mktemp -d`
35 export PULSE_RUNTIME_PATH=${TEMP_PULSE_DIR}
36
37 # this script would be called inside src/ directory, so we need to use the correct path.
38 # notice that for tests, we don't load ALSA related modules.
39 pulseaudio -n \
40 --log-target=file:${PWD}/pulse-daemon.log \
41 --log-level=debug \
42 --load="module-null-sink" \
43 --load="module-null-source" \
44 --load="module-suspend-on-idle" \
45 --load="module-native-protocol-unix" \
46 --load="module-cli-protocol-unix" \
47 --dl-search-path="$(dirname $SCRIPTNAME)/.libs/" \
48 &
49
50 # wait a few seconds to let the daemon start!
51 sleep 5
52
53 unset DISPLAY
54
55 EXIT_CODE=0
56
57 for ONE_TEST in $@; do
58 ${ONE_TEST} || EXIT_CODE=1
59 done
60
61 # terminate the designated pulseaudio daemon
62 pacmd exit
63
64 wait
65
66 kill -TERM $DBUS_SESSION_BUS_PID || die "Message bus vanished! should not have happened" && echo "Killed daemon $DBUS_SESSION_BUS_PID" >&2
67
68 sleep 2
69
70 ## be sure it really died
71 kill -9 $DBUS_SESSION_BUS_PID > /dev/null 2>&1 || true
72
73 exit $EXIT_CODE