summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/setup.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/tests/setup.py')
-rw-r--r--bitbake/lib/bb/tests/setup.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/bitbake/lib/bb/tests/setup.py b/bitbake/lib/bb/tests/setup.py
index a17b8ac46a..ba2a90009d 100644
--- a/bitbake/lib/bb/tests/setup.py
+++ b/bitbake/lib/bb/tests/setup.py
@@ -148,9 +148,10 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
148 "oe-fragments": ["test-fragment-2"] 148 "oe-fragments": ["test-fragment-2"]
149 }, 149 },
150 { 150 {
151 "name": "gizmo-notemplate-with-thisdir", 151 "name": "gizmo-notemplate-with-relative-layers",
152 "description": "Gizmo notemplate configuration using THISDIR", 152 "description": "Gizmo notemplate configuration using relative layers",
153 "bb-layers": ["layerC","layerD/meta-layer","{THISDIR}/layerE/meta-layer"], 153 "bb-layers": ["layerC","layerD/meta-layer"],
154 "bb-layers-relative": ["layerE/meta-layer"],
154 "oe-fragments": ["test-fragment-2"] 155 "oe-fragments": ["test-fragment-2"]
155 } 156 }
156 ] 157 ]
@@ -177,14 +178,22 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
177 self.git('add {}'.format(name), cwd=self.testrepopath) 178 self.git('add {}'.format(name), cwd=self.testrepopath)
178 self.git('commit -m "Adding {}"'.format(name), cwd=self.testrepopath) 179 self.git('commit -m "Adding {}"'.format(name), cwd=self.testrepopath)
179 180
180 def check_setupdir_files(self, setuppath, test_file_content, json_config): 181 def check_setupdir_files(self, setuppath, test_file_content):
182 with open(os.path.join(setuppath, 'config', "config-upstream.json")) as f:
183 config_upstream = json.load(f)
181 with open(os.path.join(setuppath, 'layers', 'test-repo', 'test-file')) as f: 184 with open(os.path.join(setuppath, 'layers', 'test-repo', 'test-file')) as f:
182 self.assertEqual(f.read(), test_file_content) 185 self.assertEqual(f.read(), test_file_content)
183 bitbake_config = json_config["bitbake-config"] 186 bitbake_config = config_upstream["bitbake-config"]
184 bb_build_path = os.path.join(setuppath, 'build') 187 bb_build_path = os.path.join(setuppath, 'build')
185 bb_conf_path = os.path.join(bb_build_path, 'conf') 188 bb_conf_path = os.path.join(bb_build_path, 'conf')
186 self.assertTrue(os.path.exists(os.path.join(bb_build_path, 'init-build-env'))) 189 self.assertTrue(os.path.exists(os.path.join(bb_build_path, 'init-build-env')))
187 190
191 with open(os.path.join(setuppath, 'config', "sources-fixed-revisions.json")) as f:
192 sources_fixed_revisions = json.load(f)
193 self.assertTrue('test-repo' in sources_fixed_revisions['sources'].keys())
194 revision = self.git('rev-parse HEAD', cwd=self.testrepopath).strip()
195 self.assertEqual(revision, sources_fixed_revisions['sources']['test-repo']['git-remote']['rev'])
196
188 if "oe-template" in bitbake_config: 197 if "oe-template" in bitbake_config:
189 with open(os.path.join(bb_conf_path, 'conf-summary.txt')) as f: 198 with open(os.path.join(bb_conf_path, 'conf-summary.txt')) as f:
190 self.assertEqual(f.read(), bitbake_config["oe-template"]) 199 self.assertEqual(f.read(), bitbake_config["oe-template"])
@@ -196,14 +205,13 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
196 with open(os.path.join(bb_conf_path, 'bblayers.conf')) as f: 205 with open(os.path.join(bb_conf_path, 'bblayers.conf')) as f:
197 bblayers = f.read() 206 bblayers = f.read()
198 for l in bitbake_config["bb-layers"]: 207 for l in bitbake_config["bb-layers"]:
199 if l.startswith('{THISDIR}/'): 208 self.assertIn(os.path.join(setuppath, "layers", l), bblayers)
200 thisdir_layer = os.path.join( 209 for l in bitbake_config.get("bb-layers-relative") or []:
201 os.path.dirname(json_config["path"]), 210 relative_layer = os.path.join(
202 l.removeprefix("{THISDIR}/"), 211 os.path.dirname(config_upstream["path"]),
212 l,
203 ) 213 )
204 self.assertIn(thisdir_layer, bblayers) 214 self.assertIn(relative_layer, bblayers)
205 else:
206 self.assertIn(os.path.join(setuppath, "layers", l), bblayers)
207 215
208 if 'oe-fragment' in bitbake_config.keys(): 216 if 'oe-fragment' in bitbake_config.keys():
209 for f in bitbake_config["oe-fragments"]: 217 for f in bitbake_config["oe-fragments"]:
@@ -290,15 +298,13 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
290 'gizmo-env-passthrough', 298 'gizmo-env-passthrough',
291 'gizmo-no-fragment', 299 'gizmo-no-fragment',
292 'gadget-notemplate','gizmo-notemplate', 300 'gadget-notemplate','gizmo-notemplate',
293 'gizmo-notemplate-with-thisdir')} 301 'gizmo-notemplate-with-relative-layers')}
294 } 302 }
295 for cf, v in test_configurations.items(): 303 for cf, v in test_configurations.items():
296 for c in v['buildconfigs']: 304 for c in v['buildconfigs']:
297 out = self.runbbsetup("init --non-interactive {} {}".format(v['cmdline'], c)) 305 out = self.runbbsetup("init --non-interactive {} {}".format(v['cmdline'], c))
298 setuppath = os.path.join(self.tempdir, 'bitbake-builds', '{}-{}'.format(cf, c)) 306 setuppath = os.path.join(self.tempdir, 'bitbake-builds', '{}-{}'.format(cf, c))
299 with open(os.path.join(setuppath, 'config', "config-upstream.json")) as f: 307 self.check_setupdir_files(setuppath, test_file_content)
300 config_upstream = json.load(f)
301 self.check_setupdir_files(setuppath, test_file_content, config_upstream)
302 os.environ['BBPATH'] = os.path.join(setuppath, 'build') 308 os.environ['BBPATH'] = os.path.join(setuppath, 'build')
303 out = self.runbbsetup("status") 309 out = self.runbbsetup("status")
304 self.assertIn("Configuration in {} has not changed".format(setuppath), out[0]) 310 self.assertIn("Configuration in {} has not changed".format(setuppath), out[0])
@@ -327,9 +333,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
327 if c in ('gadget', 'gizmo'): 333 if c in ('gadget', 'gizmo'):
328 self.assertIn("Existing bitbake configuration directory renamed to {}/build/conf-backup.".format(setuppath), out[0]) 334 self.assertIn("Existing bitbake configuration directory renamed to {}/build/conf-backup.".format(setuppath), out[0])
329 self.assertIn('-{}+{}'.format(prev_test_file_content, test_file_content), out[0]) 335 self.assertIn('-{}+{}'.format(prev_test_file_content, test_file_content), out[0])
330 with open(os.path.join(setuppath, 'config', "config-upstream.json")) as f: 336 self.check_setupdir_files(setuppath, test_file_content)
331 config_upstream = json.load(f)
332 self.check_setupdir_files(setuppath, test_file_content, config_upstream)
333 337
334 # make a new branch in the test layer repo, change a file on that branch, 338 # make a new branch in the test layer repo, change a file on that branch,
335 # make a new commit, update the top level json config to refer to that branch, 339 # make a new commit, update the top level json config to refer to that branch,
@@ -353,6 +357,4 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
353 if c in ('gadget', 'gizmo'): 357 if c in ('gadget', 'gizmo'):
354 self.assertIn("Existing bitbake configuration directory renamed to {}/build/conf-backup.".format(setuppath), out[0]) 358 self.assertIn("Existing bitbake configuration directory renamed to {}/build/conf-backup.".format(setuppath), out[0])
355 self.assertIn('-{}+{}'.format(prev_test_file_content, test_file_content), out[0]) 359 self.assertIn('-{}+{}'.format(prev_test_file_content, test_file_content), out[0])
356 with open(os.path.join(setuppath, 'config', "config-upstream.json")) as f: 360 self.check_setupdir_files(setuppath, test_file_content)
357 config_upstream = json.load(f)
358 self.check_setupdir_files(setuppath, test_file_content, config_upstream)