[PATCH 1/2] oeqa/selftest: wic: Add vfat to test_wic_sector_size

Mark Hatle
2026-03-13T00:29:28Z

Add an empty vfat partition to the 4k sector size test. This ensures that
the -S 4096 option is passed to mkfs.vfat, and the resulting filesystem is
generated.

We also now verify that the requested partitions, and names were created
as expected. Size does not matter, only the partition type and name.

Note, there is a known issue in parted that 4096 fat partitions are not
recognized by fstype, so report themselves as empty in the regular output.
Both wic ls and parted p show an unknown filesytem type. However, the type
of the partition (last field) is set to msftdata, so we can use that
instead.

Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
---
meta/lib/oeqa/selftest/cases/wic.py | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index ecaee5a..c4bc5a4 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -958,6 +958,7 @@ bootloader --ptable gpt""")
with NamedTemporaryFile("w", suffix=".wks") as wks:
wks.writelines(
['bootloader --ptable gpt\n',
+ 'part --fstype vfat --fstype vfat --label emptyfat --size 1M --mkfs-extraopts "-S 4096"\n',
'part --fstype ext4 --source rootfs --label rofs-a --mkfs-extraopts "-b 4096"\n',
'part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts "-b 4096"\n'])
wks.flush()
@@ -970,17 +971,21 @@ bootloader --ptable gpt""")
sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools')
# list partitions
result = runCmd("wic ls %s -n %s" % (images[0], sysroot))
- self.assertEqual(3, len(result.output.split('\n')))
+ print(result.output)
+ # 4 lines of output: header + 3 partition
+ self.assertEqual(4, len(result.output.split('\n')))

# verify partition size with wic
res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %s unit b p" % (wic_sector_size, images[0]),
stderr=subprocess.PIPE)

+ print(res.output)
# parse parted output which looks like this:
# BYT;\n
# /var/tmp/wic/build/tmpgjzzefdd-202410281021-sda.direct:78569472B:file:4096:4096:gpt::;\n
- # 1:139264B:39284735B:39145472B:ext4:rofs-a:;\n
- # 2:39284736B:78430207B:39145472B:ext4:primary:;\n
+ # 1:139264B:1187839B:1048576B::emptyfat:msftdata;
+ # 2:1187840B:149270527B:148082688B:ext4:rofs-a:;
+ # 3:149270528B:297353215B:148082688B:ext4:primary:;
disk_info = res.output.splitlines()[1]
# Check sector sizes
sector_size_logical = int(disk_info.split(":")[3])
@@ -988,6 +993,26 @@ bootloader --ptable gpt""")
self.assertEqual(wic_sector_size, sector_size_logical, "Logical sector size is not %d." % wic_sector_size)
self.assertEqual(wic_sector_size, sector_size_physical, "Physical sector size is not %d." % wic_sector_size)

+ # It is a known issue with parsed that a 4K FAT partition does
+ # not have a recognized filesystem type of *fat.
+ part_info = res.output.splitlines()[2]
+ partname = part_info.split(":")[5]
+ parttype = part_info.split(":")[6]
+ self.assertEqual('emptyfat', partname)
+ self.assertEqual('msftdata;', parttype)
+
+ part_info = res.output.splitlines()[3]
+ parttype = part_info.split(":")[4]
+ partname = part_info.split(":")[5]
+ self.assertEqual('ext4', parttype)
+ self.assertEqual('rofs-a', partname)
+
+ part_info = res.output.splitlines()[4]
+ parttype = part_info.split(":")[4]
+ partname = part_info.split(":")[5]
+ self.assertEqual('ext4', parttype)
+ self.assertEqual('primary', partname)
+
finally:
os.environ['PATH'] = oldpath

--
1.8.3.1