File: task.yaml

package info (click to toggle)
snapd 2.71-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 79,536 kB
  • sloc: ansic: 16,114; sh: 16,105; python: 9,941; makefile: 1,890; exp: 190; awk: 40; xml: 22
file content (63 lines) | stat: -rw-r--r-- 2,670 bytes parent folder | download | duplicates (2)
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
62
63
summary: Ensure that the content sharing interface works.

details: |
    The content-sharing interface interface allows a snap to access contents from
    other snap

    A snap which defines the content sharing plug must be shown in the interfaces list.
    The plug must be autoconnected on install and, as usual, must be able to be
    reconnected.

# slow in autopkgtest (>4m)
backends: [-autopkgtest]

# This test purges the state which causes the device to reinitialize
# with (potentially) a different core snap. Running this on core will
# also trigger a reboot in the middle of the tests because the new
# core will be applied. So skip the test on core devices.
systems: [-ubuntu-core-*]

prepare: |
    echo "Ensure an empty state so that installing test-snapd-content-plug"
    echo "will pull in test-snapd-content-slot *and* core"

    tests.systemd stop-unit snapd.service
    rm -f /var/lib/snapd/state.json
    # clear cache to prevent it from being used in the download, because that core
    # was modified by the prepare suite and will fail to be validated
    rm -f /var/lib/snapd/snaps/core_*
    systemctl start snapd
    snap wait system seed.loaded

execute: |
    echo "When a snap declaring a content sharing plug is installed"
    snap install --edge test-snapd-content-plug

    echo "Then this pulls in the default provider"
    snap list | MATCH  test-snapd-content-slot

    echo "Then the snap is listed as connected"
    snap interfaces -i content | grep -Pzq "test-snapd-content-slot:shared-content-slot +test-snapd-content-plug:shared-content-plug"

    echo "And fstab files are created"
    [ "$(find /var/lib/snapd/mount -type f -name "*.fstab" | wc -l)" -gt 0 ]

    echo "And we can use the shared content"
    test-snapd-content-plug.content-plug | grep "Some shared content"

    echo "And the current mount profile is the same as the desired mount profile"
    # Exclude the rootfs line, which is only in the /run/ fstab
    grep -v "x-snapd.origin=rootfs" /run/snapd/ns/snap.test-snapd-content-plug.fstab \
        | diff -u - /var/lib/snapd/mount/snap.test-snapd-content-plug.fstab

    echo "When the plug is disconnected"
    snap disconnect test-snapd-content-plug:shared-content-plug test-snapd-content-slot:shared-content-slot

    echo "Then the fstab files are removed"
    [ "$(find /var/lib/snapd/mount -type f -name "*.fstab" | wc -l)" -eq 0 ]

    echo "When the plug is reconnected"
    snap connect test-snapd-content-plug:shared-content-plug test-snapd-content-slot:shared-content-slot

    echo "Then the fstab files are recreated"
    [ "$(find /var/lib/snapd/mount -type f -name "*.fstab" | wc -l)" -gt 0 ]