diff options
| author | Vince Chang <vince_chang@aspeedtech.com> | 2024-11-01 16:22:08 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-11-01 23:03:32 +0000 |
| commit | 806c6b974b393faa4b0d289a24c44d1f78c851da (patch) | |
| tree | b46d2e1df7da266266c06e5c32b2aa7331409ab2 /meta/lib/oeqa | |
| parent | e07cda3174cb9c2895e0d57296ca83e03d2c8521 (diff) | |
| download | poky-806c6b974b393faa4b0d289a24c44d1f78c851da.tar.gz | |
selftest: wic: wic_sector_size add wic-tools path
Add wic-tools to the PATH to avoid failures when running the
wic_sector_size test case on a build host that doesn’t have parted.
(From OE-Core rev: 013dcdf75669421bc38d699263cb1e8d5b95d398)
Signed-off-by: Vince Chang <vince_chang@aspeedtech.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/wic.py | 92 |
1 files changed, 48 insertions, 44 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index fa7e4aae8c..207e487002 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py | |||
| @@ -842,55 +842,59 @@ bootloader --ptable gpt""") | |||
| 842 | 842 | ||
| 843 | def test_wic_sector_size(self): | 843 | def test_wic_sector_size(self): |
| 844 | """Test generation image sector size""" | 844 | """Test generation image sector size""" |
| 845 | # Add WIC_SECTOR_SIZE into config | 845 | |
| 846 | config = 'WIC_SECTOR_SIZE = "4096"\n'\ | 846 | oldpath = os.environ['PATH'] |
| 847 | 'WIC_BLOCK_SIZE = "4096"\n'\ | 847 | os.environ['PATH'] = get_bb_var("PATH", "wic-tools") |
| 848 | 'WICVARS:append = " WIC_SECTOR_SIZE WIC_BLOCK_SIZE"\n' | ||
| 849 | self.append_config(config) | ||
| 850 | bitbake('core-image-minimal') | ||
| 851 | |||
| 852 | # Check WIC_SECTOR_SIZE apply to bitbake variable | ||
| 853 | wic_sector_size_str = get_bb_var('WIC_SECTOR_SIZE', 'core-image-minimal') | ||
| 854 | wic_sector_size = int(wic_sector_size_str) | ||
| 855 | self.assertEqual(4096, wic_sector_size) | ||
| 856 | |||
| 857 | self.logger.info("Test wic_sector_size: %d \n" % wic_sector_size) | ||
| 858 | 848 | ||
| 859 | with NamedTemporaryFile("w", suffix=".wks") as wks: | 849 | try: |
| 860 | wks.writelines( | 850 | # Add WIC_SECTOR_SIZE into config |
| 861 | ['bootloader --ptable gpt\n', | 851 | config = 'WIC_SECTOR_SIZE = "4096"\n'\ |
| 862 | 'part --fstype ext4 --source rootfs --label rofs-a --mkfs-extraopts "-b 4096"\n', | 852 | 'WICVARS:append = " WIC_SECTOR_SIZE"\n' |
| 863 | 'part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts "-b 4096"\n']) | 853 | self.append_config(config) |
| 864 | wks.flush() | 854 | bitbake('core-image-minimal') |
| 865 | cmd = "wic create %s -e core-image-minimal -o %s" % (wks.name, self.resultdir) | 855 | |
| 866 | runCmd(cmd) | 856 | # Check WIC_SECTOR_SIZE apply to bitbake variable |
| 867 | wksname = os.path.splitext(os.path.basename(wks.name))[0] | 857 | wic_sector_size_str = get_bb_var('WIC_SECTOR_SIZE', 'core-image-minimal') |
| 868 | images = glob(os.path.join(self.resultdir, "%s-*direct" % wksname)) | 858 | wic_sector_size = int(wic_sector_size_str) |
| 869 | self.assertEqual(1, len(images)) | 859 | self.assertEqual(4096, wic_sector_size) |
| 860 | |||
| 861 | self.logger.info("Test wic_sector_size: %d \n" % wic_sector_size) | ||
| 862 | |||
| 863 | with NamedTemporaryFile("w", suffix=".wks") as wks: | ||
| 864 | wks.writelines( | ||
| 865 | ['bootloader --ptable gpt\n', | ||
| 866 | 'part --fstype ext4 --source rootfs --label rofs-a --mkfs-extraopts "-b 4096"\n', | ||
| 867 | 'part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts "-b 4096"\n']) | ||
| 868 | wks.flush() | ||
| 869 | cmd = "wic create %s -e core-image-minimal -o %s" % (wks.name, self.resultdir) | ||
| 870 | runCmd(cmd) | ||
| 871 | wksname = os.path.splitext(os.path.basename(wks.name))[0] | ||
| 872 | images = glob(os.path.join(self.resultdir, "%s-*direct" % wksname)) | ||
| 873 | self.assertEqual(1, len(images)) | ||
| 870 | 874 | ||
| 871 | sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') | 875 | sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') |
| 872 | # list partitions | 876 | # list partitions |
| 873 | result = runCmd("wic ls %s -n %s" % (images[0], sysroot)) | 877 | result = runCmd("wic ls %s -n %s" % (images[0], sysroot)) |
| 874 | self.assertEqual(3, len(result.output.split('\n'))) | 878 | self.assertEqual(3, len(result.output.split('\n'))) |
| 875 | self.logger.info("result: %s \n" % result.output) | ||
| 876 | 879 | ||
| 877 | # verify partition size with wic | 880 | # verify partition size with wic |
| 878 | res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %s unit b p" % (wic_sector_size, images[0]), | 881 | res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %s unit b p" % (wic_sector_size, images[0]), |
| 879 | stderr=subprocess.PIPE) | 882 | stderr=subprocess.PIPE) |
| 880 | 883 | ||
| 881 | self.logger.info("res: %s \n" % res.output) | 884 | # parse parted output which looks like this: |
| 882 | # parse parted output which looks like this: | 885 | # BYT;\n |
| 883 | # BYT;\n | 886 | # /var/tmp/wic/build/tmpgjzzefdd-202410281021-sda.direct:78569472B:file:4096:4096:gpt::;\n |
| 884 | # /var/tmp/wic/build/tmpgjzzefdd-202410281021-sda.direct:78569472B:file:4096:4096:gpt::;\n | 887 | # 1:139264B:39284735B:39145472B:ext4:rofs-a:;\n |
| 885 | # 1:139264B:39284735B:39145472B:ext4:rofs-a:;\n | 888 | # 2:39284736B:78430207B:39145472B:ext4:primary:;\n |
| 886 | # 2:39284736B:78430207B:39145472B:ext4:primary:;\n | 889 | disk_info = res.output.splitlines()[1] |
| 887 | disk_info = res.output.splitlines()[1] | 890 | # Check sector sizes |
| 888 | # Check sector sizes | 891 | sector_size_logical = int(disk_info.split(":")[3]) |
| 889 | sector_size_logical = int(disk_info.split(":")[3]) | 892 | sector_size_physical = int(disk_info.split(":")[4]) |
| 890 | sector_size_physical = int(disk_info.split(":")[4]) | 893 | self.assertEqual(wic_sector_size, sector_size_logical, "Logical sector size is not %d." % wic_sector_size) |
| 891 | self.assertEqual(wic_sector_size, sector_size_logical, "Logical sector size is not %d." % wic_sector_size) | 894 | self.assertEqual(wic_sector_size, sector_size_physical, "Physical sector size is not %d." % wic_sector_size) |
| 892 | self.assertEqual(wic_sector_size, sector_size_physical, "Physical sector size is not %d." % wic_sector_size) | ||
| 893 | 895 | ||
| 896 | finally: | ||
| 897 | os.environ['PATH'] = oldpath | ||
| 894 | 898 | ||
| 895 | class Wic2(WicTestCase): | 899 | class Wic2(WicTestCase): |
| 896 | 900 | ||
