#!/bin/sh
set -ex

# juju < 1.23 doesn't support systemd so switch back to upstart
MAJOR_MINOR=`juju version | cut -d '-' -f 1 | cut -d '.' -f 1,2`
WANTS_UPSTART=`echo $MAJOR_MINOR "1.23" | awk '{print $1<$2?"true":"false"}'`
if [ -d /run/systemd/system -a $WANTS_UPSTART = "true" ]; then
    if [ ! -x /tmp/autopkgtest-reboot ]; then
        echo "SKIP: testbed does not support reboot"
        exit 0
    fi
    if [ -n "${ADT_REBOOT_MARK:-}" ]; then
        echo "SKIP: Reboot with upstart still runs systemd; using init= ?"
        exit 0
    fi
    echo "Installing upstart..."
    apt-get install -y upstart-sysv
    echo "Rebooting into upstart..."
    /tmp/autopkgtest-reboot b1
fi

sh debian/tests/fake-future.sh
sh debian/tests/normal-user.sh debian/tests/manual-provider
