3
# Copyright (C) 2013 Canonical, Ltd.
5
# This program is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU General Public License as
7
# published by the Free Software Foundation, version 2 of the
12
genprofile --stdin <<EOF
22
# the arguments passed are emitted in the profile's prologue, for
23
# setting profile variables, e.g.
24
# set_dbus_var "@{MY_DBUS_VAR}=stuff"
25
# the saved variable declaration gets unset after each test run
33
out=$(dbus-daemon --fork --print-pid --print-address --config-file=dbus.conf)
36
fatalerror "Failed to start DBus daemon"
39
bus_addr=$(echo $out | cut -d\ -f 1)
40
bus_pid=$(echo $out | cut -d\ -f 2)
42
# The daemon may error out during initialization. Unfortunately,
43
# there's no good way to detect that, but this will work under normal
46
kill -0 $bus_pid 2>/dev/null
49
fatalerror "DBus daemon unexpectedly stopped"
52
do_onexit="kill $bus_pid"
53
export DBUS_SESSION_BUS_ADDRESS=$bus_addr
57
dest=com.apparmor.Test
58
path=/com/apparmor/Test
59
iface=com.apparmor.Test
61
# parameters: bus message_type destination path interface.member
63
# destination must be a connection name or "broadcast" for a broadcast signal
68
if [ "$3" == "broadcast" ]
70
if [ "$2" != "signal" ]
72
fatalerror "Cannot send broadcast for message type \"$2\""
78
out=$(./dbus_message --$1 --type=$2 $d $4 $5 2>&1)
87
send "$bus" "signal" "$dest" "$path" "${iface}.Signal"
92
send "$bus" "signal" "broadcast" "$path" "${iface}.Signal"
97
send "$bus" "method_call" "$dest" "$path" "${iface}.Method"
105
cmp -s "$1" "$3" || rc=$?
106
if [ $rc -ne 0 ] && [ "$2" == "eq" ]
108
msg="Log files \"$1\" and \"$3\" are different, but should be equal."
109
elif [ $rc -eq 0 ] && [ "$2" == "ne" ]
111
msg="Log files \"$1\" and \"$3\" are the same, but should be different."
116
echo "Error: ${testname} failed. Test '${_testdesc}' produced unexpected log contents. ${msg}"