summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2018-07-27 18:22:36 +0800
committerBen Hutchings <benh@debian.org>2020-09-07 00:15:37 +0100
commit6b3b361213803f364f919527a3faa8f270617f55 (patch)
tree03b4351847e2e4bb68c7e050ebce9c0e79d2426f /debian
parentc14b760c7ea740e0133c35d8de235040f01cf7ab (diff)
debian/tests: Add test of the panic shell and parameter handling
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'debian')
-rwxr-xr-xdebian/tests/amd64-panic-shell32
-rw-r--r--debian/tests/control3
-rw-r--r--debian/tests/test-common13
3 files changed, 47 insertions, 1 deletions
diff --git a/debian/tests/amd64-panic-shell b/debian/tests/amd64-panic-shell
new file mode 100755
index 0000000..7948914
--- /dev/null
+++ b/debian/tests/amd64-panic-shell
@@ -0,0 +1,32 @@
+#!/bin/sh -e
+
+LOCALVERSION=-amd64
+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_amd64
+grep -qF "ALERT! /dev/nonexistent does not exist. Dropping to a shell!" "${OUTPUT}"
+grep -qF "(initramfs) " "${OUTPUT}"
+
+run_qemu_nocheck_amd64 "panic=-1"
+grep -qF "Rebooting automatically due to panic= boot argument" "${OUTPUT}"
+! grep -qF "(initramfs) " "${OUTPUT}"
+
+run_qemu_nocheck_amd64 "panic=0"
+grep -qF "Halting automatically due to panic= boot argument" "${OUTPUT}"
+! grep -qF "(initramfs) " "${OUTPUT}"
diff --git a/debian/tests/control b/debian/tests/control
index 55d7e51..e375be3 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -16,3 +16,6 @@ Depends: @, qemu-system-x86, linux-image-amd64, klibc-utils, genext2fs
Tests: amd64-separate-usr
Depends: @, qemu-system-x86, linux-image-amd64, klibc-utils, genext2fs
+
+Tests: amd64-panic-shell
+Depends: @, qemu-system-x86, linux-image-amd64, klibc-utils, genext2fs
diff --git a/debian/tests/test-common b/debian/tests/test-common
index be28535..8741226 100644
--- a/debian/tests/test-common
+++ b/debian/tests/test-common
@@ -77,7 +77,18 @@ build_rootfs_ext2() {
build_fs_ext2 "${ROOTDIR}" "${ROOTDISK}"
}
+_run_qemu_amd64() {
+ local extra_params="$*"
+
+ timeout --foreground 60 qemu-system-x86_64 -m 1G -drive "file=${ROOTDISK},if=${ROOTDISK_QEMU_IF},media=disk,format=raw" ${USRDISK:+-drive "file=${USRDISK},if=${USRDISK_QEMU_IF},media=disk,format=raw"} -nographic -no-reboot -kernel "/boot/vmlinuz-${KVER}" -initrd "${INITRAMFS}" -append "root=/dev/${ROOTDISK_LINUX_NAME} ro console=ttyS0,115200 ${extra_params}" | tee "${OUTPUT}"
+}
+
+run_qemu_nocheck_amd64() {
+ # hide error messages from autopkgtest
+ _run_qemu_amd64 2>&1 "$@"
+}
+
run_qemu_amd64() {
- timeout --foreground 60 qemu-system-x86_64 -m 1G -drive "file=${ROOTDISK},if=${ROOTDISK_QEMU_IF},media=disk,format=raw" ${USRDISK:+-drive "file=${USRDISK},if=${USRDISK_QEMU_IF},media=disk,format=raw"} -nographic -no-reboot -kernel "/boot/vmlinuz-${KVER}" -initrd "${INITRAMFS}" -append "root=/dev/${ROOTDISK_LINUX_NAME} ro console=ttyS0,115200 panic=-1 " | tee "${OUTPUT}"
+ _run_qemu_amd64 "panic=-1"
grep -qF "${INIT_MESSAGE}" "${OUTPUT}"
}