summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorKamel Bouhara (Schneider Electric) <kamel.bouhara@bootlin.com>2025-12-15 16:54:24 +0100
committerSteve Sakoman <steve@sakoman.com>2025-12-31 07:49:31 -0800
commit12a747565998e0e5703473e26614517e4cdb8842 (patch)
tree1f4f694940cb57847df532d73464bd8773b78ebc /meta/lib
parent707dce4f01527b23e775ec31282e94c3a74e71da (diff)
downloadpoky-12a747565998e0e5703473e26614517e4cdb8842.tar.gz
oeqa/selftest: oe-selftest: Add SPDX tests for kernel config and PACKAGECONFIG
Add test_kernel_config_spdx and test_packageconfig_spdx to verify SPDX document generation includes kernel configuration and package feature metadata when enabled. (From OE-Core rev: a172a0e8d543796ee78bb66650726168352f1cdf) Signed-off-by: Kamel Bouhara (Schneider Electric) <kamel.bouhara@bootlin.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 2f0ab110d7521510c60e0493ef3cb021130758cd) Signed-off-by: Kamel Bouhara <kamel.bouhara@bootlin.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/cases/spdx.py57
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 )