summary: Check that read-only bind mounts can be created
# This is blacklisted on debian because we first have to get the dpkg-vendor patches
systems: [-debian-8]
prepare: |
    echo "Having installed the snapd-hacker-toolbelt snap"
    snap install snapd-hacker-toolbelt
    echo "We can change its mount profile externally to create a read-only bind-mount"
    echo "/snap/snapd-hacker-toolbelt/current/src -> /snap/snapd-hacker-toolbelt/current/dst"
    mkdir -p /var/lib/snapd/mount
    echo "/snap/snapd-hacker-toolbelt/current/src /snap/snapd-hacker-toolbelt/current/dst none bind,ro 0 0" > /var/lib/snapd/mount/snap.snapd-hacker-toolbelt.busybox.fstab
execute: |
    cd /
    echo "We can now look at the .id file in the destination directory"
    [ "$(/snap/bin/snapd-hacker-toolbelt.busybox cat /snap/snapd-hacker-toolbelt/current/dst/.id)" = "source" ]
restore: |
    snap remove --purge snapd-hacker-toolbelt
    rm -rf /var/snap/snapd-hacker-toolbelt
    rm -f /var/lib/snapd/mount/snap.snapd-hacker-toolbelt.busybox.fstab
