Message ID | 20250617171332.3162295-1-ross.burton@arm.com |
---|---|
State | New |
Headers | show |
Series | [1/4] oeqa/utils/command: fast-path get_bb_var() | expand |
On Tue Jun 17, 2025 at 7:13 PM CEST, Ross Burton via lists.openembedded.org wrote: > get_bb_var() currently end up calling 'bitbake -e' and parsing the whole > output. However if postconfig isn't set then we can speed this up by > just calling bitbake-getvar. > > Signed-off-by: Ross Burton <ross.burton@arm.com> > --- Hi Ross, Turns out this is breaking some selftest: 2025-06-17 17:45:55,857 - oe-selftest - INFO - bblayers.BitbakeConfigBuild.test_enable_disable_fragments (subunit.RemotedTestCase) 2025-06-17 17:45:55,859 - oe-selftest - INFO - ... ERROR ... 2025-06-17 17:45:55,859 - oe-selftest - INFO - 4: 1/42 1/633 (1.46s) (0 failed) (bblayers.BitbakeConfigBuild.test_enable_disable_fragments) 2025-06-17 17:45:55,859 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last): File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/meta/lib/oeqa/selftest/cases/bblayers.py", line 246, in test_enable_disable_fragments self.assertEqual(get_bb_var('SELFTEST_FRAGMENT_VARIABLE'), None) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/meta/lib/oeqa/utils/commands.py", line 295, in get_bb_var return subprocess.run(cmd, check=True, text=True, stdout=subprocess.PIPE).stdout.strip() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/subprocess.py", line 571, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['bitbake-getvar', '--value', 'SELFTEST_FRAGMENT_VARIABLE']' returned non-zero exit status 1. https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/1943 https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/1790 https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/1728
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py index 2a47f90e327..bfe69474149 100644 --- a/meta/lib/oeqa/utils/commands.py +++ b/meta/lib/oeqa/utils/commands.py @@ -285,7 +285,14 @@ def get_bb_vars(variables=None, target=None, postconfig=None): return values def get_bb_var(var, target=None, postconfig=None): - return get_bb_vars([var], target, postconfig)[var] + if postconfig: + return bitbake("-e %s" % target or "", postconfig=postconfig).output + else: + # Fast-path for the non-postconfig case + cmd = ["bitbake-getvar", "--value", var] + if target: + cmd.extend(["--recipe", target]) + return subprocess.run(cmd, check=True, text=True, stdout=subprocess.PIPE).stdout.strip() def get_test_layer(bblayers=None): if bblayers is None:
get_bb_var() currently end up calling 'bitbake -e' and parsing the whole output. However if postconfig isn't set then we can speed this up by just calling bitbake-getvar. Signed-off-by: Ross Burton <ross.burton@arm.com> --- meta/lib/oeqa/utils/commands.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)