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 (73 lines) | stat: -rw-r--r-- 2,975 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
64
65
66
67
68
69
70
71
72
73
summary: Verify the scenarios when device cgroup is optional or required

details: |
  Verify scenarios where device cgroup is optional (when using the following
  base snaps: core, core16, core18, core20, core22, bare) or required (all other
  bases).

systems:
  #TODO: bpftool is not available on core22+ and tests.device-cgroup needs it for cgroups v2
  - -ubuntu-core-22-*
  - -ubuntu-core-24-*
  
execute: |
    #shellcheck source=tests/lib/systems.sh
    . "$TESTSLIB"/systems.sh

    echo "Given snap is installed"
    "$TESTSTOOLS"/snaps-state install-local test-snapd-sh-core20
    test -f /var/lib/snapd/cgroup/snap.test-snapd-sh-core20.device
    NOMATCH "non-strict=true" < /var/lib/snapd/cgroup/snap.test-snapd-sh-core20.device

    "$TESTSTOOLS"/snaps-state install-local test-snapd-sh-core24
    test -f /var/lib/snapd/cgroup/snap.test-snapd-sh-core24.device
    NOMATCH "non-strict=true" < /var/lib/snapd/cgroup/snap.test-snapd-sh-core24.device

    echo "No devices are assigned to either snap"
    udevadm info "/dev/null" | NOMATCH "E: TAGS=.*snap_test-snapd-sh.*"
    udevadm info "/dev/null" | NOMATCH "E: CURRENT_TAGS=.*snap_test-snapd-sh.*"

    # device 'c 1:3' is /dev/null and is among the devices we allow by default

    echo "And no devices are not shown in the snap device list"
    tests.device-cgroup test-snapd-sh-core20.sh dump | NOMATCH "c 1:3"
    tests.device-cgroup test-snapd-sh-core24.sh dump | NOMATCH "c 1:3"

    echo "When a snap with optional cgroup command is called"
    test-snapd-sh-core20.sh -c 'true'

    echo "There is no device set up for it"
    tests.device-cgroup test-snapd-sh-core20.sh dump | NOMATCH "c 1:3"

    echo "When a snap with required cgroup command is called"
    test-snapd-sh-core24.sh -c 'true'

    echo "Device is listed as allowed"
    tests.device-cgroup test-snapd-sh-core24.sh dump | MATCH "c 1:3"

    # drop persistent cgroup information
    if is_cgroupv2; then
        rm /sys/fs/bpf/snap/snap_test-snapd-sh-core24_sh
        test ! -e /sys/fs/bpf/snap/snap_test-snapd-sh-core20_sh
    else
        rmdir /sys/fs/cgroup/devices/snap.test-snapd-sh-core24.sh
        test ! -e /sys/fs/cgroup/devices/snap.test-snapd-sh-core20.sh
    fi

    echo "When snaps are installed in devmode"
    "$TESTSTOOLS"/snaps-state install-local test-snapd-sh-core20 --devmode
    MATCH "non-strict=true" < /var/lib/snapd/cgroup/snap.test-snapd-sh-core20.device

    "$TESTSTOOLS"/snaps-state install-local test-snapd-sh-core24 --devmode
    MATCH "non-strict=true" < /var/lib/snapd/cgroup/snap.test-snapd-sh-core24.device

    test-snapd-sh-core20.sh -c 'true'
    test-snapd-sh-core24.sh -c 'true'

    if is_cgroupv2; then
        test ! -e /sys/fs/bpf/snap/snap_test-snapd-sh-core24_sh
        test ! -e /sys/fs/bpf/snap/snap_test-snapd-sh-core20_sh
    else
        test ! -e /sys/fs/cgroup/devices/snap.test-snapd-sh-core24.sh
        test ! -e /sys/fs/cgroup/devices/snap.test-snapd-sh-core20.sh
    fi