oeqa/selftest/wic: fix PATH for wic.Wic2.test_extra_partition_plugin

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 bff3842305..bc99673d0d 100644
  --- a/meta/lib/oeqa/selftest/cases/wic.py
  +++ b/meta/lib/oeqa/selftest/cases/wic.py
  @@ -1680,0 +1681,4 @@ INITRAMFS_IMAGE = "core-image-initramfs-boot"
  +        oldpath = os.environ['PATH']
  +        os.environ['PATH'] = get_bb_var("PATH", "wic-tools")
  +
  +        try:
  @@ -1696,0 +1701,3 @@ INITRAMFS_IMAGE = "core-image-initramfs-boot"
  +        finally:
  +            os.environ['PATH'] = oldpath
  +

[0]: https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/2456

(From OE-Core rev: 9dfd4f44d4f40e7926dc88cb564baa2345c2a24f)

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>
This commit is contained in:
Yoann Congal
2025-10-03 23:12:48 +02:00
committed by Richard Purdie
parent 82eb9a0c36
commit 9ef953f10d

View File

@@ -1678,21 +1678,28 @@ INITRAMFS_IMAGE = "core-image-initramfs-boot"
testfile.write("test")
testfile.close()
with NamedTemporaryFile("w", suffix=".wks") as wks:
wks.writelines(['part / --source extra_partition --ondisk sda --fstype=ext4 --label foo --align 4 --size 5M\n',
'part / --source extra_partition --ondisk sda --fstype=ext4 --uuid e7d0824e-cda3-4bed-9f54-9ef5312d105d --align 4 --size 5M\n',
'part / --source extra_partition --ondisk sda --fstype=ext4 --label bar --align 4 --size 5M\n'])
wks.flush()
_, wicimg = self._get_wic(wks.name)
oldpath = os.environ['PATH']
os.environ['PATH'] = get_bb_var("PATH", "wic-tools")
result = runCmd("wic ls %s | wc -l" % wicimg)
self.assertEqual('4', result.output, msg="Expect 3 partitions, not %s" % result.output)
try:
with NamedTemporaryFile("w", suffix=".wks") as wks:
wks.writelines(['part / --source extra_partition --ondisk sda --fstype=ext4 --label foo --align 4 --size 5M\n',
'part / --source extra_partition --ondisk sda --fstype=ext4 --uuid e7d0824e-cda3-4bed-9f54-9ef5312d105d --align 4 --size 5M\n',
'part / --source extra_partition --ondisk sda --fstype=ext4 --label bar --align 4 --size 5M\n'])
wks.flush()
_, wicimg = self._get_wic(wks.name)
for part, file in enumerate(["foo.conf", "foobar.conf", "bar.conf"]):
result = runCmd("wic ls %s:%d | grep -q \"%s\"" % (wicimg, part + 1, file))
self.assertEqual(0, result.status, msg="File '%s' not found in the partition #%d" % (file, part))
result = runCmd("wic ls %s | wc -l" % wicimg)
self.assertEqual('4', result.output, msg="Expect 3 partitions, not %s" % result.output)
self.remove_config(config)
for part, file in enumerate(["foo.conf", "foobar.conf", "bar.conf"]):
result = runCmd("wic ls %s:%d | grep -q \"%s\"" % (wicimg, part + 1, file))
self.assertEqual(0, result.status, msg="File '%s' not found in the partition #%d" % (file, part))
self.remove_config(config)
finally:
os.environ['PATH'] = oldpath
def test_fs_types(self):
"""Test filesystem types for empty and not empty partitions"""