summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoann Congal <yoann.congal@smile.fr>2024-11-13 00:11:26 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-11-18 22:09:03 +0000
commit131872001abf6c76bd1ed7e31cc68c88ede8ca2c (patch)
tree9d0012a22b964c13d9603e095745dc0bde30e7f3
parent2ded868fc873a55c3d69002ad0b37e3893689c71 (diff)
downloadpoky-131872001abf6c76bd1ed7e31cc68c88ede8ca2c.tar.gz
oeqa/selftest: add a test for bitbake "-e" and "-getvar" difference
This is a non-regression test for [YOCTO #15638] (From OE-Core rev: 22b508da24e0f7e5ad8ce4e090832bd0829963f0) Signed-off-by: Yoann Congal <yoann.congal@smile.fr> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta-selftest/classes/test_anon_func.bbclass3
-rw-r--r--meta/lib/oeqa/selftest/cases/bbtests.py18
2 files changed, 21 insertions, 0 deletions
diff --git a/meta-selftest/classes/test_anon_func.bbclass b/meta-selftest/classes/test_anon_func.bbclass
new file mode 100644
index 0000000000..b1197dc7a4
--- /dev/null
+++ b/meta-selftest/classes/test_anon_func.bbclass
@@ -0,0 +1,3 @@
1python () {
2 d.setVar("TEST_SET_FROM_ANON_FUNC", "expected value")
3}
diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py b/meta/lib/oeqa/selftest/cases/bbtests.py
index 98e9f81661..1cec77b72c 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
375 self.assertGreater(result.status, 0, "Build should have failed if ${ is in the path") 375 self.assertGreater(result.status, 0, "Build should have failed if ${ is in the path")
376 self.assertTrue(re.search("ERROR: Directory name /.* contains unexpanded bitbake variable. This may cause build failures and WORKDIR polution", 376 self.assertTrue(re.search("ERROR: Directory name /.* contains unexpanded bitbake variable. This may cause build failures and WORKDIR polution",
377 result.output), msg = "mkdirhier with unexpanded variable should have failed: %s" % result.output) 377 result.output), msg = "mkdirhier with unexpanded variable should have failed: %s" % result.output)
378
379 def test_bb_env_bb_getvar_equality(self):
380 """ Test if "bitbake -e" output is identical to "bitbake-getvar" output for a variable set from an anonymous function
381 """
382 self.write_config('''INHERIT += "test_anon_func"
383TEST_SET_FROM_ANON_FUNC ?= ""''')
384
385 result_bb_e = runCmd('bitbake -e')
386 bb_e_var_match = re.search('^TEST_SET_FROM_ANON_FUNC="(?P<value>.*)"$', result_bb_e.output, re.MULTILINE)
387 self.assertTrue(bb_e_var_match, msg = "Can't find TEST_SET_FROM_ANON_FUNC value in \"bitbake -e\" output")
388 bb_e_var_value = bb_e_var_match.group("value")
389
390 result_bb_getvar = runCmd('bitbake-getvar TEST_SET_FROM_ANON_FUNC --value')
391 bb_getvar_var_value = result_bb_getvar.output.strip()
392 self.assertEqual(bb_e_var_value, bb_getvar_var_value,
393 msg='''"bitbake -e" output differs from bitbake-getvar output for TEST_SET_FROM_ANON_FUNC (set from anonymous function)
394bitbake -e: "%s"
395bitbake-getvar: "%s"''' % (bb_e_var_value, bb_getvar_var_value))