diff options
Diffstat (limited to 'bitbake/lib/bb/tests/setup.py')
-rw-r--r-- | bitbake/lib/bb/tests/setup.py | 77 |
1 files changed, 63 insertions, 14 deletions
diff --git a/bitbake/lib/bb/tests/setup.py b/bitbake/lib/bb/tests/setup.py index 747a9b733f..b238926b29 100644 --- a/bitbake/lib/bb/tests/setup.py +++ b/bitbake/lib/bb/tests/setup.py | |||
@@ -120,6 +120,22 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) | |||
120 | "oe-fragments": ["test-fragment-2"] | 120 | "oe-fragments": ["test-fragment-2"] |
121 | }, | 121 | }, |
122 | { | 122 | { |
123 | "name": "gizmo-env-passthrough", | ||
124 | "description": "Gizmo build configuration with environment-passthrough", | ||
125 | "bb-layers": ["layerC","layerD/meta-layer"], | ||
126 | "oe-fragments": ["test-fragment-1"], | ||
127 | "bb-env-passthrough-additions": [ | ||
128 | "BUILD_ID", | ||
129 | "BUILD_DATE", | ||
130 | "BUILD_SERVER" | ||
131 | ] | ||
132 | }, | ||
133 | { | ||
134 | "name": "gizmo-no-fragment", | ||
135 | "description": "Gizmo no-fragment template-only build configuration", | ||
136 | "oe-template": "test-configuration-gizmo" | ||
137 | }, | ||
138 | { | ||
123 | "name": "gadget-notemplate", | 139 | "name": "gadget-notemplate", |
124 | "description": "Gadget notemplate build configuration", | 140 | "description": "Gadget notemplate build configuration", |
125 | "bb-layers": ["layerA","layerB/meta-layer"], | 141 | "bb-layers": ["layerA","layerB/meta-layer"], |
@@ -189,8 +205,18 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) | |||
189 | else: | 205 | else: |
190 | self.assertIn(os.path.join(buildpath, "layers", l), bblayers) | 206 | self.assertIn(os.path.join(buildpath, "layers", l), bblayers) |
191 | 207 | ||
192 | for f in bitbake_config["oe-fragments"]: | 208 | if 'oe-fragment' in bitbake_config.keys(): |
193 | self.assertTrue(os.path.exists(os.path.join(bb_conf_path, f))) | 209 | for f in bitbake_config["oe-fragments"]: |
210 | self.assertTrue(os.path.exists(os.path.join(bb_conf_path, f))) | ||
211 | |||
212 | if 'bb-environment-passthrough' in bitbake_config.keys(): | ||
213 | with open(os.path.join(bb_build_path, 'init-build-env'), 'r') as f: | ||
214 | init_build_env = f.read() | ||
215 | self.assertTrue('BB_ENV_PASSTHROUGH_ADDITIONS' in init_build_env) | ||
216 | self.assertTrue('BUILD_ID' in init_build_env) | ||
217 | self.assertTrue('BUILD_DATE' in init_build_env) | ||
218 | self.assertTrue('BUILD_SERVER' in init_build_env) | ||
219 | # a more throrough test could be to initialize a bitbake build-env, export FOO to the shell environment, set the env-passthrough on it and finally check against 'bitbake-getvar FOO' | ||
194 | 220 | ||
195 | 221 | ||
196 | def test_setup(self): | 222 | def test_setup(self): |
@@ -206,22 +232,29 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) | |||
206 | self.runbbsetup("--help") | 232 | self.runbbsetup("--help") |
207 | 233 | ||
208 | # set up global location for top-dir-prefix | 234 | # set up global location for top-dir-prefix |
209 | out = self.runbbsetup("install-global-settings") | 235 | out = self.runbbsetup("settings --global default top-dir-prefix {}".format(self.tempdir)) |
210 | settings_path = "{}/global-config".format(self.tempdir) | 236 | settings_path = "{}/global-config".format(self.tempdir) |
211 | self.assertIn(settings_path, out[0]) | 237 | self.assertIn(settings_path, out[0]) |
212 | out = self.runbbsetup("change-global-setting default top-dir-prefix {}".format(self.tempdir)) | ||
213 | self.assertIn("Setting 'top-dir-prefix' in section 'default' is changed to", out[0]) | 238 | self.assertIn("Setting 'top-dir-prefix' in section 'default' is changed to", out[0]) |
214 | self.assertIn("New global settings written to".format(settings_path), out[0]) | 239 | self.assertIn("New settings written to".format(settings_path), out[0]) |
240 | out = self.runbbsetup("settings --global default dl-dir {}".format(os.path.join(self.tempdir, 'downloads'))) | ||
241 | self.assertIn("Setting 'dl-dir' in section 'default' is changed to", out[0]) | ||
242 | self.assertIn("New settings written to".format(settings_path), out[0]) | ||
215 | 243 | ||
216 | # check that writing settings works and then adjust them to point to | 244 | # check that writing settings works and then adjust them to point to |
217 | # test registry repo | 245 | # test registry repo |
218 | out = self.runbbsetup("install-settings") | 246 | out = self.runbbsetup("settings default registry 'git://{};protocol=file;branch=master;rev=master'".format(self.registrypath)) |
219 | settings_path = "{}/bitbake-builds/bitbake-setup.conf".format(self.tempdir) | 247 | settings_path = "{}/bitbake-builds/settings.conf".format(self.tempdir) |
220 | self.assertIn(settings_path, out[0]) | 248 | self.assertIn(settings_path, out[0]) |
221 | out = self.runbbsetup("change-setting default registry 'git://{};protocol=file;branch=master;rev=master'".format(self.registrypath)) | ||
222 | self.assertIn("Setting 'registry' in section 'default' is changed to", out[0]) | 249 | self.assertIn("Setting 'registry' in section 'default' is changed to", out[0]) |
223 | self.assertIn("New settings written to".format(settings_path), out[0]) | 250 | self.assertIn("New settings written to".format(settings_path), out[0]) |
224 | 251 | ||
252 | # check that listing settings works | ||
253 | out = self.runbbsetup("settings --list") | ||
254 | self.assertIn("default top-dir-prefix {}".format(self.tempdir), out[0]) | ||
255 | self.assertIn("default dl-dir {}".format(os.path.join(self.tempdir, 'downloads')), out[0]) | ||
256 | self.assertIn("default registry {}".format('git://{};protocol=file;branch=master;rev=master'.format(self.registrypath)), out[0]) | ||
257 | |||
225 | # check that 'list' produces correct output with no configs, one config and two configs | 258 | # check that 'list' produces correct output with no configs, one config and two configs |
226 | out = self.runbbsetup("list") | 259 | out = self.runbbsetup("list") |
227 | self.assertNotIn("test-config-1", out[0]) | 260 | self.assertNotIn("test-config-1", out[0]) |
@@ -247,8 +280,18 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) | |||
247 | self.add_file_to_testrepo('test-file', test_file_content) | 280 | self.add_file_to_testrepo('test-file', test_file_content) |
248 | 281 | ||
249 | # test-config-1 is tested as a registry config, test-config-2 as a local file | 282 | # test-config-1 is tested as a registry config, test-config-2 as a local file |
250 | test_configurations = {'test-config-1': {'cmdline': 'test-config-1', 'buildconfigs':('gadget','gizmo','gadget-notemplate','gizmo-notemplate')}, | 283 | test_configurations = {'test-config-1': {'cmdline': 'test-config-1', |
251 | 'test-config-2': {'cmdline': os.path.join(self.registrypath,'config-2/test-config-2.conf.json'), 'buildconfigs': ('gadget','gizmo','gadget-notemplate','gizmo-notemplate', 'gizmo-notemplate-with-thisdir') } } | 284 | 'buildconfigs':('gadget','gizmo', |
285 | 'gizmo-env-passthrough', | ||
286 | 'gizmo-no-fragment', | ||
287 | 'gadget-notemplate','gizmo-notemplate')}, | ||
288 | 'test-config-2': {'cmdline': os.path.join(self.registrypath,'config-2/test-config-2.conf.json'), | ||
289 | 'buildconfigs': ('gadget','gizmo', | ||
290 | 'gizmo-env-passthrough', | ||
291 | 'gizmo-no-fragment', | ||
292 | 'gadget-notemplate','gizmo-notemplate', | ||
293 | 'gizmo-notemplate-with-thisdir')} | ||
294 | } | ||
252 | for cf, v in test_configurations.items(): | 295 | for cf, v in test_configurations.items(): |
253 | for c in v['buildconfigs']: | 296 | for c in v['buildconfigs']: |
254 | out = self.runbbsetup("init --non-interactive {} {}".format(v['cmdline'], c)) | 297 | out = self.runbbsetup("init --non-interactive {} {}".format(v['cmdline'], c)) |
@@ -272,13 +315,16 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) | |||
272 | prev_test_file_content = test_file_content | 315 | prev_test_file_content = test_file_content |
273 | test_file_content = 'modified\n' | 316 | test_file_content = 'modified\n' |
274 | self.add_file_to_testrepo('test-file', test_file_content) | 317 | self.add_file_to_testrepo('test-file', test_file_content) |
275 | for c in ('gadget','gizmo','gadget-notemplate','gizmo-notemplate'): | 318 | for c in ('gadget', 'gizmo', |
319 | 'gizmo-env-passthrough', | ||
320 | 'gizmo-no-fragment', | ||
321 | 'gadget-notemplate', 'gizmo-notemplate'): | ||
276 | buildpath = os.path.join(self.tempdir, 'bitbake-builds', 'test-config-1-{}'.format(c)) | 322 | buildpath = os.path.join(self.tempdir, 'bitbake-builds', 'test-config-1-{}'.format(c)) |
277 | os.environ['BBPATH'] = os.path.join(buildpath, 'build') | 323 | os.environ['BBPATH'] = os.path.join(buildpath, 'build') |
278 | out = self.runbbsetup("status") | 324 | out = self.runbbsetup("status") |
279 | self.assertIn("Layer repository file://{} checked out into {}/layers/test-repo updated revision master from".format(self.testrepopath, buildpath), out[0]) | 325 | self.assertIn("Layer repository file://{} checked out into {}/layers/test-repo updated revision master from".format(self.testrepopath, buildpath), out[0]) |
280 | out = self.runbbsetup("update") | 326 | out = self.runbbsetup("update") |
281 | if c in ('gadget','gizmo'): | 327 | if c in ('gadget', 'gizmo'): |
282 | self.assertIn("Existing bitbake configuration directory renamed to {}/build/conf-backup.".format(buildpath), out[0]) | 328 | self.assertIn("Existing bitbake configuration directory renamed to {}/build/conf-backup.".format(buildpath), out[0]) |
283 | 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]) |
284 | with open(os.path.join(buildpath, 'config', "config-upstream.json")) as f: | 330 | with open(os.path.join(buildpath, 'config', "config-upstream.json")) as f: |
@@ -294,14 +340,17 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) | |||
294 | self.git('checkout -b {}'.format(branch), cwd=self.testrepopath) | 340 | self.git('checkout -b {}'.format(branch), cwd=self.testrepopath) |
295 | self.add_file_to_testrepo('test-file', test_file_content) | 341 | self.add_file_to_testrepo('test-file', test_file_content) |
296 | json_1 = self.add_json_config_to_registry('test-config-1.conf.json', branch, branch) | 342 | json_1 = self.add_json_config_to_registry('test-config-1.conf.json', branch, branch) |
297 | for c in ('gadget','gizmo','gadget-notemplate','gizmo-notemplate'): | 343 | for c in ('gadget', 'gizmo', |
344 | 'gizmo-env-passthrough', | ||
345 | 'gizmo-no-fragment', | ||
346 | 'gadget-notemplate', 'gizmo-notemplate'): | ||
298 | buildpath = os.path.join(self.tempdir, 'bitbake-builds', 'test-config-1-{}'.format(c)) | 347 | buildpath = os.path.join(self.tempdir, 'bitbake-builds', 'test-config-1-{}'.format(c)) |
299 | os.environ['BBPATH'] = os.path.join(buildpath, 'build') | 348 | os.environ['BBPATH'] = os.path.join(buildpath, 'build') |
300 | out = self.runbbsetup("status") | 349 | out = self.runbbsetup("status") |
301 | self.assertIn("Configuration in {} has changed:".format(buildpath), out[0]) | 350 | self.assertIn("Configuration in {} has changed:".format(buildpath), out[0]) |
302 | self.assertIn('- "rev": "master"\n+ "rev": "another-branch"', out[0]) | 351 | self.assertIn('- "rev": "master"\n+ "rev": "another-branch"', out[0]) |
303 | out = self.runbbsetup("update") | 352 | out = self.runbbsetup("update") |
304 | if c in ('gadget','gizmo'): | 353 | if c in ('gadget', 'gizmo'): |
305 | self.assertIn("Existing bitbake configuration directory renamed to {}/build/conf-backup.".format(buildpath), out[0]) | 354 | self.assertIn("Existing bitbake configuration directory renamed to {}/build/conf-backup.".format(buildpath), out[0]) |
306 | self.assertIn('-{}+{}'.format(prev_test_file_content, test_file_content), out[0]) | 355 | self.assertIn('-{}+{}'.format(prev_test_file_content, test_file_content), out[0]) |
307 | with open(os.path.join(buildpath, 'config', "config-upstream.json")) as f: | 356 | with open(os.path.join(buildpath, 'config', "config-upstream.json")) as f: |