1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#!/bin/sh
# Setup
echo "# Starting dbus-daemon..."
dbus-daemon \
--session \
--print-address=9 9>address.out \
>dbus-daemon.log 2>&1 \
&
echo "# Waiting for dbus-daemon..."
for i in $(seq 0 9)
do
export DBUS_SESSION_BUS_ADDRESS=$(cat address.out)
test "$DBUS_SESSION_BUS_ADDRESS" && break
sleep 1
done
echo "# Starting libvirt-dbus..."
libvirt-dbus \
--session \
>libvirt-dbus.log 2>&1 \
&
# Test
echo \
'ao 1 "/org/libvirt/Test/domain/_6695eb01_f6a4_8304_79aa_97f2502e193f"' \
>expected.log
echo "# Listing domains..."
for i in $(seq 0 9)
do
busctl \
--user call \
org.libvirt /org/libvirt/Test \
org.libvirt.Connect ListDomains u 0 \
>actual.log 2>&1
diff -Naru expected.log actual.log
rc=$?
test $rc -eq 0 && break
sleep 1
done
# Teardown
echo "# Stopping libvirt-dbus..."
pkill -P $$ libvirt-dbus
echo "# Stopping dbus-daemon..."
pkill -P $$ dbus-daemon
test $rc -eq 0 || {
cat dbus-daemon.log libvirt-dbus.log >&2
}
exit $rc
|