From 2b8299eb6b911e64d9a05b86c07b489d15eeaa5e Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Fri, 8 Apr 2016 10:14:19 +0100 Subject: oeqa/selftest/wic: add test case for sparse images Add a testcase to build a directdisk image and check that the used disk size is less than the apparent size, as wic now assembles images as sparse files. Signed-off-by: Joshua Lock Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- meta/lib/oeqa/selftest/wic.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py index a569fbf747..dd3207528e 100644 --- a/meta/lib/oeqa/selftest/wic.py +++ b/meta/lib/oeqa/selftest/wic.py @@ -276,3 +276,16 @@ class Wic(oeSelfTest): status, output = qemu.run_serial(command) self.assertEqual(1, status, 'Failed to run command "%s": %s' % (command, output)) self.assertEqual(output, '/dev/root /\r\n/dev/vda3 /mnt') + + def test_sparseness(self): + """Test that assembled images are sparse; apparent size > disk usage""" + self.assertEqual(0, runCmd("wic create directdisk " + "--image-name core-image-minimal").status) + images = glob(self.resultdir + "directdisk-*.direct") + self.assertEqual(1, len(images)) + + imagestat = os.stat(images.pop()) + # st_blocks is the "number of 512-byte blocks allocated for file" + used = imagestat.st_blocks*512 + apparent = imagestat.st_size + self.assertLess(used, apparent) -- cgit 1.2.3-korg