From: Adrian Freihofer <[email protected]>

Tests can not query variable flags with get_bb_vars. They either need
another bitbake invocation per flag or the metadata needs to copy the
flags into variable values just to make them visible to the tests.

Allow requesting variable flags with the VAR[flag] syntax. They are read
in the same tinfoil session as the variables. Unset or empty flags are
returned as None, consistent with the variables. For example:

    bb_vars = get_bb_vars(['FIT_LOADABLES',
                           'FIT_LOADABLE_FILENAME[loadable1]'],
                          'linux-yocto-fitimage')
    filename = bb_vars['FIT_LOADABLE_FILENAME[loadable1]']

Signed-off-by: Adrian Freihofer <[email protected]>
---
 meta/lib/oeqa/utils/commands.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 1ccc107aed..f4876ca6c9 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -254,10 +254,11 @@ def get_bb_env(target=None, postconfig=None):
         return bitbake("-e", postconfig=postconfig).output
 
 def get_bb_vars(variables=None, target=None, postconfig=None):
-    """Get values of multiple bitbake variables
+    """Get values of multiple bitbake variables or variable flags
 
-    All values are read with a single tinfoil session. If variables is None,
-    all variables are returned. Unset or empty values are returned as None.
+    All values are read with a single tinfoil session. Variable flags can be
+    requested with the VAR[flag] syntax. If variables is None, all variables
+    are returned. Unset or empty values are returned as None.
     """
     import bb.tinfoil
 
@@ -282,8 +283,13 @@ def get_bb_vars(variables=None, target=None, 
postconfig=None):
                     values[var] = str(val)
             return values
 
+        flag_re = re.compile(r'^(?P<var>[^\[]+)\[(?P<flag>[^\]]+)\]$')
         for var in variables:
-            val = d.getVar(var)
+            match = flag_re.match(var)
+            if match:
+                val = d.getVarFlag(match.group('var'), match.group('flag'))
+            else:
+                val = d.getVar(var)
             values[var] = str(val) if val is not None and val != '' else None
     return values
 
-- 
2.56.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#248618): 
https://lists.openembedded.org/g/openembedded-core/message/248618
Mute This Topic: https://lists.openembedded.org/mt/121930727/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to