summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Williams <codehelp@debian.org>2016-07-31 22:23:18 +0100
committerNeil Williams <codehelp@debian.org>2016-07-31 22:23:18 +0100
commit479f2395ba42813e284a15e442c38b8536155ce8 (patch)
treec49d7d93f896a2285fecc7d9d14cd21a2ab7370a
parent5c0f1d11fb1bdeceffc0aa28e19673c82663a9ab (diff)
downloadvmdebootstrap-479f2395ba42813e284a15e442c38b8536155ce8.tar.gz
Update and expand the build tests
Still issues to fix with some of the scenarios
-rwxr-xr-xbin/vmdebootstrap9
-rw-r--r--vmdebootstrap/filesystem.py2
-rw-r--r--vmdebootstrap/grub.py3
-rw-r--r--yarns/300-slow-build-tests.yarn48
-rw-r--r--yarns/900-implements.yarn22
5 files changed, 74 insertions, 10 deletions
diff --git a/bin/vmdebootstrap b/bin/vmdebootstrap
index 799fbd3..cb98cd4 100755
--- a/bin/vmdebootstrap
+++ b/bin/vmdebootstrap
@@ -228,11 +228,12 @@ class VmDebootstrap(cliapp.Application): # pylint: disable=too-many-public-meth
if self.settings['swap'] > 0:
base.message("Creating swap space")
runcmd(['mkswap', filesystem.devices['swapdev']])
- # stable or oldstable, use ^metadata_csum
+ # stable or oldstable, use ^metadata_csum only for ext*
opt = None
if distro.was_oldstable(datetime.date(2015, 4, 26)) or \
distro.was_stable(datetime.date(2015, 4, 26)):
- opt = "^metadata_csum"
+ if self.settings['roottype'] in ['ext2', 'ext3', 'ext4']:
+ opt = "^metadata_csum"
filesystem.mkfs(rootdev, fstype=roottype, opt=opt)
rootdir = self.mount(rootdev)
filesystem.devices['rootdir'] = rootdir
@@ -567,18 +568,20 @@ class VmDebootstrap(cliapp.Application): # pylint: disable=too-many-public-meth
# Umount in the reverse mount order
if self.settings['image']:
self.umount()
+ time.sleep(2)
# tidy up loop mounting issues on failure.
out = runcmd(['losetup', '-a'])
rootdev = filesystem.devices['rootdev']
if rootdev:
- runcmd(['dmsetup', 'remove', rootdev]], ignore_fail=True)
+ runcmd(['dmsetup', 'remove', rootdev], ignore_fail=True)
device = [line.decode('utf-8').split()[0][:-1]
for line in out.splitlines()
if self.settings['image'] in line.decode('utf-8')]
if device:
runcmd(['losetup', '-d', "%s" % device[0]], ignore_fail=True)
runcmd(['kpartx', '-d', self.settings['image']], ignore_fail=True)
+ time.sleep(2)
for dirname in self.remove_dirs:
shutil.rmtree(dirname)
diff --git a/vmdebootstrap/filesystem.py b/vmdebootstrap/filesystem.py
index d878d73..b911c05 100644
--- a/vmdebootstrap/filesystem.py
+++ b/vmdebootstrap/filesystem.py
@@ -120,7 +120,7 @@ class Filesystem(Base):
for line in out.splitlines()
if line.decode('utf-8').startswith('add map ')]
if len(devices) != parts:
- msg = 'Surprising number of partitions - check output of losetup -a'
+ msg = 'Surprising number of partitions %d:%d- check output of losetup -a' % (len(devices), parts)
logging.debug("%s", runcmd(['losetup', '-a']))
logging.debug("%s: devices=%s parts=%s", msg, devices, parts)
raise cliapp.AppException(msg)
diff --git a/vmdebootstrap/grub.py b/vmdebootstrap/grub.py
index 5c50b12..ad9f293 100644
--- a/vmdebootstrap/grub.py
+++ b/vmdebootstrap/grub.py
@@ -147,5 +147,6 @@ class GrubHandler(Base):
def grub_packages(self):
if self.settings['grub'] and not self.settings['use-uefi']:
- return ['grub-pc']
+ if self.settings['arch'] in ['i386', 'amd64']:
+ return ['grub-pc']
return []
diff --git a/yarns/300-slow-build-tests.yarn b/yarns/300-slow-build-tests.yarn
index e42e8d2..8137943 100644
--- a/yarns/300-slow-build-tests.yarn
+++ b/yarns/300-slow-build-tests.yarn
@@ -12,12 +12,27 @@ These tests are slow, since building images is slow.
SCENARIO build a basic Debian 8 image
ASSUMING build tests are requested
GIVEN user wants to build an image FOO.img that is 2GiB in size
+ WHEN the user runs vmdebootstrap --sparse --extlinux --roottype ext3
+ THEN the image has the correct size
+ AND the partition count of the image is 1
+ AND partition 1 has an ext3 filesystem
+ AND partition 1 has file /etc/debian_version matching ^8\..*$
+ AND partition 1 has filename ldlinux.sys
+ AND partition 1 has filename extlinux.conf
+
+ SCENARIO build a basic Debian 8 image with networking
+ ASSUMING build tests are requested
+ GIVEN user wants to build an image FOO.img that is 2GiB in size
WHEN the user runs vmdebootstrap --sparse --extlinux
+ ... --roottype ext3 --enable-dhcp --configure-apt
THEN the image has the correct size
AND the partition count of the image is 1
AND partition 1 has the boot flag set
- AND partition 1 has an ext4 filesystem
+ AND partition 1 has an ext3 filesystem
AND partition 1 has file /etc/debian_version matching ^8\..*$
+ AND partition 1 has filename ldlinux.sys
+ AND partition 1 has filename extlinux.conf
+ AND partition 1 has file /etc/apt/sources.list.d/base.list matching jessie
SCENARIO build a Debian 8 image with grub
ASSUMING build tests are requested
@@ -30,6 +45,30 @@ These tests are slow, since building images is slow.
AND partition 1 has file /boot/grub/grub.cfg matching ^### BEGIN /etc/grub.d/00_header ###$
AND partition 1 has file /etc/fstab matching ^\S+\s+\/\s+ext4\s+errors=remount-ro\s+\d\s+\d$
+ SCENARIO build a Debian stretch image with grub
+ ASSUMING build tests are requested
+ GIVEN user wants to build an image FOO.img that is 2GiB in size
+ WHEN the user runs vmdebootstrap --grub --distribution stretch
+ THEN the image has the correct size
+ AND the partition count of the image is 1
+ AND partition 1 has the boot flag set
+ AND partition 1 has an ext4 filesystem
+ AND partition 1 has file /boot/grub/grub.cfg matching ^### BEGIN /etc/grub.d/00_header ###$
+ AND partition 1 has file /etc/fstab matching ^\S+\s+\/\s+ext4\s+errors=remount-ro\s+\d\s+\d$
+
+ SCENARIO build a Debian stretch image with systemd
+ ASSUMING build tests are requested
+ GIVEN user wants to build an image FOO.img that is 2GiB in size
+ WHEN the user runs vmdebootstrap --grub --distribution stretch
+ ... --systemd-networkd
+ THEN the image has the correct size
+ AND the partition count of the image is 1
+ AND partition 1 has symlink /etc/resolv.conf
+ AND partition 1 has the boot flag set
+ AND partition 1 has an ext4 filesystem
+ AND partition 1 has symlink /sbin/init
+ AND partition 1 has file /etc/apt/sources.list.d/setup matching jessie
+
SCENARIO build a Debian 8 image with uefi
ASSUMING build tests are requested
GIVEN user wants to build an image FOO.img that is 2GiB in size
@@ -42,9 +81,8 @@ These tests are slow, since building images is slow.
SCENARIO build a basic Debian 8 qcow image
ASSUMING build tests are requested
GIVEN user wants to build an image FOO.img that is 2GiB in size
- WHEN the user runs vmdebootstrap --sparse --extlinux --convert-qcow2
- THEN the image has the correct size
- AND image has file format matching qcow2
+ WHEN the user runs vmdebootstrap --sparse --roottype ext2 --extlinux --convert-qcow2
+ THEN image has file format matching qcow2
SCENARIO build a Debian 8 image with btrfs and grub
ASSUMING build tests are requested
@@ -71,7 +109,7 @@ These tests are slow, since building images is slow.
SCENARIO build a Debian 8 armhf image with boot flag lba
ASSUMING build tests are requested
GIVEN user wants to build an image FOO.img that is 2GiB in size
- WHEN the user runs vmdebootstrap --bootflag=lba --arch armhf
+ WHEN the user runs vmdebootstrap --bootflag=lba --arch armhf --grub
... --foreign /usr/bin/qemu-arm-static --bootsize 100mib --boottype vfat
THEN the image has the correct size
AND the partition count of the image is 2
diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn
index 860d649..433c374 100644
--- a/yarns/900-implements.yarn
+++ b/yarns/900-implements.yarn
@@ -136,6 +136,28 @@ regular expression.
trap "umount \"$mp\"; unkpartx_image \"$IMAGE\"" EXIT
grep -P -e "$MATCH_3" "$mp/$MATCH_2"
+Check that the partition contains a specified symlink.
+
+ IMPLEMENTS THEN partition (\d+) has symlink (\S+)
+ device="$(kpartx_image_partition "$IMAGE" "$MATCH_1")"
+ trap "unkpartx_image \"$IMAGE\"" EXIT
+ mp="$(mktemp -d)"
+ mount -r "$device" "$mp"
+ trap "umount \"$mp\"; unkpartx_image \"$IMAGE\"" EXIT
+ stat "$mp/$MATCH_2" |
+ grep "symbolic link"
+
+Check that the partition contains a specified path.
+
+ IMPLEMENTS THEN partition (\d+) has filename (\S+)
+ device="$(kpartx_image_partition "$IMAGE" "$MATCH_1")"
+ trap "unkpartx_image \"$IMAGE\"" EXIT
+ mp="$(mktemp -d)"
+ mount -r "$device" "$mp"
+ trap "umount \"$mp\"; unkpartx_image \"$IMAGE\"" EXIT
+ stat "$mp/$MATCH_2" |
+ grep "regular file"
+
Check the image output format
IMPLEMENTS THEN image has file format matching (.+)