diff mbox series

[3/3] selftest/bblayers: Add a test to validate bitbake-setup registry schema

Message ID 20251023072513.280477-3-yoann.congal@smile.fr
State New
Headers show
Series [1/3] meta/files: Add a jsonschema for bitbake-setup configuration files | expand

Commit Message

Yoann Congal Oct. 23, 2025, 7:25 a.m. UTC
From: Yoann Congal <yoann.congal@smile.fr>

This test validates bitbake/default-registry/configurations/*.conf.json
against bitbake-setup.schema.json:
  INFO - test_validate_bitbake_setup_default_registry (bblayers.BitbakeLayers.test_validate_bitbake_setup_default_registry)
  DEBUG - Validating [...]/poky/bitbake/bin/../default-registry/configurations/oe-nodistro.conf.json
  DEBUG - Validating [...]/poky/bitbake/bin/../default-registry/configurations/poky-master.conf.json
  INFO -  ... ok
  INFO - test_validate_examplelayersjson (bblayers.BitbakeLayers.test_validate_examplelayersjson)
  INFO -  ... ok
  INFO - ----------------------------------------------------------------------
  INFO - Ran 2 tests in 121.119s
  INFO - OK
  INFO - RESULTS:
  INFO - RESULTS - bblayers.BitbakeLayers.test_validate_bitbake_setup_default_registry: PASSED (15.86s)
  INFO - RESULTS - bblayers.BitbakeLayers.test_validate_examplelayersjson: PASSED (7.12s)

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
RFC: This structure takes ~7s per schema validation. I guess because of
the multiple bb_get_var in each loop. I'll glady take suggestions on how
to improve this.
---
 meta/lib/oeqa/selftest/cases/bblayers.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Alexander Kanavin Oct. 23, 2025, 11:10 a.m. UTC | #1
On Thu, 23 Oct 2025 at 09:25, Yoann Congal via lists.openembedded.org
<yoann.congal=smile.fr@lists.openembedded.org> wrote:
> RFC: This structure takes ~7s per schema validation. I guess because of
> the multiple bb_get_var in each loop. I'll glady take suggestions on how
> to improve this.

I guess you need to refactor the code to obtain them only once on the
top level (or even in the test initialization where
python3-jsonschema-native is built), and set as object properties:
self.something.

Otherwise lgtm, now that we have a schema and tests, we can start
messing around with it :)

Alex
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py
index 43a158fcf2..8397506f04 100644
--- a/meta/lib/oeqa/selftest/cases/bblayers.py
+++ b/meta/lib/oeqa/selftest/cases/bblayers.py
@@ -155,6 +155,20 @@  class BitbakeLayers(OESelftestTestCase):
         jsonschema = "layers.schema.json"
         self.validate_json(json, jsonschema)
 
+    def test_validate_bitbake_setup_default_registry(self):
+        jsonschema = "bitbake-setup.schema.json"
+
+        bitbake_path = get_bb_var("BITBAKEPATH")
+        default_registry_path = os.path.join(bitbake_path, "..", "default-registry", "configurations")
+
+        for root, _, files in os.walk(default_registry_path):
+            for f in files:
+                if not f.endswith(".conf.json"):
+                    continue
+                json = os.path.join(root, f)
+                self.logger.debug("Validating %s", json)
+                self.validate_json(json, jsonschema)
+
     def test_bitbakelayers_setup(self):
         result = runCmd('bitbake-layers create-layers-setup {}'.format(self.testlayer_path))
         jsonfile = os.path.join(self.testlayer_path, "setup-layers.json")