diff options
Diffstat (limited to 'meta/lib')
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/spdx.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/spdx.py b/meta/lib/oeqa/selftest/cases/spdx.py index 8cd4e83ca2..035f3fe336 100644 --- a/meta/lib/oeqa/selftest/cases/spdx.py +++ b/meta/lib/oeqa/selftest/cases/spdx.py | |||
| @@ -286,3 +286,60 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase): | |||
| 286 | break | 286 | break |
| 287 | else: | 287 | else: |
| 288 | self.assertTrue(False, "Unable to find imported Host SpdxID") | 288 | self.assertTrue(False, "Unable to find imported Host SpdxID") |
| 289 | |||
| 290 | def test_kernel_config_spdx(self): | ||
| 291 | kernel_recipe = get_bb_var("PREFERRED_PROVIDER_virtual/kernel") | ||
| 292 | spdx_file = f"recipe-{kernel_recipe}.spdx.json" | ||
| 293 | spdx_path = f"{{DEPLOY_DIR_SPDX}}/{{SSTATE_PKGARCH}}/recipes/{spdx_file}" | ||
| 294 | |||
| 295 | # Make sure kernel is configured first | ||
| 296 | bitbake(f"-c configure {kernel_recipe}") | ||
| 297 | |||
| 298 | objset = self.check_recipe_spdx( | ||
| 299 | kernel_recipe, | ||
| 300 | spdx_path, | ||
| 301 | task="do_create_kernel_config_spdx", | ||
| 302 | extraconf="""\ | ||
| 303 | INHERIT += "create-spdx" | ||
| 304 | SPDX_INCLUDE_KERNEL_CONFIG = "1" | ||
| 305 | """, | ||
| 306 | ) | ||
| 307 | |||
| 308 | # Check that at least one CONFIG_* entry exists | ||
| 309 | found_kernel_config = False | ||
| 310 | for build_obj in objset.foreach_type(oe.spdx30.build_Build): | ||
| 311 | if getattr(build_obj, "build_buildType", "") == "https://openembedded.org/kernel-configuration": | ||
| 312 | found_kernel_config = True | ||
| 313 | self.assertTrue( | ||
| 314 | len(getattr(build_obj, "build_parameter", [])) > 0, | ||
| 315 | "Kernel configuration build_Build has no CONFIG_* entries" | ||
| 316 | ) | ||
| 317 | break | ||
| 318 | |||
| 319 | self.assertTrue(found_kernel_config, "Kernel configuration build_Build not found in SPDX output") | ||
| 320 | |||
| 321 | def test_packageconfig_spdx(self): | ||
| 322 | objset = self.check_recipe_spdx( | ||
| 323 | "tar", | ||
| 324 | "{DEPLOY_DIR_SPDX}/{SSTATE_PKGARCH}/recipes/recipe-tar.spdx.json", | ||
| 325 | extraconf="""\ | ||
| 326 | SPDX_INCLUDE_PACKAGECONFIG = "1" | ||
| 327 | """, | ||
| 328 | ) | ||
| 329 | |||
| 330 | found_entries = [] | ||
| 331 | for build_obj in objset.foreach_type(oe.spdx30.build_Build): | ||
| 332 | for param in getattr(build_obj, "build_parameter", []): | ||
| 333 | if param.key.startswith("PACKAGECONFIG:"): | ||
| 334 | found_entries.append((param.key, param.value)) | ||
| 335 | |||
| 336 | self.assertTrue( | ||
| 337 | found_entries, | ||
| 338 | "No PACKAGECONFIG entries found in SPDX output for 'tar'" | ||
| 339 | ) | ||
| 340 | |||
| 341 | for key, value in found_entries: | ||
| 342 | self.assertIn( | ||
| 343 | value, ["enabled", "disabled"], | ||
| 344 | f"Unexpected PACKAGECONFIG value '{value}' for {key}" | ||
| 345 | ) | ||
