summary: Check that missing destination directory aborts mount processing
# 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 "/var/snap/snapd-hacker-toolbelt/common/src -> /var/snap/snapd-hacker-toolbelt/common/dst"
    mkdir -p /var/lib/snapd/mount
    echo "/var/snap/snapd-hacker-toolbelt/common/src /var/snap/snapd-hacker-toolbelt/common/dst none bind,ro 0 0" > /var/lib/snapd/mount/snap.snapd-hacker-toolbelt.busybox.fstab
    echo "We can now create the source directory, missing the destination directory"
    mkdir -p /var/snap/snapd-hacker-toolbelt/common/src
execute: |
    echo "We can now run busybox.true and expect it to fail"
    ( cd / && ! /snap/bin/snapd-hacker-toolbelt.busybox true ) 
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
