summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Funke <lukas.funke@weidmueller.com>2023-11-28 14:52:32 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-06 22:55:49 +0000
commit2da0213eeef3dc76b0f352912b3f2d5cd2cc4020 (patch)
tree14b3c2edc0e42386c74bf7566153b4dfce2cbcea
parent29b2bda7867e8564404303faf4b01f37dba594a2 (diff)
downloadpoky-2da0213eeef3dc76b0f352912b3f2d5cd2cc4020.tar.gz
selftest: wic: add test for zerorize option of empty plugin
Add test for empty plugin which tests whether the plugin creates partitions with actual data which is 'zero'. (From OE-Core rev: 6c6b236b34b35d0e2c020e0f9c447ac35adf8faf) Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index 4ebcb76cc4..b616759209 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -1483,6 +1483,42 @@ class Wic2(WicTestCase):
1483 result = runCmd("%s/usr/sbin/sfdisk --part-label %s 3" % (sysroot, image_path)) 1483 result = runCmd("%s/usr/sbin/sfdisk --part-label %s 3" % (sysroot, image_path))
1484 self.assertEqual('ext-space', result.output) 1484 self.assertEqual('ext-space', result.output)
1485 1485
1486 def test_empty_zeroize_plugin(self):
1487 img = 'core-image-minimal'
1488 expected_size = [ 1024*1024, # 1M
1489 512*1024, # 512K
1490 2*1024*1024] # 2M
1491 # Check combination of sourceparams
1492 with NamedTemporaryFile("w", suffix=".wks") as wks:
1493 wks.writelines(
1494 ['part empty --source empty --sourceparams="fill" --ondisk sda --fixed-size 1M\n',
1495 'part empty --source empty --sourceparams="size=512K" --ondisk sda --size 1M --align 1024\n',
1496 'part empty --source empty --sourceparams="size=2048k,bs=512K" --ondisk sda --size 4M --align 1024\n'
1497 ])
1498 wks.flush()
1499 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
1500 runCmd(cmd)
1501 wksname = os.path.splitext(os.path.basename(wks.name))[0]
1502 wicout = glob(os.path.join(self.resultdir, "%s-*direct" % wksname))
1503 # Skip the complete image and just look at the single partitions
1504 for idx, value in enumerate(wicout[1:]):
1505 self.logger.info(wicout[idx])
1506 # Check if partitions are actually zeroized
1507 with open(wicout[idx], mode="rb") as fd:
1508 ba = bytearray(fd.read())
1509 for b in ba:
1510 self.assertEqual(b, 0)
1511 self.assertEqual(expected_size[idx], os.path.getsize(wicout[idx]))
1512
1513 # Check inconsistancy check between "fill" and "--size" parameter
1514 with NamedTemporaryFile("w", suffix=".wks") as wks:
1515 wks.writelines(['part empty --source empty --sourceparams="fill" --ondisk sda --size 1M\n'])
1516 wks.flush()
1517 cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
1518 result = runCmd(cmd, ignore_status=True)
1519 self.assertIn("Source parameter 'fill' only works with the '--fixed-size' option, exiting.", result.output)
1520 self.assertNotEqual(0, result.status)
1521
1486class ModifyTests(WicTestCase): 1522class ModifyTests(WicTestCase):
1487 def test_wic_ls(self): 1523 def test_wic_ls(self):
1488 """Test listing image content using 'wic ls'""" 1524 """Test listing image content using 'wic ls'"""