From nobody Mon Feb 9 08:56:07 2026 Received: from mailgw01.zimbra-vnc.de (mailgw01.zimbra-vnc.de [148.251.101.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76921286D4D; Mon, 26 Jan 2026 19:35:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.101.236 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769456139; cv=none; b=K2FfHubQu97A6ze/HNHpuJl3gNU04coTAcCjHmuFyN+4Zpo4uJvdVohobV2gCXH8RwIF9xHHaqQUjYNtT2JB6nawVomQFZl7XKopnLy6wGWqAUVI7cDHhWDM4eS+T/Uax+dC+zexcThzGuA/PCy+4zYeV3V1yybDGFdNNiXWm4o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769456139; c=relaxed/simple; bh=ifK6y7ESTkLRQ3A93vdqh2szgwDr9S74b2hXw6gK29A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aeTX9VW/RoYqKl8rAyXExemj1ts8ENhpKcBubdsBeK/mwrvWabyqTW+/VffNo+65bwyuVNMGCQ5axA5wI4dKqZBEhMHDTlAi9ItnmDb7fwsf6JHZ9eDo5Hw0tOvnctbEvCcOrTg15x9feePVZjGMCnX7PqFA/m7bcHEFo6MDvAc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tngtech.com; spf=pass smtp.mailfrom=tngtech.com; dkim=pass (2048-bit key) header.d=tngtech.com header.i=@tngtech.com header.b=mU69tfIY; arc=none smtp.client-ip=148.251.101.236 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tngtech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tngtech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tngtech.com header.i=@tngtech.com header.b="mU69tfIY" Received: from zmproxy.tng.vnc.biz (zimbra-vnc.tngtech.com [35.234.71.156]) by mailgw01.zimbra-vnc.de (Postfix) with ESMTPS id 29DBB3FAF2; Mon, 26 Jan 2026 20:35:34 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zmproxy.tng.vnc.biz (Postfix) with ESMTP id E42901FA3D7; Mon, 26 Jan 2026 20:35:32 +0100 (CET) Received: from zmproxy.tng.vnc.biz ([127.0.0.1]) by localhost (zmproxy.tng.vnc.biz [127.0.0.1]) (amavis, port 10032) with ESMTP id GdYr0lHnBxoo; Mon, 26 Jan 2026 20:35:32 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zmproxy.tng.vnc.biz (Postfix) with ESMTP id 5837F1FA7AF; Mon, 26 Jan 2026 20:35:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 zmproxy.tng.vnc.biz 5837F1FA7AF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tngtech.com; s=B14491C6-869D-11EB-BB6C-8DD33D883B31; t=1769456132; bh=gWg1ozqnV38gDPTbJjaTTr/2ExUrF6zZXVvlJpEkHhU=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=mU69tfIYqOq/woFcGbijqrxxJsebqDl1A+bx6FxZGIhHu606pAzJhSNe6YWOeK0Rn ohuXJF9Nt36YqVCFF5H7HxtdhjYbjuAGUd5wxosTfl/UrA54kkBTyr1/qYMe8EY/Nc FEnL8FtURuxUEihF+Gx1m0C6C9H3SOFqPijq+7uo/Ir+N8/ZTN/phZOwG3LLk1yWAJ Im6Y8P0PvT23icxDUcY01UHlzdv9M9o+U+/JauQC39JhQbdxDth/8R1GkpM0PaPMJG NuXtLl3swjfDphaS/FCTKWGGt7C0doiKbLeBETWGJaeUQU3gPkOGG9Lqy62zo0LYkp y9IviNfdcsucA== X-Virus-Scanned: amavis at zmproxy.tng.vnc.biz Received: from zmproxy.tng.vnc.biz ([127.0.0.1]) by localhost (zmproxy.tng.vnc.biz [127.0.0.1]) (amavis, port 10026) with ESMTP id 2-8IAOAy3KXv; Mon, 26 Jan 2026 20:35:32 +0100 (CET) Received: from DESKTOP-0O0JV6I.localdomain (ipservice-092-208-231-176.092.208.pools.vodafone-ip.de [92.208.231.176]) by zmproxy.tng.vnc.biz (Postfix) with ESMTPSA id E82EE1FA3D7; Mon, 26 Jan 2026 20:35:31 +0100 (CET) From: Luis Augenstein To: nathan@kernel.org, nsc@kernel.org Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, gregkh@linuxfoundation.org, maximilian.huber@tngtech.com, Luis Augenstein Subject: [PATCH v3 14/14] tools/sbom: add unit tests for SPDX-License-Identifier parsing Date: Mon, 26 Jan 2026 20:33:04 +0100 Message-Id: <20260126193304.320916-15-luis.augenstein@tngtech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260126193304.320916-1-luis.augenstein@tngtech.com> References: <20260126193304.320916-1-luis.augenstein@tngtech.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Verify that SPDX-License-Identifier headers at the top of source files are parsed correctly. Co-developed-by: Maximilian Huber Signed-off-by: Maximilian Huber Signed-off-by: Luis Augenstein --- tools/sbom/tests/spdx_graph/__init__.py | 0 .../sbom/tests/spdx_graph/test_kernel_file.py | 32 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tools/sbom/tests/spdx_graph/__init__.py create mode 100644 tools/sbom/tests/spdx_graph/test_kernel_file.py diff --git a/tools/sbom/tests/spdx_graph/__init__.py b/tools/sbom/tests/spd= x_graph/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tools/sbom/tests/spdx_graph/test_kernel_file.py b/tools/sbom/t= ests/spdx_graph/test_kernel_file.py new file mode 100644 index 000000000000..bc44e7a97d2a --- /dev/null +++ b/tools/sbom/tests/spdx_graph/test_kernel_file.py @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: GPL-2.0-only OR MIT +# Copyright (C) 2025 TNG Technology Consulting GmbH + +import unittest +from pathlib import Path +import tempfile +from sbom.spdx_graph.kernel_file import _parse_spdx_license_identifier # = type: ignore + + +class TestKernelFile(unittest.TestCase): + def setUp(self): + self.tmpdir =3D tempfile.TemporaryDirectory() + self.src_tree =3D Path(self.tmpdir.name) + + def tearDown(self): + self.tmpdir.cleanup() + + def test_parse_spdx_license_identifier(self): + # REUSE-IgnoreStart + test_cases: list[tuple[str, str | None]] =3D [ + ("/* SPDX-License-Identifier: MIT*/", "MIT"), + ("// SPDX-License-Identifier: GPL-2.0-only", "GPL-2.0-only"), + ("/* SPDX-License-Identifier: GPL-2.0-or-later OR MIT */", "GP= L-2.0-or-later OR MIT"), + ("/* SPDX-License-Identifier: Apache-2.0 */\n extra text", "Ap= ache-2.0"), + ("int main() { return 0; }", None), + ] + # REUSE-IgnoreEnd + + for i, (file_content, expected_identifier) in enumerate(test_cases= ): + file_path =3D self.src_tree / f"file_{i}.c" + file_path.write_text(file_content) + self.assertEqual(_parse_spdx_license_identifier(str(file_path)= ), expected_identifier) --=20 2.34.1