]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
oeqa/selftest/wic: fix PATH for wic.Wic2.test_extra_partition_plugin master
authorYoann Congal <yoann.congal@smile.fr>
Fri, 3 Oct 2025 21:12:48 +0000 (23:12 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 6 Oct 2025 22:15:57 +0000 (23:15 +0100)
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

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>
meta/lib/oeqa/selftest/cases/wic.py

index 78de2fcfd087e16e4ba7479bace54aa1eb10f5da..bb4ac23ebf3cfc80d24540ed5cd167d4fc90384a 100644 (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")
+
+        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)
 
-            result = runCmd("wic ls %s | wc -l" % wicimg)
-            self.assertEqual('4', result.output, msg="Expect 3 partitions, not %s" % result.output)
+                result = runCmd("wic ls %s | wc -l" % wicimg)
+                self.assertEqual('4', result.output, msg="Expect 3 partitions, not %s" % result.output)
 
-            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))
+                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)
+            self.remove_config(config)
+
+        finally:
+            os.environ['PATH'] = oldpath
 
     def test_fs_types(self):
         """Test filesystem types for empty and not empty partitions"""