summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorYoann Congal <yoann.congal@smile.fr>2025-10-03 23:12:47 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-10-06 23:16:00 +0100
commit82eb9a0c365c208f85796ee3a008a8827cfa0c77 (patch)
tree49a90c209d093156fd675737d4a01e7cd47bd4a5 /meta/lib
parent107da7da4b89e224e823e2f46f36a0cf772994c1 (diff)
downloadpoky-82eb9a0c365c208f85796ee3a008a8827cfa0c77.tar.gz
oeqa/selftest/wic: fix PATH for wic.Wic2.test_extra_partition_space
Without importing PATH from the wic-tools recipes, the build host PATH is used and this test may fail depending on tools (parted, dumpe2fs, ...) availability. This triggers build faillure on AB (e.g. [0]) To fix this, import PATH from wic-tools and ensure the original environment is restored after. Since this indent a block of code into a try/finally block, here is the diff ignoring white spaces change: diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index b1c318bd4e..34d844b90b 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py @@ -1331,0 +1332,4 @@ + oldpath = os.environ['PATH'] + os.environ['PATH'] = get_bb_var("PATH", "wic-tools") + + try: @@ -1366,0 +1371,2 @@ + finally: + os.environ['PATH'] = oldpath [0]: https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/2456 (From OE-Core rev: a6278a199807f1ad7ed1e27ec352af46e03e8b67) Signed-off-by: Yoann Congal <yoann.congal@smile.fr> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py74
1 files changed, 40 insertions, 34 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index e7e5dcb7e7..78de2fcfd0 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -1330,41 +1330,47 @@ run_wic_cmd() {
1330 def test_extra_partition_space(self): 1330 def test_extra_partition_space(self):
1331 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools") 1331 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools")
1332 1332
1333 with NamedTemporaryFile("w", suffix=".wks") as tempf: 1333 oldpath = os.environ['PATH']
1334 tempf.write("bootloader --ptable gpt\n" \ 1334 os.environ['PATH'] = get_bb_var("PATH", "wic-tools")
1335 "part --ondisk hda --size 10M --extra-partition-space 10M --fstype=ext4\n" \
1336 "part --ondisk hda --fixed-size 20M --extra-partition-space 10M --fstype=ext4\n" \
1337 "part --source rootfs --ondisk hda --extra-partition-space 10M --fstype=ext4\n" \
1338 "part --source rootfs --ondisk hda --fixed-size 200M --extra-partition-space 10M --fstype=ext4\n")
1339 tempf.flush()
1340
1341 _, wicimg = self._get_wic(tempf.name)
1342
1343 res = runCmd("parted -m %s unit b p" % wicimg,
1344 native_sysroot=native_sysroot, stderr=subprocess.PIPE)
1345
1346 # parse parted output which looks like this:
1347 # BYT;\n
1348 # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n
1349 # 1:0.00MiB:200MiB:200MiB:ext4::;\n
1350 partlns = res.output.splitlines()[2:]
1351
1352 self.assertEqual(4, len(partlns))
1353 1335
1354 # Test for each partitions that the extra part space exists 1336 try:
1355 for part in range(0, len(partlns)): 1337 with NamedTemporaryFile("w", suffix=".wks") as tempf:
1356 part_file = os.path.join(self.resultdir, "selftest_img.part%d" % (part + 1)) 1338 tempf.write("bootloader --ptable gpt\n" \
1357 partln = partlns[part].split(":") 1339 "part --ondisk hda --size 10M --extra-partition-space 10M --fstype=ext4\n" \
1358 self.assertEqual(7, len(partln)) 1340 "part --ondisk hda --fixed-size 20M --extra-partition-space 10M --fstype=ext4\n" \
1359 self.assertRegex(partln[3], r'^[0-9]+B$') 1341 "part --source rootfs --ondisk hda --extra-partition-space 10M --fstype=ext4\n" \
1360 part_size = int(partln[3].rstrip("B")) 1342 "part --source rootfs --ondisk hda --fixed-size 200M --extra-partition-space 10M --fstype=ext4\n")
1361 start = int(partln[1].rstrip("B")) / 512 1343 tempf.flush()
1362 length = part_size / 512 1344
1363 runCmd("dd if=%s of=%s skip=%d count=%d" % 1345 _, wicimg = self._get_wic(tempf.name)
1364 (wicimg, part_file, start, length)) 1346
1365 res = runCmd("dumpe2fs %s -h | grep \"^Block count\"" % part_file) 1347 res = runCmd("parted -m %s unit b p" % wicimg,
1366 fs_size = int(res.output.split(":")[1].strip()) * 1024 1348 native_sysroot=native_sysroot, stderr=subprocess.PIPE)
1367 self.assertLessEqual(fs_size + 10485760, part_size, "part file: %s" % part_file) 1349
1350 # parse parted output which looks like this:
1351 # BYT;\n
1352 # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n
1353 # 1:0.00MiB:200MiB:200MiB:ext4::;\n
1354 partlns = res.output.splitlines()[2:]
1355
1356 self.assertEqual(4, len(partlns))
1357
1358 # Test for each partitions that the extra part space exists
1359 for part in range(0, len(partlns)):
1360 part_file = os.path.join(self.resultdir, "selftest_img.part%d" % (part + 1))
1361 partln = partlns[part].split(":")
1362 self.assertEqual(7, len(partln))
1363 self.assertRegex(partln[3], r'^[0-9]+B$')
1364 part_size = int(partln[3].rstrip("B"))
1365 start = int(partln[1].rstrip("B")) / 512
1366 length = part_size / 512
1367 runCmd("dd if=%s of=%s skip=%d count=%d" %
1368 (wicimg, part_file, start, length))
1369 res = runCmd("dumpe2fs %s -h | grep \"^Block count\"" % part_file)
1370 fs_size = int(res.output.split(":")[1].strip()) * 1024
1371 self.assertLessEqual(fs_size + 10485760, part_size, "part file: %s" % part_file)
1372 finally:
1373 os.environ['PATH'] = oldpath
1368 1374
1369 # TODO this test could also work on aarch64 1375 # TODO this test could also work on aarch64
1370 @skipIfNotArch(['i586', 'i686', 'x86_64']) 1376 @skipIfNotArch(['i586', 'i686', 'x86_64'])