diff mbox series

[3/3] kernel-fit-image: drop the synthetic FIT_LOADABLE_* values

Message ID 20261028211203.3081460-4-adrian.freihofer@siemens.com
State New
Headers show
Series oeqa/utils/commands: add get_bb_vars_flags and build get_bb_var(s) on it | expand

Commit Message

AdrianF Oct. 28, 2026, 9:11 p.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

The anonymous function sets the FIT_LOADABLE_* variables to the flags of
all loadables joined by " ? ", e.g. "0x86000000 ? 0x87000000". This was
done only to make the flags visible to the selftests, which could read
variables but not flags. do_compile reads the flags directly and does
not need these values.

get_bb_vars_flags can read variable flags now. Let the test request
the FIT_LOADABLE_* flags of the loadables it configures and drop the
synthetic values from the class.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 meta/classes-recipe/kernel-fit-image.bbclass |  7 ++----
 meta/lib/oeqa/selftest/cases/fitimage.py     | 24 ++++++++++++--------
 2 files changed, 16 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel-fit-image.bbclass b/meta/classes-recipe/kernel-fit-image.bbclass
index a238de1aa2..abf7327c97 100644
--- a/meta/classes-recipe/kernel-fit-image.bbclass
+++ b/meta/classes-recipe/kernel-fit-image.bbclass
@@ -32,8 +32,8 @@  python () {
     # Parse loadables config
     loadables = d.getVar('FIT_LOADABLES')
     if loadables:
-        # Forbid direct assignment, set synthetic values for testability and
-        # add the vars to vardeps so their flags are part of the signature.
+        # Only flags are supported. Add the vars to vardeps so their flags are
+        # part of the signature.
         loadable_vars = ['FIT_LOADABLE_ARCH', 'FIT_LOADABLE_COMPRESSION',
                          'FIT_LOADABLE_DESCRIPTION', 'FIT_LOADABLE_ENTRYPOINT',
                          'FIT_LOADABLE_FILENAME', 'FIT_LOADABLE_LOADADDRESS',
@@ -41,9 +41,6 @@  python () {
         for v in loadable_vars:
             if d.getVar(v):
                 raise bb.parse.SkipRecipe("You cannot use %s as a variable, you can only set flags." % v)
-
-            synt_value = " ? ".join([ d.getVarFlag(v, loadable) or "" for loadable in loadables.split() ])
-            d.setVar(v, synt_value)
         d.appendVarFlag('do_compile', 'vardeps', ' ' + ' '.join(loadable_vars))
 }
 
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py
index 81d2be5013..1fad53b16c 100644
--- a/meta/lib/oeqa/selftest/cases/fitimage.py
+++ b/meta/lib/oeqa/selftest/cases/fitimage.py
@@ -14,7 +14,7 @@  import oe.fitimage
 
 from bb import BBHandledException
 from oeqa.selftest.case import OESelftestTestCase
-from oeqa.utils.commands import runCmd, bitbake, get_bb_vars, get_bb_var
+from oeqa.utils.commands import runCmd, bitbake, get_bb_vars, get_bb_vars_flags, get_bb_var
 
 
 class BbVarsMockGenKeys:
@@ -662,10 +662,12 @@  class FitImageTestCase(OESelftestTestCase):
 class KernelFitImageBase(FitImageTestCase):
     """Test cases for the linux-yocto-fitimage recipe"""
 
-    def _fit_get_bb_vars(self, additional_vars=[]):
+    def _fit_get_bb_vars(self, additional_vars=[], flags=None):
         """Retrieve BitBake variables specific to the test case.
 
-        Call the get_bb_vars function once and get all variables needed by the test case.
+        Call the get_bb_vars_flags function once and get all variables needed by
+        the test case. flags maps variable names to lists of flag names. The
+        flags are returned as dict {flag name: value} for their variable name.
         """
         internal_used = {
             'DEPLOY_DIR_IMAGE',
@@ -676,8 +678,6 @@  class KernelFitImageBase(FitImageTestCase):
             'FIT_HASH_ALG',
             'FIT_KERNEL_COMP_ALG',
             'FIT_LOADABLES',
-            'FIT_LOADABLE_ENTRYPOINT',
-            'FIT_LOADABLE_LOADADDRESS',
             'FIT_OS',
             'FIT_SIGN_ALG',
             'FIT_SIGN_INDIVIDUAL',
@@ -712,7 +712,9 @@  class KernelFitImageBase(FitImageTestCase):
             'UBOOT_FIT_TEE_LOADADDRESS',
             'UBOOT_FIT_TEE_ENTRYPOINT',
         }
-        bb_vars = get_bb_vars(list(internal_used | set(additional_vars)), self.kernel_recipe)
+        bb_vars, bb_flags = get_bb_vars_flags([*internal_used, *additional_vars], flags, self.kernel_recipe)
+        bb_vars = {var: val or None for var, val in bb_vars.items()}
+        bb_vars.update(bb_flags)
         self.logger.debug("bb_vars: %s" % pprint.pformat(bb_vars, indent=4))
         return bb_vars
 
@@ -1025,10 +1027,10 @@  class KernelFitImageBase(FitImageTestCase):
                 "Entry Point": bb_vars['UBOOT_RD_ENTRYPOINT']
             }
         # Create one section per loadable
-        for index,loadable in enumerate(loadables):
-            loadaddress = bb_vars['FIT_LOADABLE_LOADADDRESS'].split("?")[index].strip()
+        for loadable in loadables:
+            loadaddress = bb_vars['FIT_LOADABLE_LOADADDRESS'][loadable]
             req_sections[loadable] = { "Load Address": loadaddress }
-            entrypoint = bb_vars['FIT_LOADABLE_ENTRYPOINT'].split("?")[index].strip()
+            entrypoint = bb_vars['FIT_LOADABLE_ENTRYPOINT'][loadable]
             if entrypoint:
                 req_sections[loadable]['Entry Point'] = entrypoint
         # Create a configuration section for each DTB
@@ -1204,7 +1206,9 @@  FIT_LOADABLE_TYPE[loadable2] = "firmware"
         config = FitImageTestCase._config_add_machine_settings(config, machine, keys=["KERNEL_DEVICETREE", "FIT_CONF_DEFAULT_DTB"])
         config = self._config_add_kernel_classes(config)
         self.write_config(config)
-        bb_vars = self._fit_get_bb_vars()
+        loadables = ['loadable1', 'loadable2']
+        bb_vars = self._fit_get_bb_vars(flags={'FIT_LOADABLE_ENTRYPOINT': loadables,
+                                               'FIT_LOADABLE_LOADADDRESS': loadables})
         self._gen_atf_tee_dummy_images(bb_vars)
         self._test_fitimage(bb_vars)