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 (116 lines) | stat: -rw-r--r-- 4,876 bytes parent folder | download
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
summary: Checks for snap sideload install

details: |
    Check snaps installation with --dangerous, --jailmode, --devmode, and
    deprecated options. Also validate snaps can be removed with --revision option. 

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

environment:
    # Ensure that running purely from the deb (without re-exec) works
    # correctly
    SNAP_REEXEC/reexec0: 0
    SNAP_REEXEC/reexec1: 1

prepare: |
    if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-from-archive; then
        tests.exec skip-test "No need to test when the snapd pkg is from the repository and reexec is disabled" && exit 0
    fi

    for snap in basic test-snapd-tools basic-desktop test-snapd-devmode snap-hooks-bad-install; do
        snap pack "$TESTSLIB"/snaps/$snap
    done
    SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
    if [ "$SNAP_REEXEC" = "1" ] && [ "$SNAP_MOUNT_DIR" != "/snap" ] && [ ! -L /snap ]; then
        # reexec expects to find the snapd snap under /snap, enable it to do so
        # on distros using /var/lib/snapd/snap
        ln -sf "$SNAP_MOUNT_DIR" /snap
        tests.cleanup defer rm -f /snap
    fi

execute: |
    tests.exec is-skipped && exit 0

    echo "Sideloaded snap shows status"
    expected='^basic 1.0 installed$'
    snap install --dangerous ./basic_1.0_all.snap | MATCH "$expected"

    echo "Sideloaded snap with (deprecated) --force-dangerous option"
    snap remove --purge basic
    snap install --force-dangerous ./basic_1.0_all.snap | MATCH "$expected"

    echo "Sideloaded snap executes commands"
    snap install --dangerous ./test-snapd-tools_1.0_all.snap

    test-snapd-tools.success
    [ "$(test-snapd-tools.echo Hello World)" = "Hello World" ]

    echo "Sideload desktop snap"
    SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
    snap install --dangerous ./basic-desktop_1.0_all.snap
    diff -u <(head -n6 /var/lib/snapd/desktop/applications/basic-desktop_echo.desktop) - <<-EOF
    	[Desktop Entry]
    	X-SnapInstanceName=basic-desktop
    	Name=Echo
    	Comment=It echos stuff
    	X-SnapAppName=echo
    	Exec=$SNAP_MOUNT_DIR/bin/basic-desktop.echo
    EOF

    echo "Sideload devmode snap fails without flags"
    expected="requires devmode or confinement override"
    "$TESTSTOOLS"/to-one-line "$( snap install --dangerous ./test-snapd-devmode_1.0_all.snap 2>&1 )" | MATCH "$expected"

    echo "Sideload devmode snap succeeds with --devmode"
    expected="test-snapd-devmode 1.0 installed"
    snap install --devmode ./test-snapd-devmode_1.0_all.snap | MATCH "$expected"
    expected="^test-snapd-devmode +.* +devmode"
    snap list | MATCH  "$expected"

    if [ "$(snap debug confinement)" = strict ] ; then
        echo "Sideload devmode snap succeeds with --jailmode"
        expected="test-snapd-devmode 1.0 installed"
        snap install --dangerous --jailmode ./test-snapd-devmode_1.0_all.snap | MATCH "$expected"
        expected="^test-snapd-devmode +.* +jailmode"
        snap list | MATCH "$expected"
    fi

    echo "Sideload devmode snap fails with both --devmode and --jailmode"
    expected="cannot use devmode and jailmode flags together"
    ( snap install --devmode --jailmode ./test-snapd-devmode_1.0_all.snap 2>&1 || true ) | MATCH "$expected"

    echo "Sideload a second time succeeds"
    snap install --dangerous ./test-snapd-tools_1.0_all.snap
    test-snapd-tools.success

    # TODO:UC20: fix to work on uc20 too
    # The "seed/" dir is on a FAT partition on uc20 so the permissions are
    # different here.
    if os.query is-core-le 18; then
        echo "All snap blobs are 0600"
        test "$( find /var/lib/snapd/{snaps,cache,seed/snaps}/ -type f -printf '%#m\n' | sort -u | xargs )" = "0600"
    fi

    # TODO: check we copy the data directory over

    echo "Remove --revision works"
    snap remove --revision x1 test-snapd-tools
    test-snapd-tools.success
    test ! -d "$SNAP_MOUNT_DIR/test-snapd-tools/x1"

    echo "Install multiple local snaps"
    expected="(basic 1.0 installed\stest-snapd-tools 1.0 installed)|(test-snapd-tools 1.0 installed\sbasic 1.0 installed)"
    snap install --dangerous --transaction=per-snap test-snapd-tools_1.0_all.snap basic_1.0_all.snap | MATCH -z "$expected"
    snap install --devmode --transaction=per-snap test-snapd-tools_1.0_all.snap basic_1.0_all.snap | MATCH -z "$expected"

    echo "Install multiple local snaps transactionally"
    snap remove test-snapd-tools basic
    snap install --dangerous --transaction=all-snaps test-snapd-tools_1.0_all.snap basic_1.0_all.snap |
        MATCH -z "$expected"

    echo "Install multiple local snaps transactionally, one fails and none is installed"
    snap remove test-snapd-tools basic
    not snap install --dangerous --transaction=all-snaps basic_1.0_all.snap snap-hooks-bad-install_1.0_all.snap
    not snap list basic
    not snap list snap-hooks-bad-install