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.

(From OE-Core rev: 2b8299eb6b911e64d9a05b86c07b489d15eeaa5e)

Signed-off-by: Joshua Lock <joshua.lock@collabora.co.uk>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Lock 2016-04-08 10:14:19 +01:00 committed by Richard Purdie
parent 29bc2f7423
commit 43150ab7ec
1 changed files with 13 additions and 0 deletions

View File

@ -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)