grml2usb: Add smoke autopkgtest for python2
authorChris Hofstaedtler <zeha@debian.org>
Sat, 31 Aug 2019 10:41:47 +0000 (10:41 +0000)
committerChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Sun, 13 Oct 2019 12:30:19 +0000 (14:30 +0200)
Adds an autopkgtest for the python2 variant of grml2usb -- currently
the only variant. The test unfortunately needs to be run inside a full
machine isolation context, e.g. autopkgtest-virt-qemu.

This builds a minimal stub ISO and does not attempt to test full
functionality.

debian/control
debian/tests/control [new file with mode: 0644]
debian/tests/smoke-grml2usb-py2 [new file with mode: 0755]

index 0c5aa38..0382eef 100644 (file)
@@ -17,7 +17,8 @@ Vcs-Browser: https://git.grml.org/?p=grml2usb.git
 
 Package: grml2usb
 Architecture: amd64 i386
-Depends: mtools,
+Depends: kmod,
+         mtools,
          python,
          python-parted,
          rsync,
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644 (file)
index 0000000..e4020a0
--- /dev/null
@@ -0,0 +1,10 @@
+Tests: smoke-grml2usb-py2
+Depends: dosfstools,
+         kpartx,
+         isolinux,
+         python2,
+         syslinux,
+         syslinux-common,
+         xorriso,
+         @
+Restrictions: needs-root, isolation-machine, breaks-testbed
diff --git a/debian/tests/smoke-grml2usb-py2 b/debian/tests/smoke-grml2usb-py2
new file mode 100755 (executable)
index 0000000..67b45d1
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+exec 2>&1
+set -ex
+
+TMPDIR=$(mktemp -d)
+LODEV=$(losetup -f)
+cleanup() {
+  kpartx -d "$LODEV" || true
+  losetup -d "$LODEV" || true
+  rm -rf "$TMPDIR"
+}
+trap cleanup EXIT
+
+mkdir "$TMPDIR"/isoroot "$TMPDIR"/isoroot/boot "$TMPDIR"/isoroot/boot/isolinux
+cp /usr/lib/ISOLINUX/isolinux.bin "$TMPDIR"/isoroot/boot/isolinux/
+echo 'FAKE' > "$TMPDIR"/isoroot/grml-version
+echo 'LOGO' > "$TMPDIR"/isoroot/boot/logo.16
+touch "$TMPDIR"/isoroot/boot/isolinux/FAKE_default.cfg
+touch "$TMPDIR"/isoroot/boot/isolinux/FAKE_grml.cfg
+touch "$TMPDIR"/isoroot/boot/isolinux/hidden.cfg
+xorriso -as mkisofs -l -r -J -no-pad -no-emul-boot -boot-load-size 4 -boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -o "$TMPDIR"/fake.iso "$TMPDIR"/isoroot
+xorriso -dev "$TMPDIR"/fake.iso -ls
+
+dd if=/dev/zero of="$TMPDIR"/blockdev bs=1M count=50
+
+sfdisk "$TMPDIR"/blockdev <<EOT
+label: dos
+label-id: 0x00000000
+unit: sectors
+
+p1 : start=        2048, size=      100352, type=6, bootable
+EOT
+
+losetup -P "$LODEV" "$TMPDIR"/blockdev
+
+python2 $(which grml2usb) --bootloader-only --verbose --skip-usb-check --force --fat16 "$TMPDIR"/fake.iso "$LODEV"p1