selftest/package: Add test to ensure sparse files are preserved

Add a new element to the hardlink test to check we also preseve file
sparseness during the packing process. This should ensure we don't regress this
issue again.

(From OE-Core rev: 0a4e6974b49bf68c4a4098d339b5d655e202a3fd)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2018-08-12 22:29:18 +00:00
parent 5f8a152513
commit 20c8be711f
2 changed files with 7 additions and 0 deletions

View File

@@ -16,4 +16,5 @@ do_install () {
ln ${D}${bindir}/hello ${D}${bindir}/hello2
ln ${D}${bindir}/hello ${D}${bindir}/hello3
ln ${D}${bindir}/hello ${D}${bindir}/hello4
dd if=/dev/zero of=${D}${bindir}/sparsetest bs=1 count=0 seek=1M
}

View File

@@ -88,6 +88,7 @@ class VersionOrdering(OESelftestTestCase):
class PackageTests(OESelftestTestCase):
# Verify that a recipe which sets up hardlink files has those preserved into split packages
# Also test file sparseness is preserved
def test_preserve_hardlinks(self):
result = bitbake("selftest-hardlink -c package")
@@ -97,3 +98,8 @@ class PackageTests(OESelftestTestCase):
# Recipe creates 4 hardlinked files, there is a copy in package/ and a copy in packages-split/
# so expect 8 in total.
self.assertEqual(os.stat(dest + "/selftest-hardlink" + bindir + "/hello").st_nlink, 8)
# Test a sparse file remains sparse
sparsestat = os.stat(dest + "/selftest-hardlink" + bindir + "/sparsetest")
self.assertEqual(sparsestat.st_blocks, 0)
self.assertEqual(sparsestat.st_size, 1048576)