From: Antonin Godard Date: Fri, 5 Sep 2025 12:23:58 +0000 (+0200) Subject: oeqa/bblayers.py: add a test case for bitbake-config-build show-fragment X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=09468f352994a05b59911b2fe7412d3540cdb3cb;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git 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. Signed-off-by: Antonin Godard Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py index 68b03777201..8c05ec5d3d4 100644 --- a/meta/lib/oeqa/selftest/cases/bblayers.py +++ b/meta/lib/oeqa/selftest/cases/bblayers.py @@ -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)