summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/bblayers.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/bblayers.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/bblayers.py43
1 files changed, 36 insertions, 7 deletions
diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py
index 982287c9a5..6c710b2751 100644
--- a/meta/lib/oeqa/selftest/cases/bblayers.py
+++ b/meta/lib/oeqa/selftest/cases/bblayers.py
@@ -20,6 +20,12 @@ class BitbakeLayers(OESelftestTestCase):
20 bitbake("python3-jsonschema-native") 20 bitbake("python3-jsonschema-native")
21 bitbake("-c addto_recipe_sysroot python3-jsonschema-native") 21 bitbake("-c addto_recipe_sysroot python3-jsonschema-native")
22 22
23 # Fetch variables used in multiple test cases
24 bb_vars = get_bb_vars(['COREBASE', 'BITBAKEPATH'])
25 cls.corebase = bb_vars['COREBASE']
26 cls.bitbakepath = bb_vars['BITBAKEPATH']
27 cls.jsonschema_staging_bindir = get_bb_var('STAGING_BINDIR', 'python3-jsonschema-native')
28
23 def test_bitbakelayers_layerindexshowdepends(self): 29 def test_bitbakelayers_layerindexshowdepends(self):
24 result = runCmd('bitbake-layers layerindex-show-depends meta-poky') 30 result = runCmd('bitbake-layers layerindex-show-depends meta-poky')
25 find_in_contents = re.search("openembedded-core", result.output) 31 find_in_contents = re.search("openembedded-core", result.output)
@@ -58,7 +64,7 @@ class BitbakeLayers(OESelftestTestCase):
58 self.assertTrue(find_in_contents, msg = "Flattening layers did not work. bitbake-layers flatten output: %s" % result.output) 64 self.assertTrue(find_in_contents, msg = "Flattening layers did not work. bitbake-layers flatten output: %s" % result.output)
59 65
60 def test_bitbakelayers_add_remove(self): 66 def test_bitbakelayers_add_remove(self):
61 test_layer = os.path.join(get_bb_var('COREBASE'), 'meta-skeleton') 67 test_layer = os.path.join(self.corebase, 'meta-skeleton')
62 result = runCmd('bitbake-layers show-layers') 68 result = runCmd('bitbake-layers show-layers')
63 self.assertNotIn('meta-skeleton', result.output, "This test cannot run with meta-skeleton in bblayers.conf. bitbake-layers show-layers output: %s" % result.output) 69 self.assertNotIn('meta-skeleton', result.output, "This test cannot run with meta-skeleton in bblayers.conf. bitbake-layers show-layers output: %s" % result.output)
64 result = runCmd('bitbake-layers add-layer %s' % test_layer) 70 result = runCmd('bitbake-layers add-layer %s' % test_layer)
@@ -136,16 +142,39 @@ class BitbakeLayers(OESelftestTestCase):
136 self.assertTrue(os.path.isfile(recipe_file), msg = "Can't find recipe file for %s" % recipe) 142 self.assertTrue(os.path.isfile(recipe_file), msg = "Can't find recipe file for %s" % recipe)
137 return os.path.basename(recipe_file) 143 return os.path.basename(recipe_file)
138 144
145 def validate_json(self, json, jsonschema):
146 python = os.path.join(self.jsonschema_staging_bindir, 'nativepython3')
147 jsonvalidator = os.path.join(self.jsonschema_staging_bindir, 'jsonschema')
148 schemas_dir = os.path.join(self.corebase, "meta/files/")
149 if not os.path.isabs(jsonschema):
150 jsonschema = os.path.join(schemas_dir, jsonschema)
151
152 result = runCmd(
153 "{} {} -i {} --base-uri file://{}/ {}".format(
154 python, jsonvalidator, json, schemas_dir, jsonschema
155 )
156 )
157
139 def validate_layersjson(self, json): 158 def validate_layersjson(self, json):
140 python = os.path.join(get_bb_var('STAGING_BINDIR', 'python3-jsonschema-native'), 'nativepython3') 159 self.validate_json(json, "layers.schema.json")
141 jsonvalidator = os.path.join(get_bb_var('STAGING_BINDIR', 'python3-jsonschema-native'), 'jsonschema')
142 jsonschema = os.path.join(get_bb_var('COREBASE'), 'meta/files/layers.schema.json')
143 result = runCmd("{} {} -i {} {}".format(python, jsonvalidator, json, jsonschema))
144 160
145 def test_validate_examplelayersjson(self): 161 def test_validate_examplelayersjson(self):
146 json = os.path.join(get_bb_var('COREBASE'), "meta/files/layers.example.json") 162 json = os.path.join(self.corebase, "meta/files/layers.example.json")
147 self.validate_layersjson(json) 163 self.validate_layersjson(json)
148 164
165 def test_validate_bitbake_setup_default_registry(self):
166 jsonschema = "bitbake-setup.schema.json"
167
168 default_registry_path = os.path.join(self.bitbakepath, "..", "default-registry", "configurations")
169
170 for root, _, files in os.walk(default_registry_path):
171 for f in files:
172 if not f.endswith(".conf.json"):
173 continue
174 json = os.path.join(root, f)
175 self.logger.debug("Validating %s", json)
176 self.validate_json(json, jsonschema)
177
149 def test_bitbakelayers_setup(self): 178 def test_bitbakelayers_setup(self):
150 result = runCmd('bitbake-layers create-layers-setup {}'.format(self.testlayer_path)) 179 result = runCmd('bitbake-layers create-layers-setup {}'.format(self.testlayer_path))
151 jsonfile = os.path.join(self.testlayer_path, "setup-layers.json") 180 jsonfile = os.path.join(self.testlayer_path, "setup-layers.json")
@@ -173,7 +202,7 @@ class BitbakeLayers(OESelftestTestCase):
173 202
174 # As setup-layers checkout out an old revision of poky, there is no setup-build symlink, 203 # As setup-layers checkout out an old revision of poky, there is no setup-build symlink,
175 # and we need to run oe-setup-build directly from the current poky tree under test 204 # and we need to run oe-setup-build directly from the current poky tree under test
176 oe_setup_build = os.path.join(get_bb_var('COREBASE'), 'scripts/oe-setup-build') 205 oe_setup_build = os.path.join(self.corebase, 'scripts/oe-setup-build')
177 oe_setup_build_l = os.path.join(testcheckoutdir, 'setup-build') 206 oe_setup_build_l = os.path.join(testcheckoutdir, 'setup-build')
178 os.symlink(oe_setup_build,oe_setup_build_l) 207 os.symlink(oe_setup_build,oe_setup_build_l)
179 208