]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
oeqa/bblayers.py: add a test case for bitbake-config-build show-fragment
authorAntonin Godard <antonin.godard@bootlin.com>
Fri, 5 Sep 2025 12:23:58 +0000 (14:23 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 8 Sep 2025 17:02:37 +0000 (18:02 +0100)
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 <antonin.godard@bootlin.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/selftest/cases/bblayers.py

index 68b03777201fbae77412f329a102700418613cc6..8c05ec5d3d48bb934086d020ce9fdb75613983c9 100644 (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)