diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2018-12-15 23:16:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-15 23:16:48 +0000 |
commit | 4186db82b6a5ae2a3ae6ee2520c37bf9ccf8240c (patch) | |
tree | b623c15240110de7d927ec3f3b54401c2e619fa1 | |
parent | f3bdfaa34c1ca66131ee079c85a68cdac55dbff0 (diff) | |
parent | 60d9f58bfdbe615f3b85140d1f5f17bf81c5ef06 (diff) | |
download | genimage-4186db82b6a5ae2a3ae6ee2520c37bf9ccf8240c.tar.gz genimage-4186db82b6a5ae2a3ae6ee2520c37bf9ccf8240c.tar.xz |
Merge pull request #48 from michaelolbrich/hdimage-size
hdimage: make sure partitions are large enough for the content
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | image-hd.c | 4 | ||||
-rwxr-xr-x | test/basic-images.test | 22 | ||||
-rw-r--r-- | test/flash.md5 | 2 | ||||
-rw-r--r-- | test/hdimage2.config | 10 | ||||
-rw-r--r-- | test/qemu.info | 8 | ||||
-rw-r--r-- | test/qemu.qcow.gz | bin | 0 -> 540 bytes |
7 files changed, 29 insertions, 20 deletions
diff --git a/Makefile.am b/Makefile.am index 7c08470..8455bfc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,6 +60,7 @@ EXTRA_DIST += \ test/flash.config \ test/flash.md5 \ test/hdimage.config \ + test/hdimage2.config \ test/hdimage.fdisk \ test/hdimage.fdisk-2 \ test/iso.config \ @@ -69,7 +70,7 @@ EXTRA_DIST += \ test/mke2fs.config \ test/mke2fs.dump \ test/qemu.config \ - test/qemu.info \ + test/qemu.qcow.gz \ test/sharness.sh \ test/squashfs.config \ test/tar.config \ @@ -271,6 +271,10 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) part->size = roundup(child->size, hd->align); else part->size = child->size; + } else if (child->size > part->size) { + image_error(image, "part %s size (%lld) too small for %s (%lld)\n", + part->name, part->size, child->file, child->size); + return -EINVAL; } } if (!part->size) { diff --git a/test/basic-images.test b/test/basic-images.test index 29a6e08..4439fc2 100755 --- a/test/basic-images.test +++ b/test/basic-images.test @@ -177,8 +177,8 @@ test_expect_success mke2fs,e2fsck "mke2fs" " setup_test_images() { rm -rf input && mkdir input && - dd if=/dev/null of=input/part1.img bs=512 count=7 && - dd if=/dev/null of=input/part2.img bs=512 count=11 + dd if=/dev/zero of=input/part1.img bs=512 count=7 && + dd if=/dev/zero of=input/part2.img bs=512 count=11 } exec_test_set_prereq dd @@ -190,17 +190,17 @@ test_expect_success "flash" " exec_test_set_prereq fdisk exec_test_set_prereq sfdisk -test_expect_success "hdimage" " +test_expect_success fdisk,sfdisk "hdimage" " setup_test_images && run_genimage hdimage.config test.hdimage && - check_size images/test.hdimage 9437184 && + check_size images/test.hdimage 9442816 && # check the this identifier fdisk -l images/test.hdimage | grep identifier: > hdimage.fdisk && # check partitions; filter output to handle different sfdisk versions sfdisk -d images/test.hdimage 2>/dev/null | grep '^images/' | \ sed -e 's/ *//g' -e 's;Id=;type=;' >> hdimage.fdisk && test_cmp '${testdir}/hdimage.fdisk' hdimage.fdisk && - check_size images/test.hdimage-2 11534336 && + check_size images/test.hdimage-2 11539968 && # check the this identifier fdisk -l images/test.hdimage-2 | grep identifier: > hdimage.fdisk-2 && # check partitions; filter output to handle different sfdisk versions @@ -209,6 +209,11 @@ test_expect_success "hdimage" " test_cmp '${testdir}/hdimage.fdisk-2' hdimage.fdisk-2 " +test_expect_success "hdimage2" " + setup_test_images && + test_must_fail run_genimage hdimage2.config test.hdimage +" + exec_test_set_prereq genisoimage test_expect_success genisoimage "iso" " run_genimage iso.config test.iso && @@ -227,12 +232,9 @@ exec_test_set_prereq qemu-img test_expect_success dd,diff,qemu-img "qemu" " setup_test_images && run_genimage qemu.config test.qcow && - check_size images/test.qcow 196608 && qemu-img check images/test.qcow && - qemu-img info images/test.qcow | \ - sed -e '/refcount bits:/d' -e '/corrupt:/d' > qemu.info && - test_cmp '${testdir}/qemu.info' qemu.info && - check_filelist + zcat '${testdir}/qemu.qcow.gz' > qemu.qcow && + qemu-img compare images/test.qcow qemu.qcow " exec_test_set_prereq mksquashfs diff --git a/test/flash.md5 b/test/flash.md5 index f8beb8e..2349569 100644 --- a/test/flash.md5 +++ b/test/flash.md5 @@ -1 +1 @@ -b23b5d09162b92c0284923a7f628d2a5 images/test.flash +3ac27658859853c3c49b1c8f4524e9cc images/test.flash diff --git a/test/hdimage2.config b/test/hdimage2.config new file mode 100644 index 0000000..79f8a2e --- /dev/null +++ b/test/hdimage2.config @@ -0,0 +1,10 @@ +image test.hdimage { + hdimage { + align = 1M + disk-signature = 0x12345678 + } + partition part1 { + image = "part2.img" + size = 5k + partition-type = 0x83 + } diff --git a/test/qemu.info b/test/qemu.info deleted file mode 100644 index c918c38..0000000 --- a/test/qemu.info +++ /dev/null @@ -1,8 +0,0 @@ -image: images/test.qcow -file format: qcow2 -virtual size: 0 (0 bytes) -disk size: 192K -cluster_size: 65536 -Format specific information: - compat: 1.1 - lazy refcounts: false diff --git a/test/qemu.qcow.gz b/test/qemu.qcow.gz Binary files differnew file mode 100644 index 0000000..3ce1af7 --- /dev/null +++ b/test/qemu.qcow.gz |