@@ -57,10 +57,12 @@ class WicTestCase(OESelftestTestCase):
image_is_ready = False
wicenv_cache = {}
+ wic_bindir = None
def setUpLocal(self):
"""This code is executed before each test method."""
self.resultdir = os.path.join(self.builddir, "wic-tmp")
+ self._old_path = os.environ.get('PATH')
super(WicTestCase, self).setUpLocal()
# Do this here instead of in setUpClass as the base setUp does some
@@ -72,13 +74,45 @@ class WicTestCase(OESelftestTestCase):
bitbake('wic-tools core-image-minimal core-image-minimal-mtdutils')
WicTestCase.image_is_ready = True
+
+ os.environ['PATH'] = self._get_wic_path()
rmtree(self.resultdir, ignore_errors=True)
def tearDownLocal(self):
"""Remove resultdir as it may contain images."""
+ if self._old_path is None:
+ os.environ.pop('PATH', None)
+ else:
+ os.environ['PATH'] = self._old_path
rmtree(self.resultdir, ignore_errors=True)
super(WicTestCase, self).tearDownLocal()
+ def _get_wic_path(self):
+ if WicTestCase.wic_bindir is None:
+ search_paths = [
+ os.path.join(self.td['COREBASE'], 'scripts'),
+ os.path.join(get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools'), 'usr', 'bin'),
+ ]
+
+ for bindir in search_paths:
+ if os.path.exists(os.path.join(bindir, 'wic')):
+ WicTestCase.wic_bindir = bindir
+ break
+
+ if WicTestCase.wic_bindir is None:
+ self.fail("Unable to find the wic binary in %s" % ', '.join(search_paths))
+
+ path_entries = []
+ for path_group in (
+ [WicTestCase.wic_bindir],
+ (get_bb_var("PATH", "wic-tools") or '').split(':'),
+ (self._old_path or '').split(':')):
+ for entry in path_group:
+ if entry and entry not in path_entries:
+ path_entries.append(entry)
+
+ return ':'.join(path_entries)
+
def _get_image_env_path(self, image):
"""Generate and obtain the path to <image>.env"""
if image not in WicTestCase.wicenv_cache:
@@ -88,7 +122,7 @@ class WicTestCase(OESelftestTestCase):
WicTestCase.wicenv_cache[image] = os.path.join(stdir, machine, 'imgdata')
return WicTestCase.wicenv_cache[image]
-class CLITests(OESelftestTestCase):
+class CLITests(WicTestCase):
def test_version(self):
"""Test wic --version"""
runCmd('wic --version')
The wic oe-selftest defines its own class (WicTestCase) for handling setup, teardown, and various other pieces needed to run the individual wic oe-selftests. As part of oe-core, the wic.CLITests do not need setup and teardown. However, once wic is no longer part of oe-core, the oe-selftests will need to know where to find wic that comes from a recipe. Update PATH so wic will be available. NOTE: this patch is in preparation for removing wic from oe-core the wic oe-selftests work fine with this patch being added now AI-Generated: codex/gpt-5.4 (high) Reviewed-by: Bruce Ashfield <bruce.ashfield@gmail.com> Reviewed-by: Mark Hatle <mark.hatle@kernel.crashing.org> Signed-off-by: Trevor Woerner <twoerner@gmail.com> --- changes in v9: - provide a smaller change to the wic test bbclass in order to allow the oe-selftests to work, this patch only updates the PATH changes in v8: - (skipped, sector-size cmdline arg upstreamed) changes in v7: - (none) changes in v6: - (none) changes in v5: - rebase with master - split patch set back out into smaller patches changes in v4: - (skipped) changes in v3: - squashed into one large patch changes in v2: - (none) --- meta/lib/oeqa/selftest/cases/wic.py | 36 ++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)