diff mbox series

[12/16] oeqa: Update test layers for the new layer.conf format

Message ID 20261130152704.3471590-12-richard.purdie@linuxfoundation.org
State New
Headers show
Series [01/16] bitbake/base: Implement RECIPE_HOSTTOOLS | expand

Commit Message

Richard Purdie Nov. 30, 2026, 3:27 p.m. UTC
Update the test layer creation code to use the new layer format.

Use LAYERDIR_<layername> as the way to check if a layer is available
to replace the collections check which is no longer available.

AI-Generated: Uses Claude Opus 5.5
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/lib/oeqa/selftest/cases/buildoptions.py |  8 +++----
 meta/lib/oeqa/selftest/cases/devtool.py      | 24 +++++---------------
 meta/lib/oeqa/selftest/cases/layerappend.py  | 18 +++++++--------
 meta/lib/oeqa/selftest/cases/recipetool.py   | 11 ++++-----
 meta/lib/oeqa/utils/commands.py              | 15 +++++-------
 5 files changed, 28 insertions(+), 48 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/buildoptions.py b/meta/lib/oeqa/selftest/cases/buildoptions.py
index 92d8595591b..264fe09b959 100644
--- a/meta/lib/oeqa/selftest/cases/buildoptions.py
+++ b/meta/lib/oeqa/selftest/cases/buildoptions.py
@@ -117,11 +117,9 @@  class SanityOptionsTest(OESelftestTestCase):
         os.makedirs(dummy_layer_conf_dir)
         dummy_layer_conf_path = os.path.join(dummy_layer_conf_dir, 'layer.conf')
 
-        dummy_layer_content = 'BBPATH .= ":${LAYERDIR}"\n' \
-                              'BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"\n' \
-                              'BBFILE_COLLECTIONS += "%s"\n' \
-                              'BBFILE_PATTERN_%s = "^${LAYERDIR}/"\n' \
-                              'BBFILE_PRIORITY_%s = "6"\n' % (dummy_layer_name, dummy_layer_name, dummy_layer_name)
+        dummy_layer_content = 'LAYERNAME = "%s"\n' \
+                              'LAYERDEPENDS = "oe-core"\n' \
+                              'LAYERSERIES_COMPAT = "%s"\n' % (dummy_layer_name, get_bb_var('LAYERSERIES_CORENAMES'))
 
         ftools.write_file(dummy_layer_conf_path, dummy_layer_content)
 
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index 89ca79e6358..7d815534996 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -218,8 +218,8 @@  class DevtoolTestCase(OESelftestTestCase):
             self.fail('bbappend for recipe %s does not seem to be created in test layer' % testrecipe)
         return bbappendfile
 
-    def _create_temp_layer(self, templayerdir, addlayer, templayername, priority=999, recipepathspec='recipes-*/*'):
-        create_temp_layer(templayerdir, templayername, priority, recipepathspec)
+    def _create_temp_layer(self, templayerdir, addlayer, templayername):
+        create_temp_layer(templayerdir, templayername)
         if addlayer:
             self.add_command_to_tearDown('bitbake-layers remove-layer %s || true' % templayerdir)
             result = runCmd('bitbake-layers add-layer %s' % templayerdir, cwd=self.builddir)
@@ -687,8 +687,7 @@  class DevtoolAddTests(DevtoolBase):
         self._test_recipe_contents(recipefile, checkvars, [])
 
     def test_devtool_add_npm(self):
-        collections = get_bb_var('BBFILE_COLLECTIONS').split()
-        if "openembedded-layer" not in collections:
+        if not get_bb_var('LAYERDIR_meta-oe'):
             self.skipTest("Test needs meta-oe for nodejs")
 
         pn = 'savoirfairelinux-node-server-example'
@@ -1553,10 +1552,9 @@  class DevtoolUpdateTests(DevtoolBase):
     def test_devtool_update_recipe_append_git(self):
         # Check preconditions
         testrecipe = 'mtd-utils-selftest'
-        bb_vars = get_bb_vars(['FILE', 'SRC_URI', 'LAYERSERIES_CORENAMES'], testrecipe)
+        bb_vars = get_bb_vars(['FILE', 'SRC_URI'], testrecipe)
         recipefile = bb_vars['FILE']
         src_uri = bb_vars['SRC_URI']
