github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/cmd/snap-confine/spread-tests/main/cgroup-used/task.yaml (about)

     1  summary: Check that launcher cgroup functionality works
     2  # This is blacklisted on debian because we first have to get the dpkg-vendor patches
     3  systems: [-debian-8]
     4  prepare: |
     5      echo "Install snapd-hacker-toolbelt"
     6      snap install snapd-hacker-toolbelt
     7  execute: |
     8      cd /
     9      echo "Clear udev tags and cgroups with non-test device and running snapd-hacker-toolbelt.busybox"
    10      echo 'KERNEL=="uinput", TAG+="snap_snapd-hacker-toolbelt_busybox"' > /etc/udev/rules.d/70-spread-test.rules
    11      udevadm control --reload-rules
    12      udevadm settle
    13      udevadm trigger
    14      udevadm settle
    15      snapd-hacker-toolbelt.busybox echo "Hello World" | grep Hello
    16      echo "Verify no tags for snapd-hacker-toolbelt.busybox for kmsg"
    17      if udevadm info /sys/devices/virtual/mem/kmsg | grep snap_snapd-hacker-toolbelt_busybox ; then exit 1; fi
    18      echo "Manually add udev tags for snapd-hacker-toolbelt.busybox for kmsg"
    19      echo 'KERNEL=="kmsg", TAG+="snap_snapd-hacker-toolbelt_busybox"' > /etc/udev/rules.d/70-spread-test.rules
    20      echo "Simulate snapd udev triggers"
    21      udevadm control --reload-rules
    22      udevadm settle
    23      udevadm trigger
    24      udevadm settle
    25      echo "Verify udev has tag for kmsg"
    26      if ! udevadm info /sys/devices/virtual/mem/kmsg | grep snap_snapd-hacker-toolbelt_busybox; then exit 1; fi
    27      echo "Run snapd-hacker-toolbelt.busybox echo and see if kmsg added to cgroup"
    28      snapd-hacker-toolbelt.busybox echo "Hello World" | grep Hello
    29      if ! grep 'c 1:11 rwm' /sys/fs/cgroup/devices/snap.snapd-hacker-toolbelt.busybox/devices.list ; then exit 1; fi
    30  restore: |
    31      snap remove --purge snapd-hacker-toolbelt
    32      rm -f /etc/udev/rules.d/70-spread-test.rules
    33      udevadm control --reload-rules
    34      udevadm settle
    35      udevadm trigger
    36      udevadm settle
    37      # no way to clear cgroup for snapd-hacker-toolbelt atm