summary: Check that /var/lib/snapd/hostfs is created on demand
# This is blacklisted on debian because debian doesn't use apparmor yet
systems: [-debian-8]
details: |
    The /var/lib/snapd/hostfs directory is created by snap-confine
    if the host packaging of snapd doesn't already provide it.
prepare: |
    echo "Having installed the snapd-hacker-toolbelt snap"
    snap install snapd-hacker-toolbelt
    echo "We can move the packaged hostfs directory aside"
    if [ -d /var/lib/snapd/hostfs ]; then
        mv /var/lib/snapd/hostfs /var/lib/snapd/hostfs.orig
    fi
execute: |
    cd /
    echo "We can now run a busybox true just to ensure it started correctly"
    /snap/bin/snapd-hacker-toolbelt.busybox true
    echo "We can now check that the directory was created on the system"
    test -d /var/lib/snapd/hostfs
restore: |
    snap remove --purge snapd-hacker-toolbelt
    if [ -d /var/lib/snapd/hostfs.orig ]; then
        mv /var/lib/snapd/hostfs.orig /var/lib/snapd/hostfs
    fi
