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 (84 lines) | stat: -rw-r--r-- 3,690 bytes parent folder | download | duplicates (3)
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 snap layouts work with parallel installed snaps

details: |
    This test installs a test snap that uses layout declarations. The snap is
    installed under its regular name as well as a parallel instance. The test
    verifies that the layout requested by snap works and operates only on the
    data owned by given snap instance.

prepare: |
    echo "Ensure feature flags are enabled"
    snap set system experimental.parallel-instances=true

execute: |
    echo "Install the regular snap"
    "$TESTSTOOLS"/snaps-state install-local test-snapd-layout

    echo "Sideload the parallel installed snap"
    "$TESTSTOOLS"/snaps-state install-local-as test-snapd-layout test-snapd-layout_foo

    for name in test-snapd-layout test-snapd-layout_foo; do
        # workaround trespassing bug
        rm -rf /etc/demo /etc/demo.conf /etc/demo.cfg

        echo "snap declaring layouts doesn't explode on startup"
        $name.sh -c "true"

        echo "layout declarations are honored"

        $name.sh -c "test -d /etc/demo"
        $name.sh -c "test -f /etc/demo.conf"
        $name.sh -c "test -h /etc/demo.cfg"
        #shellcheck disable=SC2016
        test "$($name.sh -c "readlink /etc/demo.cfg")" = "$($name.sh -c 'echo /var/snap/$SNAP_NAME/common/etc/demo.conf')"
        $name.sh -c "test -d /usr/share/demo"
        $name.sh -c "test -d /var/lib/demo"
        $name.sh -c "test -d /var/cache/demo"
        $name.sh -c "test -d /opt/demo"
        $name.sh -c "test -d /bin/very/weird/place"
        # Ideally we'd perform this test but the rsyslog directory has mode 700 and user mode 108:4
        # test-snapd-layout.sh -c "test -d /var/spool/rsyslog/demo"

        echo "layout locations pointing to SNAP_DATA and SNAP_COMMON of $name are writable"
        echo "and the writes go to the right place in the backing store"

        $name.sh -c "echo $name foo-1 > /etc/demo/writable"
        #shellcheck disable=SC2016
        $name.sh -c 'cat $SNAP_COMMON/etc/demo/writable' | MATCH "$name foo-1"

        $name.sh -c "echo $name foo-2 > /etc/demo.conf"
        #shellcheck disable=SC2016
        $name.sh -c 'cat $SNAP_COMMON/etc/demo.conf' | MATCH "$name foo-2"

        # NOTE: this is a symlink to demo.conf, effectively
        $name.sh -c "echo $name foo-3 > /etc/demo.cfg"
        #shellcheck disable=SC2016
        $name.sh -c 'cat $SNAP_COMMON/etc/demo.conf' | MATCH "$name foo-3"

        $name.sh -c "echo $name foo-4 > /var/lib/demo/writable"
        #shellcheck disable=SC2016
        $name.sh -c 'cat $SNAP_DATA/var/lib/demo/writable' | MATCH "$name foo-4"

        $name.sh -c "echo $name foo-5 > /var/cache/demo/writable"
        #shellcheck disable=SC2016
        $name.sh -c 'cat $SNAP_DATA/var/cache/demo/writable' | MATCH "$name foo-5"

        echo "layout locations pointing to $name \$SNAP are readable"

        $name.sh -c "test -r /usr/share/demo/file"
        $name.sh -c "test -r /opt/demo/file"

        echo "layout locations in dynamically created $name \$SNAP directories are writable"
        # shellcheck disable=SC2016
        $name.sh -c 'test -w $SNAP/bin/very/weird/place'
        $name.sh -c 'test -w /bin/very/weird/place'
    done

    echo "verify snap data is correct on the outside of snap mount namespace"
    for name in test-snapd-layout test-snapd-layout_foo; do
        MATCH "$name foo-1" < "/var/snap/$name/common/etc/demo/writable"
        # demo.cfg was a symlink to demo.conf
        MATCH "$name foo-3" < "/var/snap/$name/common/etc/demo.conf"
        MATCH "$name foo-4" < "/var/snap/$name/x1/var/lib/demo/writable"
        MATCH "$name foo-5" < "/var/snap/$name/x1/var/cache/demo/writable"
    done