#!/bin/sh

set -e

. ./debian/tests/chkboot-testing-lib

case "$AUTOPKGTEST_REBOOT_MARK" in
    "")
        setup_chkboot

        echo "assert initial state"
        chkboot-check

        echo "reinstalling kernel package"
        export DEBIAN_FRONTEND=noninteractive
        apt-get update
        apt-get reinstall --assume-yes "linux-image-$(uname -r)"

        echo "rebooting"
        /tmp/autopkgtest-reboot mark1
        ;;

    mark1)
        echo "assert state after reboot with acknowledged changes"
        chkboot-check
        ;;
esac
echo "test end"
