oeqa/bblayers.py: add a test case for bitbake-config-build show-fragment

Add a test case for 'bitbake-config-build show-fragment' and use
'bitbake-config-build list-fragments' to get the path to the fragment.

(From OE-Core rev: 09468f352994a05b59911b2fe7412d3540cdb3cb)

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Antonin Godard
2025-09-05 14:23:58 +02:00
committed by Richard Purdie
parent 3b1a9693b6
commit 20a1e4e401

View File

@@ -271,3 +271,29 @@ class BitbakeConfigBuild(OESelftestTestCase):
runCmd('bitbake-config-build disable-fragment selftest/more-fragments-here/test-another-fragment')
self.assertEqual(get_bb_var('SELFTEST_FRAGMENT_VARIABLE'), None)
self.assertEqual(get_bb_var('SELFTEST_FRAGMENT_ANOTHER_VARIABLE'), None)
def test_show_fragment(self):
"""
Test that bitbake-config-build show-fragment returns the expected
output. Use bitbake-config-build list-fragments --verbose to get the
path to the fragment.
"""
result = runCmd('bitbake-config-build --quiet list-fragments --verbose')
test_fragment_re = re.compile(r'^Path: .*conf/fragments/test-fragment.conf$')
fragment_path, fragment_content = '', ''
for line in result.output.splitlines():
m = re.match(test_fragment_re, line)
if m:
fragment_path = ' '.join(line.split()[1:])
break
if not fragment_path:
raise Exception("Couldn't find the fragment")
with open(fragment_path, 'r') as f:
fragment_content = f'{fragment_path}:\n\n{f.read()}'.strip()
result = runCmd('bitbake-config-build --quiet show-fragment selftest/test-fragment')
self.assertEqual(result.output.strip(), fragment_content)