diff options
| author | Johannes Schneider <johannes.schneider@leica-geosystems.com> | 2025-11-05 20:06:35 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-06 18:03:46 +0000 |
| commit | 13b7a749eccccac9d78a546afb856cc4d3004ed9 (patch) | |
| tree | 16d275c010aef753d6c53a74332ae13d6b432d41 | |
| parent | 5de850ec0148e576a4f1e5cdfa813d65a5016b86 (diff) | |
| download | poky-13b7a749eccccac9d78a546afb856cc4d3004ed9.tar.gz | |
bitbake: bitbake-setup: tests: move duplicate code into 'check_setupdir_files'
All places that called into 'check_setupdir_files' did the same
preparation step to load the upstream-config.json and then pass it
into the function.
Since the 'setuppath' is already passed into the function, and the
name and relative location of the upstream-config.json is fixed,
constructing the file path and loading the json could be done in the
function.
De-duplicate code by loading the json inside the function instead.
(Bitbake rev: 16d77c83ae3ce92ddab84d714a93fd3bb7def5e2)
Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | bitbake/lib/bb/tests/setup.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/bitbake/lib/bb/tests/setup.py b/bitbake/lib/bb/tests/setup.py index a17b8ac46a..e18d6fc6ae 100644 --- a/bitbake/lib/bb/tests/setup.py +++ b/bitbake/lib/bb/tests/setup.py | |||
| @@ -177,10 +177,12 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) | |||
| 177 | self.git('add {}'.format(name), cwd=self.testrepopath) | 177 | self.git('add {}'.format(name), cwd=self.testrepopath) |
| 178 | self.git('commit -m "Adding {}"'.format(name), cwd=self.testrepopath) | 178 | self.git('commit -m "Adding {}"'.format(name), cwd=self.testrepopath) |
| 179 | 179 | ||
| 180 | def check_setupdir_files(self, setuppath, test_file_content, json_config): | 180 | def check_setupdir_files(self, setuppath, test_file_content): |
| 181 | with open(os.path.join(setuppath, 'config', "config-upstream.json")) as f: | ||
| 182 | config_upstream = json.load(f) | ||
| 181 | with open(os.path.join(setuppath, 'layers', 'test-repo', 'test-file')) as f: | 183 | with open(os.path.join(setuppath, 'layers', 'test-repo', 'test-file')) as f: |
| 182 | self.assertEqual(f.read(), test_file_content) | 184 | self.assertEqual(f.read(), test_file_content) |
| 183 | bitbake_config = json_config["bitbake-config"] | 185 | bitbake_config = config_upstream["bitbake-config"] |
| 184 | bb_build_path = os.path.join(setuppath, 'build') | 186 | bb_build_path = os.path.join(setuppath, 'build') |
| 185 | bb_conf_path = os.path.join(bb_build_path, 'conf') | 187 | 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'))) | 188 | self.assertTrue(os.path.exists(os.path.join(bb_build_path, 'init-build-env'))) |
| @@ -198,7 +200,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) | |||
| 198 | for l in bitbake_config["bb-layers"]: | 200 | for l in bitbake_config["bb-layers"]: |
| 199 | if l.startswith('{THISDIR}/'): | 201 | if l.startswith('{THISDIR}/'): |
| 200 | thisdir_layer = os.path.join( | 202 | thisdir_layer = os.path.join( |
| 201 | os.path.dirname(json_config["path"]), | 203 | os.path.dirname(config_upstream["path"]), |
| 202 | l.removeprefix("{THISDIR}/"), | 204 | l.removeprefix("{THISDIR}/"), |
| 203 | ) | 205 | ) |
| 204 | self.assertIn(thisdir_layer, bblayers) | 206 | self.assertIn(thisdir_layer, bblayers) |
| @@ -296,9 +298,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) | |||
| 296 | for c in v['buildconfigs']: | 298 | for c in v['buildconfigs']: |
| 297 | out = self.runbbsetup("init --non-interactive {} {}".format(v['cmdline'], c)) | 299 | out = self.runbbsetup("init --non-interactive {} {}".format(v['cmdline'], c)) |
| 298 | setuppath = os.path.join(self.tempdir, 'bitbake-builds', '{}-{}'.format(cf, c)) | 300 | setuppath = os.path.join(self.tempdir, 'bitbake-builds', '{}-{}'.format(cf, c)) |
| 299 | with open(os.path.join(setuppath, 'config', "config-upstream.json")) as f: | 301 | 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') | 302 | os.environ['BBPATH'] = os.path.join(setuppath, 'build') |
| 303 | out = self.runbbsetup("status") | 303 | out = self.runbbsetup("status") |
| 304 | self.assertIn("Configuration in {} has not changed".format(setuppath), out[0]) | 304 | self.assertIn("Configuration in {} has not changed".format(setuppath), out[0]) |
| @@ -327,9 +327,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) | |||
| 327 | if c in ('gadget', 'gizmo'): | 327 | if c in ('gadget', 'gizmo'): |
| 328 | self.assertIn("Existing bitbake configuration directory renamed to {}/build/conf-backup.".format(setuppath), out[0]) | 328 | 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]) | 329 | 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: | 330 | 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 | 331 | ||
| 334 | # make a new branch in the test layer repo, change a file on that branch, | 332 | # 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, | 333 | # make a new commit, update the top level json config to refer to that branch, |
| @@ -353,6 +351,4 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) | |||
| 353 | if c in ('gadget', 'gizmo'): | 351 | if c in ('gadget', 'gizmo'): |
| 354 | self.assertIn("Existing bitbake configuration directory renamed to {}/build/conf-backup.".format(setuppath), out[0]) | 352 | 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]) | 353 | 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: | 354 | 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) | ||
