File: task.yaml

package info (click to toggle)
snapd 2.72-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,412 kB
  • sloc: sh: 16,506; ansic: 16,211; python: 11,213; makefile: 1,919; exp: 190; awk: 58; xml: 22
file content (58 lines) | stat: -rw-r--r-- 2,347 bytes parent folder | download | duplicates (4)
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
# It is not possible to test it with "daemon: notify" yet, for more details please see the forum thread:
# https://forum.snapcraft.io/t/its-a-little-bit-hard-to-use-daemon-notify-for-sd-notify/6366
summary: Ensure that the daemon-notify interface works.

details: |
    The daemon-notify interface allows sending notification messages 
    to systemd through the notify socket


# test is timing dependant and may fail on very slow systems
backends: [-autopkgtest]

prepare: |
    "$TESTSTOOLS"/snaps-state install-local test-snapd-daemon-notify

execute: |
    echo "The interface is not connected by default"
    snap interfaces -i daemon-notify | MATCH -- "- +test-snapd-daemon-notify:daemon-notify"

    echo "When the interface is connected"
    snap connect test-snapd-daemon-notify:daemon-notify

    echo "And the service is stopped"
    snap stop test-snapd-daemon-notify.notify

    denials_before="$("$TESTSTOOLS"/journal-state get-log -u snap.test-snapd-daemon-notify.notify.service | grep -c 'Permission denied' || true)"
    echo "Then after we restart the service there are no denials"
    snap start test-snapd-daemon-notify.notify
    for _ in $(seq 10); do
        denials_after="$("$TESTSTOOLS"/journal-state get-log -u snap.test-snapd-daemon-notify.notify.service | grep -c 'Permission denied' || true)"
        if [ "$denials_before" -ne "$denials_after" ]; then
            break
        fi
        sleep 1
    done
    test "$denials_before" = "$denials_after"

    if [ "$(snap debug confinement)" = partial ] ; then
        exit 0
    fi

    echo "When the plug is disconnected"
    snap disconnect test-snapd-daemon-notify:daemon-notify

    echo "And the service is stopped"
    snap stop test-snapd-daemon-notify.notify

    echo "Then the snap is not able to send notification messages"
    denials_before="$("$TESTSTOOLS"/journal-state get-log -u snap.test-snapd-daemon-notify.notify.service | grep -c 'Permission denied' || true)"
    snap start test-snapd-daemon-notify.notify
    for _ in $(seq 10); do
        denials_after="$("$TESTSTOOLS"/journal-state get-log -u snap.test-snapd-daemon-notify.notify.service | grep -c 'Permission denied' || true)"
        if [ "$denials_before" -ne "$denials_after" ]; then
            break
        fi
        sleep 1
    done
    test "$denials_before" != "$denials_after"