From: Yoann Congal Date: Tue, 12 Nov 2024 23:11:26 +0000 (+0100) Subject: oeqa/selftest: add a test for bitbake "-e" and "-getvar" difference X-Git-Tag: yocto-5.2~1290 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=22b508da24e0f7e5ad8ce4e090832bd0829963f0;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git oeqa/selftest: add a test for bitbake "-e" and "-getvar" difference This is a non-regression test for [YOCTO #15638] Signed-off-by: Yoann Congal Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- diff --git a/meta-selftest/classes/test_anon_func.bbclass b/meta-selftest/classes/test_anon_func.bbclass new file mode 100644 index 00000000000..b1197dc7a4c --- /dev/null +++ b/meta-selftest/classes/test_anon_func.bbclass @@ -0,0 +1,3 @@ +python () { + d.setVar("TEST_SET_FROM_ANON_FUNC", "expected value") +} diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py b/meta/lib/oeqa/selftest/cases/bbtests.py index 98e9f816610..1cec77b72c2 100644 --- a/meta/lib/oeqa/selftest/cases/bbtests.py +++ b/meta/lib/oeqa/selftest/cases/bbtests.py @@ -375,3 +375,21 @@ require conf/distro/include/no-gplv3.inc self.assertGreater(result.status, 0, "Build should have failed if ${ is in the path") self.assertTrue(re.search("ERROR: Directory name /.* contains unexpanded bitbake variable. This may cause build failures and WORKDIR polution", result.output), msg = "mkdirhier with unexpanded variable should have failed: %s" % result.output) + + def test_bb_env_bb_getvar_equality(self): + """ Test if "bitbake -e" output is identical to "bitbake-getvar" output for a variable set from an anonymous function + """ + self.write_config('''INHERIT += "test_anon_func" +TEST_SET_FROM_ANON_FUNC ?= ""''') + + result_bb_e = runCmd('bitbake -e') + bb_e_var_match = re.search('^TEST_SET_FROM_ANON_FUNC="(?P.*)"$', result_bb_e.output, re.MULTILINE) + self.assertTrue(bb_e_var_match, msg = "Can't find TEST_SET_FROM_ANON_FUNC value in \"bitbake -e\" output") + bb_e_var_value = bb_e_var_match.group("value") + + result_bb_getvar = runCmd('bitbake-getvar TEST_SET_FROM_ANON_FUNC --value') + bb_getvar_var_value = result_bb_getvar.output.strip() + self.assertEqual(bb_e_var_value, bb_getvar_var_value, + msg='''"bitbake -e" output differs from bitbake-getvar output for TEST_SET_FROM_ANON_FUNC (set from anonymous function) +bitbake -e: "%s" +bitbake-getvar: "%s"''' % (bb_e_var_value, bb_getvar_var_value))