]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
oeqa/bblayers.py: add tests for adding new built-in fragments
authorAntonin Godard <antonin.godard@bootlin.com>
Fri, 26 Sep 2025 09:46:53 +0000 (11:46 +0200)
committerMathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Fri, 26 Sep 2025 15:05:15 +0000 (17:05 +0200)
Add discussed in [1], our best option for customizing built-in fragments
is to pass them from a layer configuration. In short, the reason is that
our statement must be parsed before the addfragments call is parsed.We
also have to use the :append override as using += would override the
original definition of OE_FRAGMENTS_BUILTIN (since it uses a ?=
assignment).

Provide a test case for customizing built-in fragments with
meta-selftest.

[1]: https://lore.kernel.org/yocto-docs/20250925-fragments-v1-0-c9f747361fb2@bootlin.com/T/#m9f7c9f110c084eba17e0f64d8b2ac7a88af3f38e

Cc: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
meta-selftest/conf/layer.conf
meta/lib/oeqa/selftest/cases/bblayers.py

index ecc45ded8c87209276e9a4dd55759e25c5aba8a6..de7d6340eda2427b5c0ce73a351c62c44fa7d1e4 100644 (file)
@@ -12,3 +12,5 @@ BBFILE_PRIORITY_selftest = "5"
 addpylib ${LAYERDIR}/lib oeqa
 
 LAYERSERIES_COMPAT_selftest = "whinlatter"
+
+OE_FRAGMENTS_BUILTIN:append = " selftest-fragment:SELFTEST_BUILTIN_FRAGMENT_VARIABLE"
index 8c05ec5d3d48bb934086d020ce9fdb75613983c9..d82c5aaf3764ff84902a11d8a25e7af1bbbd78a2 100644 (file)
@@ -272,6 +272,35 @@ class BitbakeConfigBuild(OESelftestTestCase):
         self.assertEqual(get_bb_var('SELFTEST_FRAGMENT_VARIABLE'), None)
         self.assertEqual(get_bb_var('SELFTEST_FRAGMENT_ANOTHER_VARIABLE'), None)
 
+    def test_enable_disable_builtin_fragments(self):
+        """
+        Tests that the meta-selftest properly adds a new built-in fragment from
+        its layer.conf configuration file.
+        The test sequence goes as follows:
+        1. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is not set yet.
+        2. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set after setting
+           the fragment.
+        3. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set after setting
+           the fragment with another value that overrides the first one.
+        4. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set to the previous
+           value after removing the second assignment (from step 3).
+        5. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is not set after
+           removing the original assignment.
+        """
+        self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), None)
+
+        runCmd('bitbake-config-build enable-fragment selftest-fragment/somevalue')
+        self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'somevalue')
+
+        runCmd('bitbake-config-build enable-fragment selftest-fragment/someothervalue')
+        self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'someothervalue')
+
+        runCmd('bitbake-config-build disable-fragment selftest-fragment/someothervalue')
+        self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'somevalue')
+
+        runCmd('bitbake-config-build disable-fragment selftest-fragment/somevalue')
+        self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), None)
+
     def test_show_fragment(self):
         """
         Test that bitbake-config-build show-fragment returns the expected