/
task.yaml
50 lines (40 loc) · 1.88 KB
/
task.yaml
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
summary: D-Bus session services support activation via systemd user session
systems:
# Ubuntu Core does not contain the D-Bus user session systemd units
- -ubuntu-core-*
# Ubuntu 14.04 does not provide user@.service
- -ubuntu-14.04-*
# CentOS/Amazon Linux give error "Unit user@0.service not loaded."
- -amazon-linux-2-*
- -centos-7-*
environment:
XDG_RUNTIME_DIR: /run/user/$(id -u test)
prepare: |
#shellcheck source=tests/lib/pkgdb.sh
. "$TESTSLIB"/pkgdb.sh
distro_install_package dbus-user-session
systemctl stop "user@$(id -u test).service"
mkdir -p "$XDG_RUNTIME_DIR"
chown test.test "$XDG_RUNTIME_DIR"
chmod u=rwX,go= "$XDG_RUNTIME_DIR"
restore: |
systemctl stop "user@$(id -u test).service"
execute: |
#shellcheck source=tests/lib/snaps.sh
. "$TESTSLIB"/snaps.sh
echo "Set up a systemd user session"
systemctl start "user@$(id -u test).service"
eval "$(su -l -c "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} systemctl --user show-environment" test | grep ^DBUS_)"
export DBUS_SESSION_BUS_ADDRESS
echo "Install a snap containing an activatable D-Bus session service"
snap install --edge test-snapd-dbus-service
echo "A service activation file has been created"
[ -f /var/lib/snapd/dbus/services/io.snapcraft.SnapDbusService.service ]
echo "Making a method call wakes the service"
install_local test-snapd-dbus-service-client
snap connect test-snapd-dbus-service-client:dbus-session-plug \
test-snapd-dbus-service:dbus-session-slot
su -l -c "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS} test-snapd-dbus-service-client.session" test | MATCH hello
echo "Removing the snap also removes the service activation file"
snap remove test-snapd-dbus-service
[ ! -f /var/lib/snapd/dbus/services/io.snapcraft.SnapDbusService.service ]