From patchwork Tue Mar 24 13:29:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Tondo X-Patchwork-Id: 84226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7989F54ABA for ; Tue, 24 Mar 2026 13:30:27 +0000 (UTC) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.19721.1774359018918558739 for ; Tue, 24 Mar 2026 06:30:19 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=EdbNYfl/; spf=pass (domain: gmail.com, ip: 209.85.128.48, mailfrom: stondo@gmail.com) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-48704db565eso31051555e9.1 for ; Tue, 24 Mar 2026 06:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774359017; x=1774963817; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5UZZzXQzurrs8J8UMbL8fHyl6r4+dsVbTu7T2utEzjo=; b=EdbNYfl/jspdITq50BeXZqZBDZgyKFB7hpSqQdhonRHGusb3rKjx9nHY0UDSU6nhjJ Vg991XY4whJAkLDt6y08e3qrOh5mSOEiYT5M4SvQB4jOktskBIGnwetbryRADY8EMmwF YcIOSmWo5WAiaoEhpojNvsYconhMd1NFawab8+VBgXq7ZDiCjRMY4ViOlqF20JS/1FIZ UZGn7b9vxynJ5wy1qRKVkleD6kWZb/dIpBELIIsF89cq6qFS0qirAXf8CwarcIs8lExZ Pj4zlMJLHrw40DHOgiYGrCOcYonrQkEfB4CUOaZFGotn6wnkc//o5/mPgzCEBo/g9oLV hDEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774359017; x=1774963817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5UZZzXQzurrs8J8UMbL8fHyl6r4+dsVbTu7T2utEzjo=; b=l+40kx1gfSKHe6GdqtrC4LQUVW4lQUAkJm3J4AWXPZSV4wR8AFy+KCjw1LRTAe5H8T EEtAIIpJQEdv6wQiyQgDFu56UD7RX4zRqFavpHA1VaULzlUaTJJm+qMHBFa2ncAAD84S gJnCncNkX5NjpCKry0h8ibpm2LdGNKiYtdQdq5ic4Ok6lxRaMCU4C5X/cCtGphj5rns0 whTRIq+UchGY0loCh7mtiTdsc1RHJMJoBOe44q/HlvIN0NKOdA0lm28Wn039DmQce3oo AOwOX2EC1q4KLASKVcp3u7YPjeUjXJ1lk+TfIIYCAOCETzYQvwmfIfaZ6Bu/0SgLcQu7 1/Uw== X-Gm-Message-State: AOJu0YzW0duxptqVYS6sHIOJntvC26pLMnaSXWZrTqVTJYfZlI/Vz38J Sn0oNL5E76MHjVTixn+wJ/wG1HJp4aZX4q9SiaDFGYnySNbWopkC197Br34D0A8e X-Gm-Gg: ATEYQzzlQwvUmQc/e8EqHNoOasRC9lRVaHScoySzZT03yoUFn81MD03iWWtkXGaP2L+ D8/2rAP2GToszuXf5RtyMJOd056Lrlq34upMTKg0mGViG9T0LyaYoFkA2gtru1wVNoBMLqrKYVH Zp9jz30Muy9QfI1ZYsECczrex0HRY6TgqsF2tFHeAzBDocgmGQKNjrf8y18LLI5KNrfsy+bw4kJ vtFhRmDw5Hkj1pOG3ovnwWSTFcSCCGsSAYEVDYDFAde9CBspqRn0dV2KLSyBS22TV8eVFWh09f5 KamKOtuc+JpdiFrm0LixBHUA9sNqtzPdYZc7wL+JBBSPu9V1lro1ENbzr8/9TBwt+VUFjFuw8Go u3ynRjVS4zMJ7ydo8zsJmWXiOR4WSN0VOyVSh+VTxaEEXR/aicizI+Ghcc/hMXUiJXkVRxCWnnX PxwoLtdLWM2gcVgptWA8vQI3Di9+64lmZAv6+70sgrgjmKB0aBWSpWoUtdxqNaFpbacD1G9DQ9V UDgrrMj X-Received: by 2002:a05:600c:1c0a:b0:485:40c6:f528 with SMTP id 5b1f17b1804b1-486fee2bb38mr249454285e9.30.1774359016828; Tue, 24 Mar 2026 06:30:16 -0700 (PDT) Received: from fedora (mob-194-230-148-205.cgn.sunrise.net. [194.230.148.205]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48710fa0e35sm47494875e9.3.2026.03.24.06.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 06:30:16 -0700 (PDT) From: stondo@gmail.com To: openembedded-core@lists.openembedded.org Cc: richard.purdie@linuxfoundation.org, ross.burton@arm.com, jpewhacker@gmail.com, stefano.tondo.ext@siemens.com, peter.marko@siemens.com, adrian.freihofer@siemens.com, mathieu.dubois-briand@bootlin.com Subject: [OE-core][PATCH v14 4/4] oeqa/selftest: Add tests for source download enrichment Date: Tue, 24 Mar 2026 14:29:58 +0100 Message-ID: <20260324132958.2316491-5-stondo@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260324132958.2316491-1-stondo@gmail.com> References: <20260323210745.1337169-1-stefano.tondo.ext@siemens.com> <20260324132958.2316491-1-stondo@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 24 Mar 2026 13:30:27 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/233801 From: Stefano Tondo Add two tests for the new source download SPDX features: test_download_location_defensive_handling: Verify that packages with no download location (e.g. packagegroups, images, virtual providers) are handled gracefully without crashing the SPDX generation pipeline. test_version_extraction_patterns: Verify that Git source packages get SRCREV as their version in the SPDX output, rather than the recipe PV. Signed-off-by: Stefano Tondo --- meta/lib/oeqa/selftest/cases/spdx.py | 76 ++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/meta/lib/oeqa/selftest/cases/spdx.py b/meta/lib/oeqa/selftest/cases/spdx.py index af1144c1e5..9347e0bf7b 100644 --- a/meta/lib/oeqa/selftest/cases/spdx.py +++ b/meta/lib/oeqa/selftest/cases/spdx.py @@ -428,3 +428,79 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase): value, ["enabled", "disabled"], f"Unexpected PACKAGECONFIG value '{value}' for {key}" ) + + def test_download_location_defensive_handling(self): + """Test that download_location handling is defensive. + + Verifies SPDX generation succeeds and external references are + properly structured when download_location retrieval works. + """ + objset = self.check_recipe_spdx( + "m4", + "{DEPLOY_DIR_SPDX}/{SSTATE_PKGARCH}/builds/build-m4.spdx.json", + ) + + found_external_refs = False + for pkg in objset.foreach_type(oe.spdx30.software_Package): + if pkg.externalRef: + found_external_refs = True + for ref in pkg.externalRef: + self.assertIsNotNone(ref.externalRefType) + self.assertIsNotNone(ref.locator) + self.assertGreater(len(ref.locator), 0, "Locator should have at least one entry") + for loc in ref.locator: + self.assertIsInstance(loc, str) + break + + self.logger.info( + f"External references {'found' if found_external_refs else 'not found'} " + f"in SPDX output (defensive handling verified)" + ) + + def test_version_extraction_patterns(self): + """Test that version extraction works for various package formats. + + Verifies that Git source downloads carry extracted versions and that + the reported version strings are well-formed. + """ + objset = self.check_recipe_spdx( + "opkg-utils", + "{DEPLOY_DIR_SPDX}/{SSTATE_PKGARCH}/builds/build-opkg-utils.spdx.json", + ) + + # Collect all packages with versions + packages_with_versions = [] + for pkg in objset.foreach_type(oe.spdx30.software_Package): + if pkg.software_packageVersion: + packages_with_versions.append((pkg.name, pkg.software_packageVersion)) + + self.assertGreater( + len(packages_with_versions), 0, + "Should find packages with extracted versions" + ) + + for name, version in packages_with_versions: + self.assertRegex( + version, + r"^[0-9a-f]{40}$", + f"Expected Git source version for {name} to be a full SHA-1", + ) + + self.logger.info(f"Found {len(packages_with_versions)} packages with versions") + + # Log some examples for debugging + for name, version in packages_with_versions[:5]: + self.logger.info(f" {name}: {version}") + + # Verify that versions follow expected patterns + for name, version in packages_with_versions: + # Version should not be empty + self.assertIsNotNone(version) + self.assertNotEqual(version, "") + + # Version should contain digits + self.assertRegex( + version, + r'\d', + f"Version '{version}' for package '{name}' should contain digits" + )