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 (84 lines) | stat: -rw-r--r-- 2,986 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
summary: Ensure that commands run when their snap provided interfaces are connected

details: |
    Install a test snap that plugs as many snap provided interfaces as is
    possible and verify the command can run (ie, don't test the interface
    functionality itself). This will help catch things like AppArmor 
    policy syntax errors, seccomp policy parsing, udev querying bugs, etc.

# memory issue inside the adt environment
backends: [-autopkgtest]

# Ideally we would run this everywhere, but on systems with full security
# support, it takes a while, which leads to travis timeouts. Limit to:
# - Ubuntu Core
# - Ubuntu classic
# - All Ubuntu autopkgtests
# - Debian sid amd64 VM
# - TODO: All Fedora systems (for classic-only; unrelated error elsewhere)
systems:
  - ubuntu-*
  - debian-*

# Start early as it takes a long time.
priority: 100

environment:
    CONSUMER_SNAP: test-snapd-policy-app-consumer

prepare: |
    # We remove the shared-memory plug and interface in trusty because it fails with the
    # following error since adding private /dev/shm support to shared-memory interface:
    # shared-memory plug with "private: true" cannot be connected if "/dev/shm" is a symlink)
    if os.query is-trusty; then
        cp -r "$TESTSLIB/snaps/$CONSUMER_SNAP" .
        sed -e '/shared-memory:/,+2d' -i $CONSUMER_SNAP/meta/snap.yaml
    fi

restore: |
    # Remove the snaps to avoid timeout in next test
    PROVIDER_SNAP="test-snapd-policy-app-provider-classic"
    if os.query is-core; then
        PROVIDER_SNAP="test-snapd-policy-app-provider-core"
    fi
    snap remove --purge "$PROVIDER_SNAP"
    snap remove --purge "$CONSUMER_SNAP"

debug: |
    # get the full journal to see any out-of-memory errors
    # shellcheck disable=SC2119
    "$TESTSTOOLS"/journal-state get-log

execute: |
    PROVIDER_SNAP="test-snapd-policy-app-provider-classic"    
    if os.query is-core; then
        PROVIDER_SNAP="test-snapd-policy-app-provider-core"
    fi

    echo "Given a snap is installed"
    "$TESTSTOOLS"/snaps-state install-local "$PROVIDER_SNAP"
    "$TESTSTOOLS"/snaps-state install-local "$CONSUMER_SNAP"

    echo "For each snap-provided slot from $PROVIDER_SNAP"
    SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
    for slotcmd in "$SNAP_MOUNT_DIR"/bin/"$PROVIDER_SNAP".* ; do
        slotcmd_bn=$(basename "$slotcmd")
        slot_iface=$(echo "$slotcmd_bn" | tr '.' ':')

        #shellcheck disable=SC2001
        plugcmd=$(echo "$slotcmd" | sed "s/$PROVIDER_SNAP/$CONSUMER_SNAP/")
        plugcmd_bn=$(basename "$plugcmd")
        plug_iface=$(echo "$plugcmd_bn" | tr '.' ':')

        CONNECTED_PATTERN="$slot_iface +$CONSUMER_SNAP"

        echo "When slot $slot_iface is connected"
        snap connect "$plug_iface" "$slot_iface"
        snap interfaces | MATCH "$CONNECTED_PATTERN"

        echo "Then $slotcmd should succeed"
        "$slotcmd" | MATCH PASS

        echo "Then $plugcmd should succeed"
        "$plugcmd" | MATCH PASS
    done