-        corenames = bb_vars['LAYERSERIES_CORENAMES']
         self.assertIn('git://', src_uri, 'This test expects the %s recipe to be a git recipe' % testrecipe)
         for entry in src_uri.split():
             if entry.startswith('git://'):
@@ -1578,18 +1576,8 @@  class DevtoolUpdateTests(DevtoolBase):
         result = runCmd('echo "# Additional line" >> Makefile.am', cwd=tempsrcdir)
         result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir)
         self._add_recipe_cleanup(recipefile)
-        # Create a temporary layer
-        os.makedirs(os.path.join(templayerdir, 'conf'))
-        with open(os.path.join(templayerdir, 'conf', 'layer.conf'), 'w') as f:
-            f.write('BBPATH .= ":${LAYERDIR}"\n')
-            f.write('BBFILES += "${LAYERDIR}/recipes-*/*/*.bbappend"\n')
-            f.write('BBFILE_COLLECTIONS += "oeselftesttemplayer"\n')
-            f.write('BBFILE_PATTERN_oeselftesttemplayer = "^${LAYERDIR}/"\n')
-            f.write('BBFILE_PRIORITY_oeselftesttemplayer = "999"\n')
-            f.write('BBFILE_PATTERN_IGNORE_EMPTY_oeselftesttemplayer = "1"\n')
-            f.write('LAYERSERIES_COMPAT_oeselftesttemplayer = "%s"\n' % corenames)
-        self.add_command_to_tearDown('bitbake-layers remove-layer %s || true' % templayerdir)
-        result = runCmd('bitbake-layers add-layer %s' % templayerdir, cwd=self.builddir)
+        # Create a temporary layer and add it to bblayers.conf
+        self._create_temp_layer(templayerdir, True, 'oeselftesttemplayer')
         # Create the bbappend
         result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir))
         self.assertNotIn('WARNING:', result.output)
diff --git a/meta/lib/oeqa/selftest/cases/layerappend.py b/meta/lib/oeqa/selftest/cases/layerappend.py
index afd65b485f1..b915cd98460 100644
--- a/meta/lib/oeqa/selftest/cases/layerappend.py
+++ b/meta/lib/oeqa/selftest/cases/layerappend.py
@@ -11,16 +11,12 @@  from oeqa.utils.commands import bitbake, get_bb_var
 import oeqa.utils.ftools as ftools
 
 class LayerAppendTests(OESelftestTestCase):
