github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/cmd/snap-confine/spread-tests/regression/lp-1599608/task.yaml (about)

     1  summary: Check that execle doesn't regress
     2  # This is blacklisted on debian because we first have to get the dpkg-vendor patches
     3  systems: [-debian-8]
     4  details: |
     5   The setup for this test is unorthodox because by the time the cgroup code is
     6   executed, the mounts are in place and /lib/udev/snap-device-helper from the core
     7   snap is used. Unfortunately, simple bind mounts over
     8   /snap/ubuntu-core/current/lib/udev don't work and the core snap must be
     9   unpacked, lib/udev/snap-device-helper modified to be tested, repacked and mounted.
    10   We unmount the core snap and move it aside to avoid both the original and the
    11   updated core snap from being mounted on the same mount point, which confuses
    12   the kernel.
    13  prepare: |
    14      echo "This test is disabled because it causes failures for subsequent tests"
    15      echo "it seems to unmount ubuntu-core snap and not re-mount the original one correctly"
    16      exit 0
    17      cd /
    18      echo "Install hello-world"
    19      snap install hello-world
    20      systemctl stop snapd.service snapd.socket
    21      # all of this ls madness can go away when we have remote environment
    22      # variables
    23      echo "Unmount original core snap"
    24      umount $(ls -1d /snap/ubuntu-core/* | grep -v current | tail -1)
    25      mv $(ls -1 /var/lib/snapd/snaps/ubuntu-core_*.snap | tail -1) $(ls -1 /var/lib/snapd/snaps/ubuntu-core_*.snap | tail -1).orig
    26      echo "Create modified core snap for snap-device-helper"
    27      unsquashfs $(ls -1 /var/lib/snapd/snaps/ubuntu-core_*.snap.orig | tail -1)
    28      echo 'echo PATH=$PATH > /run/udev/spread-test.out' >> ./squashfs-root/lib/udev/snap-device-helper
    29      echo 'echo TESTVAR=$TESTVAR >> /run/udev/spread-test.out' >> ./squashfs-root/lib/udev/snap-device-helper
    30      mksquashfs ./squashfs-root $(ls -1 /var/lib/snapd/snaps/ubuntu-core_*.snap.orig | tail -1 | sed 's/.orig//') -comp xz -no-fragments
    31      if [ ! -e $(ls -1 /var/lib/snapd/snaps/ubuntu-core_*.snap | tail -1) ]; then exit 1; fi
    32      echo "Mount modified core snap"
    33      mount $(ls -1 /var/lib/snapd/snaps/ubuntu-core_*.snap | tail -1) $(ls -1d /snap/ubuntu-core/* | grep -v current | tail -1)
    34      systemctl start snapd.service snapd.socket
    35  execute: |
    36      exit 0
    37      cd /
    38      echo "Add a udev tag so affected code branch is exercised"
    39      echo 'KERNEL=="uinput", TAG+="snap_hello-world_env"' > /etc/udev/rules.d/70-spread-test.rules
    40      udevadm control --reload-rules
    41      udevadm settle
    42      udevadm trigger
    43      udevadm settle
    44      PATH=/foo:$PATH TESTVAR=bar hello-world.env | grep PATH
    45      cat /run/udev/spread-test.out
    46      echo "Ensure user-specified PATH is not used"
    47      not grep 'PATH=/foo' /run/udev/spread-test.out
    48      echo "Ensure environment is clean"
    49      not grep 'TESTVAR=bar' /run/udev/spread-test.out
    50  restore: |
    51      exit 0
    52      echo "Remove hello-world"
    53      snap remove --purge hello-world
    54      systemctl stop snapd.service snapd.socket
    55      echo "Unmount the modified core snap"
    56      # all of this ls madness can go away when we have remote environment
    57      # variables
    58      umount $(ls -1d /snap/ubuntu-core/* | grep -v current | tail -1)
    59      if [ "x"$(ls -1 /var/lib/snapd/snaps/ubuntu-core_*.snap.orig | tail -1) != "x" ]; then mv -f $(ls -1 /var/lib/snapd/snaps/ubuntu-core_*.snap.orig | tail -1) $(ls -1 /var/lib/snapd/snaps/ubuntu-core_*.snap.orig | tail -1 | sed 's/.orig//') ; fi
    60      echo "Mount the original core snap"
    61      mount $(ls -1 /var/lib/snapd/snaps/ubuntu-core_*.snap | tail -1) $(ls -1d /snap/ubuntu-core/* | grep -v current | tail -1)
    62      rm -rf /squashfs-root
    63      rm -f /run/udev/spread-test.out
    64      rm -f /etc/udev/rules.d/70-spread-test.rules
    65      udevadm control --reload-rules
    66      udevadm settle
    67      udevadm trigger
    68      udevadm settle
    69      systemctl start snapd.service snapd.socket