#!/bin/sh -e

SUPPORTED_FLAVOURS='amd64 arm64 armmp powerpc64le s390x generic'
ROOTDISK_QEMU_IF=virtio
ROOTDISK_LINUX_NAME=nonexistent
. debian/tests/test-common

cat >>"${CONFDIR}/initramfs.conf" <<EOF
MODULES=list
BUSYBOX=n
FSTYPE=ext2
EOF
cat >"${CONFDIR}/modules" <<EOF
ext2
virtio_pci
virtio_blk
EOF
build_initramfs

build_rootfs_ext2

run_qemu_nocheck
check_no_network_configuration
grep -qF "ALERT!  /dev/nonexistent does not exist.  Dropping to a shell!" "${OUTPUT}"
grep -qF "(initramfs) " "${OUTPUT}"

run_qemu_nocheck "panic=-1"
check_no_network_configuration
grep -qF "Rebooting automatically due to panic= boot argument" "${OUTPUT}"
! grep -qF "(initramfs) " "${OUTPUT}"

run_qemu_nocheck "panic=0"
check_no_network_configuration
grep -qF "Halting automatically due to panic= boot argument" "${OUTPUT}"
! grep -qF "(initramfs) " "${OUTPUT}"
