summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVince Chang <vince_chang@aspeedtech.com>2024-10-28 11:46:18 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-10-29 11:19:57 +0000
commit0a27b7b9a478430e1e41ef387f1c5b7fbf03f8e8 (patch)
treecec650391522e7b06606e4529412cd78bf024d85
parent6d90d0ba44a00fc92861040b05f39e0ef93d9b99 (diff)
downloadpoky-0a27b7b9a478430e1e41ef387f1c5b7fbf03f8e8.tar.gz
selftest: wic: add test for WIC_SECTOR_SIZE
Add test for WIC_SECTOR_SIZE=4096. Verified it on ext4 file system. (From OE-Core rev: 69a1f18ce18d67881d7379ccc19ca001a35acb68) Signed-off-by: Vince Chang <vince_chang@aspeedtech.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index 5e475f9e3f..c96018abbb 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -839,6 +839,56 @@ bootloader --ptable gpt""")
839 finally: 839 finally:
840 os.remove(wks_file) 840 os.remove(wks_file)
841 841
842 def test_wic_sector_size(self):
843 """Test generation image sector size"""
844 # Add WIC_SECTOR_SIZE into config
845 config = 'WIC_SECTOR_SIZE = "4096"\n'\
846 'WIC_BLOCK_SIZE = "4096"\n'\
847 'WICVARS:append = " WIC_SECTOR_SIZE WIC_BLOCK_SIZE"\n'
848 self.append_config(config)
849 bitbake('core-image-minimal')
850
851 # Check WIC_SECTOR_SIZE apply to bitbake variable
852 wic_sector_size_str = get_bb_var('WIC_SECTOR_SIZE', 'core-image-minimal')
853 wic_sector_size = int(wic_sector_size_str)
854 self.assertEqual(4096, wic_sector_size)
855
856 self.logger.info("Test wic_sector_size: %d \n" % wic_sector_size)
857
858 with NamedTemporaryFile("w", suffix=".wks") as wks:
859 wks.writelines(
860 ['bootloader --ptable gpt\n',
861 'part --fstype ext4 --source rootfs --label rofs-a --mkfs-extraopts "-b 4096"\n',
862 'part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts "-b 4096"\n'])
863 wks.flush()
864 cmd = "wic create %s -e core-image-minimal -o %s" % (wks.name, self.resultdir)
865 runCmd(cmd)
866 wksname = os.path.splitext(os.path.basename(wks.name))[0]
867 images = glob(os.path.join(self.resultdir, "%s-*direct" % wksname))
868 self.assertEqual(1, len(images))
869
870 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools')
871 # list partitions
872 result = runCmd("wic ls %s -n %s" % (images[0], sysroot))
873 self.assertEqual(3, len(result.output.split('\n')))
874 self.logger.info("result: %s \n" % result.output)
875
876 # verify partition size with wic
877 res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %s unit b p 2>/dev/null" % (wic_sector_size, images[0]))
878
879 self.logger.info("res: %s \n" % res.output)
880 # parse parted output which looks like this:
881 # BYT;\n
882 # /var/tmp/wic/build/tmpgjzzefdd-202410281021-sda.direct:78569472B:file:4096:4096:gpt::;\n
883 # 1:139264B:39284735B:39145472B:ext4:rofs-a:;\n
884 # 2:39284736B:78430207B:39145472B:ext4:primary:;\n
885 disk_info = res.output.splitlines()[1]
886 # Check sector sizes
887 sector_size_logical = int(disk_info.split(":")[3])
888 sector_size_physical = int(disk_info.split(":")[4])
889 self.assertEqual(wic_sector_size, sector_size_logical, "Logical sector size is not %d." % wic_sector_size)
890 self.assertEqual(wic_sector_size, sector_size_physical, "Physical sector size is not %d." % wic_sector_size)
891
842 892
843class Wic2(WicTestCase): 893class Wic2(WicTestCase):
844 894