+    # Each layer depends on the previous one so that the bbappends are
+    # applied in a defined order (layer 2's after layer 1's)
     layerconf = """
-# We have a conf and classes directory, append to BBPATH
-BBPATH .= ":${LAYERDIR}"
-
-# We have a recipes directory, add to BBFILES
-BBFILES += "${LAYERDIR}/recipes*/*.bb ${LAYERDIR}/recipes*/*.bbappend"
-
-BBFILE_COLLECTIONS += "meta-layerINT"
-BBFILE_PATTERN_meta-layerINT := "^${LAYERDIR}/"
-BBFILE_PRIORITY_meta-layerINT = "6"
+LAYERNAME = "meta-layertestINT"
+LAYERDEPENDS = "DEPENDS"
+LAYERSERIES_COMPAT = "CORENAMES"
 """
     recipe = """
 LICENSE = "MIT"
@@ -57,6 +53,8 @@  SRC_URI:append = " file://appendtest.txt"
 
     def test_layer_appends(self):
         corebase = get_bb_var("COREBASE")
+        corenames = get_bb_var("LAYERSERIES_CORENAMES")
+        depends = {"0": "oe-core", "1": "meta-layertest0", "2": "meta-layertest1"}
 
         for l in ["0", "1", "2"]:
             layer = os.path.join(corebase, "meta-layertest" + l)
@@ -64,7 +62,7 @@  SRC_URI:append = " file://appendtest.txt"
             os.mkdir(layer)
             os.mkdir(layer + "/conf")
             with open(layer + "/conf/layer.conf", "w") as f:
-                f.write(self.layerconf.replace("INT", l))
+                f.write(self.layerconf.replace("INT", l).replace("DEPENDS", depends[l]).replace("CORENAMES", corenames))
             os.mkdir(layer + "/recipes-test")
             if l == "0":
                 with open(layer + "/recipes-test/layerappendtest.bb", "w") as f:
diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py
index 181d95804fc..fdcc468a837 100644
--- a/meta/lib/oeqa/selftest/cases/recipetool.py
+++ b/meta/lib/oeqa/selftest/cases/recipetool.py
@@ -318,9 +318,9 @@  class RecipetoolAppendTests(RecipetoolBase):
         _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-postinst', self.testfile, '-r selftest-recipetool-appendfile', expectedlines, ['testfile'])
 
     def test_recipetool_appendfile_extlayer(self):
-        # Try creating a bbappend in a layer that's not in bblayers.conf and has a different structure
+        # Try creating a bbappend in a layer that's not in bblayers.conf
         exttemplayerdir = os.path.join(self.tempdir, 'extlayer')
-        self._create_temp_layer(exttemplayerdir, False, 'oeselftestextlayer', recipepathspec='metadata/recipes/recipes-*/*')
+        self._create_temp_layer(exttemplayerdir, False, 'oeselftestextlayer')
         result = runCmd('recipetool appendfile %s /usr/share/selftest-replaceme-orig %s' % (exttemplayerdir, self.testfile))
         self.assertNotIn('Traceback', result.output)
         createdfiles = []
@@ -328,8 +328,8 @@  class RecipetoolAppendTests(RecipetoolBase):
             for f in files:
                 createdfiles.append(os.path.relpath(os.path.join(root, f), exttemplayerdir))
         createdfiles.remove('conf/layer.conf')
-        expectedfiles = ['metadata/recipes/recipes-test/selftest-recipetool-appendfile/selftest-recipetool-appendfile.bbappend',
-                         'metadata/recipes/recipes-test/selftest-recipetool-appendfile/selftest-recipetool-appendfile/selftest-replaceme-orig']
+        expectedfiles = ['recipes-test/recipetool/selftest-recipetool-appendfile.bbappend',
+                         'recipes-test/recipetool/selftest-recipetool-appendfile/selftest-replaceme-orig']
         self.assertEqual(sorted(createdfiles), sorted(expectedfiles))
 
     def test_recipetool_appendfile_wildcard(self):
@@ -434,8 +434,7 @@  class RecipetoolCreateTests(RecipetoolBase):
         self._test_recipe_contents(recipefile, checkvars, inherits)
 
     def test_recipetool_create_npm(self):
-        collections = get_bb_var('BBFILE_COLLECTIONS').split()
-        if "openembedded-layer" not in collections:
+        if not get_bb_var('LAYERDIR_meta-oe'):
             self.skipTest("Test needs meta-oe for nodejs")
 
         temprecipe = os.path.join(self.tempdir, 'recipe')
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index cf2b7aa9418..35459358535 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -337,18 +337,15 @@  def get_test_layer(bblayers=None):
             break
     return testlayer
 
-def create_temp_layer(templayerdir, templayername, priority=999, recipepathspec='recipes-*/*'):
+def create_temp_layer(templayerdir, templayername, layerdepends='oe-core'):
+    # Bitbake constructs BBPATH and BBFILES itself, recipes and bbappends
+    # are found in any recipes* directories within the layer
     os.makedirs(os.path.join(templayerdir, 'conf'))
     corenames = get_bb_var('LAYERSERIES_CORENAMES')
     with open(os.path.join(templayerdir, 'conf', 'layer.conf'), 'w') as f:
-        f.write('BBPATH .= ":${LAYERDIR}"\n')
-        f.write('BBFILES += "${LAYERDIR}/%s/*.bb \\' % recipepathspec)
-        f.write('            ${LAYERDIR}/%s/*.bbappend"\n' % recipepathspec)
-        f.write('BBFILE_COLLECTIONS += "%s"\n' % templayername)
-        f.write('BBFILE_PATTERN_%s = "^${LAYERDIR}/"\n' % templayername)
-        f.write('BBFILE_PRIORITY_%s = "%d"\n' % (templayername, priority))
-        f.write('BBFILE_PATTERN_IGNORE_EMPTY_%s = "1"\n' % templayername)
-        f.write('LAYERSERIES_COMPAT_%s = "%s"\n' % (templayername, corenames))
+        f.write('LAYERNAME = "%s"\n' % templayername)
+        f.write('LAYERDEPENDS = "%s"\n' % layerdepends)
+        f.write('LAYERSERIES_COMPAT = "%s"\n' % corenames)
 
 @contextlib.contextmanager
 def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, qemuparams=None, overrides={}, boot_patterns = {}, discard_writes=True):