From patchwork Tue May 5 18:28:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Kent X-Patchwork-Id: 87547 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 35706FF8855 for ; Tue, 5 May 2026 18:29:06 +0000 (UTC) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.673.1778005739369802693 for ; Tue, 05 May 2026 11:28:59 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=W3IWkGwN; spf=pass (domain: gmail.com, ip: 209.85.221.41, mailfrom: sam.john.kent@gmail.com) Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-448528f4e69so3314537f8f.3 for ; Tue, 05 May 2026 11:28:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778005737; x=1778610537; 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=bCYcdYqlipwQ0HIF+cbtW4+7S1dXpvXs59A5ca87gPU=; b=W3IWkGwNxZB30niGsab/m2PEDnzwb72LdpBRIKxSBEE026YJ5V1gBL/VEGb3Tv84xQ JPuLVwsG6rqE2TR9skaGi7Bolq2Dv09ad2dH+GveS7SkVwHjJK/Qz142d4s0lHjPhd4p HWlyzc2NEH0XUvSU3GRkfflqcwqvqaFs39Zwn8QxqudBHIlxN88UDXjvPx/N3zC/D//k DJ/hHv+PRJlTjicmTLTo+UPCWCzfYfdLa1WVhdmMIf6fxjIEtoMVanHCyu4DFpF91epi 3uavk/wF87rG1nJupgyDjnlu+Nibfw2Tky/qOsriFhLa9mn1eby3F0WStQVkn6PXBtQ1 zqUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778005737; x=1778610537; 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=bCYcdYqlipwQ0HIF+cbtW4+7S1dXpvXs59A5ca87gPU=; b=QCIzipRA0LZKsMotFxFsORdGu3TsyXzqa8TjS3OT2PW68Q2/Ky7QCEBFi2iuXTqKHM HMI5w+u1VC+Q6UYAr45NjsQYfCiM73MfKfveJjcyzoMhzbrww/jtRzzZHaWQrvi3ag5X p1E7vFFyzkFis/iIARo2G+CWG4LcAHkom+R7Ze8ReL4tMZtKFBnzm4BdmbuLtVLGMv8s m8EjRuhqZArUkNQOYkF3iDMPvqfSzdAqwICjXDeOwJo5OvzDClO/5LOCJNb1Yq5Pf3QS DAT3vsmAW24H7ZkNU/gehHhqZCH7lKJvMAlv3/ckBZPQLYXAtoVAUdLfw+tuLDyT7y10 XvQQ== X-Gm-Message-State: AOJu0YwMyiyt3zjeI6UEK/RSeHFE2Po3PWccrv5p2y1QV4Ukujx1Q/yU I78Tvurl1vMojhFHPzKRQBA+kQ5gp6oECUPagOejUcsfb8Q0vXiPTmjg7wpkNN62UUMc4A== X-Gm-Gg: AeBDievYH514FcIrlle+VaNLGBlM9LyUEGDq249hNXYNvsIptow/wJSctCcmtBu0F75 RdLORU+f+nWdodhxlYUAAFtMyDnZbj7ilcoOKrXDXGcX4GH9hIPrE5NnPbVWSIrhBTRapE0EJQE MdRP4oqNUqeJ59EW0U1sLDwLSzCipanywI3ViIQYgI6uFPjMnv4pa+9/tKKKTMW8VOwzINidfGO M50ndM6hvsMTA6clY+3FczeMMPMGnGDeWu3Xw9WsPDTKs7O0i8QE4jAErYJdXueKE+BE2284Vqw Iq1IHrDmQoDuzl4W3FmACbtcw/5ZH5Stal68tEhO9hdEkDFUuZKSx+6V12C2GENWym1hXeZQ1W2 ywXGeSseI7IaSdAhvP/FjDpwwVDPfE9NdPl9XpwhD82QQGe5RGICXKrxqqnMohlCltbUH052K00 afDRZXWdPY3TZsJObjUjweQkDxldSE7RVkhqu+PO8+K7lrcMNEOl3jpl1p/WKFmcdEjjIgwmg1j QGk8W0= X-Received: by 2002:a05:6000:2f83:b0:43c:fe0e:5bbc with SMTP id ffacd0b85a97d-4515bae9122mr422910f8f.19.1778005737223; Tue, 05 May 2026 11:28:57 -0700 (PDT) Received: from sam-ThinkPad-X1-Carbon-Gen-11.netbird.cloud ([45.12.242.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45054b03d4csm6818780f8f.22.2026.05.05.11.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2026 11:28:56 -0700 (PDT) From: Sam Kent To: openembedded-core@lists.openembedded.org Cc: mathieu.dubois-briand@bootlin.com, richard.purdie@linuxfoundation.org, Sam Kent Subject: [PATCH v5 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling Date: Tue, 5 May 2026 19:28:42 +0100 Message-Id: <20260505182844.1136632-1-sam.john.kent@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260505170521.1129945-1-sam.john.kent@gmail.com> References: <20260505170521.1129945-1-sam.john.kent@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, 05 May 2026 18:29:06 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/236524 An empty runtime-provides directory caused lookup-recipe, package-info and list-pkg-files to skip the runtime-reverse fallback. Use os.listdir() to ensure the folder is not empty and use os.path.isdir( to ensure it is not a file. Signed-off-by: Sam Kent --- scripts/oe-pkgdata-util | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util index bbfc6a2..904008b 100755 --- a/scripts/oe-pkgdata-util +++ b/scripts/oe-pkgdata-util @@ -289,8 +289,9 @@ def lookup_recipe(args): for pkg in pkgs: providepkgpath = os.path.join(args.pkgdata_dir, "runtime-rprovides", pkg) - if os.path.exists(providepkgpath): - for f in os.listdir(providepkgpath): + rprovides = os.listdir(providepkgpath) if os.path.isdir(providepkgpath) else [] + if rprovides: + for f in rprovides: if f != pkg: print("%s is in the RPROVIDES of %s:" % (pkg, f)) pkgdatafile = os.path.join(args.pkgdata_dir, "runtime", f) @@ -355,8 +356,9 @@ def package_info(args): for pkg in packages: providepkgpath = os.path.join(args.pkgdata_dir, "runtime-rprovides", pkg) - if os.path.exists(providepkgpath): - for f in os.listdir(providepkgpath): + rprovides = os.listdir(providepkgpath) if os.path.isdir(providepkgpath) else [] + if rprovides: + for f in rprovides: if f != pkg: print("%s is in the RPROVIDES of %s:" % (pkg, f)) pkgdatafile = os.path.join(args.pkgdata_dir, "runtime", f) @@ -507,8 +509,9 @@ def list_pkg_files(args): else: providepkgpath = os.path.join(args.pkgdata_dir, "runtime-rprovides", pkg) - if os.path.exists(providepkgpath): - for f in os.listdir(providepkgpath): + rprovides = os.listdir(providepkgpath) if os.path.isdir(providepkgpath) else [] + if rprovides: + for f in rprovides: if f != pkg: print("%s is in the RPROVIDES of %s:" % (pkg, f)) pkgdatafile = os.path.join(args.pkgdata_dir, "runtime", f) From patchwork Tue May 5 18:28:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sam Kent X-Patchwork-Id: 87549 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 665B8CD343B for ; Tue, 5 May 2026 18:29:06 +0000 (UTC) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.725.1778005741319792530 for ; Tue, 05 May 2026 11:29:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=F/HG1ewg; spf=pass (domain: gmail.com, ip: 209.85.221.48, mailfrom: sam.john.kent@gmail.com) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-44e5624c053so1468005f8f.2 for ; Tue, 05 May 2026 11:29:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778005739; x=1778610539; 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=QWyhzVHkxYx4vi7DJmjCoDTQIufTHceXy+tKkIjZxeg=; b=F/HG1ewgdQErcgPzWhHknbw2OxVYEcOSODKEvz0Ft1WxjVuPyfQYiD4Tq9ugNJaRAx utamtAiUAy5nYyUo5f6JWBjFzkn99ZL/KSzvuFuxXJR1PLCnFyMd7rknnrzpVQpCmDyl KLuZdBZk5BeX1q2QdHBcsG+mcZUqunDSi1qO57e8T5Qq91wSYDudHsICUB62qmC8rrzT kKM0g/gwxABm2nEtrHRk/Fty2epiIgRi99U5RNX20TdDqTnG05wVCP0BbX6NpRIOzlyW rWQJNWbuWsNBJiMyHrM1fJkUSCj9ibAgAPqvGQKvrXUSDbSmFziAsMEYK9k9UHMfW/uA oD1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778005739; x=1778610539; 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=QWyhzVHkxYx4vi7DJmjCoDTQIufTHceXy+tKkIjZxeg=; b=Fy8vARkUCKb8iZFv9x6i22FtsZOqmPMLTxafmIt6aoN6vrZHVr4BA6rIPFXi+7sVqh 0DeH8uPglxR+IeMwFXZBfg2WI5HmapnVvqoVuA/OcpW3Y2U63IWPFs2z/DgGc0IMFo5K rvkRQt4O98xLWYaCrPODlZSWswX3YfhxOI87ffZCNdfsyudruS9PtpgIXQjQFyk3Q+Do fuBpsRDaSxbvJ8EhRZ2DEH/d/+E/1IYpdA3/2dia95+uBqtq7JnV2r2zePqEzvFkmnIm D4CP23Nm3Jj9T+wiAW+96vp7IMPCVBctn3ekgMhmafPYi2ZN0EYydcU5eE+5XV18KchA jwSg== X-Gm-Message-State: AOJu0YwDeOtJJdkAePXR1VdcIApyAwdblQ4Lhb/P4dlI0Gs7YO2Tm84K FuLku6ihy3iNRyZg3ojoa2sFf4potrV4njM/aCVjb75izeWrXReG2TNGqW9Gsjyya8FRCw== X-Gm-Gg: AeBDietdb2nPY8A8FBn7djeCjbdG8G2mlZrXVYVy9cld5+iOuX1r1vasd2IyjjR8k4P rbCL1QfICbCfYXCC7q42NoTO6JUTuhyGE6KX4UlleI3ij9Gf/+3v/XIIKfmLqaqiHtFAfeoK668 YhImdgGrThIJZlgVV+Y6kYeKjhBD80pU8it6bF7wEahyWXQRdjNqKoDfVId+2UGw5JjJvoSExdQ zWnERiFYZcx/yzoL4MC4Wx5Rm6m1pchi0Vv31ifbqq1L10/TaEuWspRkWTCsuXVVvaO9OaOGL7C DEFy03cYlXh5lsC3RyePiX20Nb5ywHop1HBbLulHRgfXh85hxosSJDXBatCoCHyxyTRsZ+gc4Qr 0JM72yEuUQt/2f0CbUy4amJ0n3Og3G48C0XyAYC/CfpXqX1dv7+OPnGRBWPaePTfhjPsIm1ME6z DPYbnbUdxkky/c4rGYgBK6LPogHcfg9i9HaTagziGylr15bq/JG604fAyKmGFMNG6+Vzs1oWEKu ptHGHSMoLbm75K1/Q== X-Received: by 2002:a05:6000:601:b0:44d:67f7:e1a6 with SMTP id ffacd0b85a97d-4515ce1c946mr427284f8f.20.1778005739322; Tue, 05 May 2026 11:28:59 -0700 (PDT) Received: from sam-ThinkPad-X1-Carbon-Gen-11.netbird.cloud ([45.12.242.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45054b03d4csm6818780f8f.22.2026.05.05.11.28.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2026 11:28:58 -0700 (PDT) From: Sam Kent To: openembedded-core@lists.openembedded.org Cc: mathieu.dubois-briand@bootlin.com, richard.purdie@linuxfoundation.org, Sam Kent Subject: [PATCH v5 2/3] oelib: add unit tests for kernel module detection helpers Date: Tue, 5 May 2026 19:28:43 +0100 Message-Id: <20260505182844.1136632-2-sam.john.kent@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260505182844.1136632-1-sam.john.kent@gmail.com> References: <20260505170521.1129945-1-sam.john.kent@gmail.com> <20260505182844.1136632-1-sam.john.kent@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, 05 May 2026 18:29:06 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/236525 Add tests for the filename pre-filter logic, is_kernel_module(), and is_kernel_module_signed() to meta/lib/oeqa/selftest/cases/oelib/ Signed-off-by: Sam Kent --- meta/lib/oeqa/selftest/cases/oelib/package.py | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 meta/lib/oeqa/selftest/cases/oelib/package.py diff --git a/meta/lib/oeqa/selftest/cases/oelib/package.py b/meta/lib/oeqa/selftest/cases/oelib/package.py new file mode 100644 index 0000000..5751057 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/oelib/package.py @@ -0,0 +1,108 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import mmap +import os +import tempfile +from unittest.case import TestCase + + +class TestKernelModuleFilenameFilter(TestCase): + """ + The pre-filter in process_split_and_strip_files() selects candidates to + pass to is_elf(). It must use f.endswith(".ko"), not ".ko" in f, to avoid + false-positives on compressed modules (.ko.xz, .ko.gz). + """ + + ko_files = [ + "driver.ko", + "net/foo.ko", + ] + + not_ko_files = [ + "driver.ko.xz", + "driver.ko.gz", + "driver.ko2", + "myko.c", + "vmlinux", + ] + + def test_endswith_matches_ko(self): + for f in self.ko_files: + with self.subTest(f=f): + self.assertTrue(f.endswith(".ko")) + + def test_endswith_rejects_non_ko(self): + for f in self.not_ko_files: + with self.subTest(f=f): + self.assertFalse(f.endswith(".ko")) + + def test_old_predicate_had_false_positives(self): + # The previous check (".ko" in f) matched compressed modules — this is + # the regression the fix addresses. + false_positives = [f for f in self.not_ko_files if ".ko" in f] + self.assertEqual(false_positives, ["driver.ko.xz", "driver.ko.gz", "driver.ko2"]) + + +class TestIsKernelModule(TestCase): + """ + is_kernel_module() detects kernel modules by searching for the + "vermagic=" string, which is always present in genuine .ko files. + """ + + def setUp(self): + from oe.package import is_kernel_module + self.is_kernel_module = is_kernel_module + self._tmpfile = None + + def tearDown(self): + if self._tmpfile and os.path.exists(self._tmpfile): + os.unlink(self._tmpfile) + + def _make_tmp(self, content): + f = tempfile.NamedTemporaryFile(delete=False, suffix=".ko") + f.write(content) + f.close() + return f.name + + def test_detects_vermagic(self): + self._tmpfile = self._make_tmp(b"\x7fELF\x00" * 10 + b"vermagic=5.15.0" + b"\x00" * 10) + self.assertTrue(self.is_kernel_module(self._tmpfile)) + + def test_rejects_plain_elf(self): + self._tmpfile = self._make_tmp(b"\x7fELF\x00" * 50) + self.assertFalse(self.is_kernel_module(self._tmpfile)) + + +class TestIsKernelModuleSigned(TestCase): + """ + is_kernel_module_signed() detects the "Module signature appended" tail + that the kernel's modsign infrastructure writes. + """ + + def setUp(self): + from oe.package import is_kernel_module_signed + self.is_kernel_module_signed = is_kernel_module_signed + self._tmpfile = None + + def tearDown(self): + if self._tmpfile and os.path.exists(self._tmpfile): + os.unlink(self._tmpfile) + + def _make_tmp(self, content): + f = tempfile.NamedTemporaryFile(delete=False, suffix=".ko") + f.write(content) + f.close() + return f.name + + def test_detects_signed(self): + tail = b"Module signature appended\n\x00\x00" + self._tmpfile = self._make_tmp(b"\x00" * 64 + tail) + self.assertTrue(self.is_kernel_module_signed(self._tmpfile)) + + def test_rejects_unsigned(self): + self._tmpfile = self._make_tmp(b"\x7fELF\x00" * 20) + self.assertFalse(self.is_kernel_module_signed(self._tmpfile)) From patchwork Tue May 5 18:28:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sam Kent X-Patchwork-Id: 87548 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 43AEDCD3439 for ; Tue, 5 May 2026 18:29:06 +0000 (UTC) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.726.1778005743877515364 for ; Tue, 05 May 2026 11:29:04 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=ldwosoL4; spf=pass (domain: gmail.com, ip: 209.85.221.52, mailfrom: sam.john.kent@gmail.com) Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-43fe62837baso3089373f8f.3 for ; Tue, 05 May 2026 11:29:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778005742; x=1778610542; 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=iSPpAGe0QhXEcve7pLZOgeAXtZhG4hz4K0PrXKXCCsU=; b=ldwosoL43r0Hw5sXO05lfUx7GzgaChOijtNg9UhksBcl+/GOKVWjgx0TcgcjKAJMXe AxJAq+/+myORpyghatIzMOwFhRCui8Z/yxJtbtRU6vLiJEvjp1fwOEPhtt3CS5/4HTVo aQhQnRRIXbQYKd0FssCZMCOPP4h8rH5+nT9Ozl1wpaOc7x7AkGuX9NzkRmBNPlyBb3sw 9rdyBrtqliDQQplOOtFEObJscTD35DuY543BYAbdjKoW78jhuSmOwyop2TBSUButwLDh GiUhNG9kO3E7ahevGVkSf1LuHC08mCOFV9G8BpD3zG8IbyCHDoEGmCkO+SPrtwjuSlwP jPMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778005742; x=1778610542; 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=iSPpAGe0QhXEcve7pLZOgeAXtZhG4hz4K0PrXKXCCsU=; b=e10+DXIVUPNIq0J7moblsuAQok6GQzFa1KNo2hX3S71RFJTxTshBQ0pEib6vP0Fziy HDTuHDr4IYJ9jHjI1nFiV++CN+6Hu0Ze7I5PTAOB7Z0pl1ZrhNozoh3K4KdnfszjUgY6 8Daa41arBJvVLDp+vltlc6pZMeQSFMyZz6fgDF/MHeGRPsE9QSX5taUF5JR0lFhmbU47 4aSJpXqXXEUq03YBcD3kvV7Iis/ihBTK4uO7zRCu3o3YD8osRL17TxRvuUXaEWRmMkFn 1z5Jh+S8o/D/FY9aYl0UKrZJHjEvkqoUH93Er7WVKPMWOyh9a4CCKsXEvAqM4xUcVJmR 5BTA== X-Gm-Message-State: AOJu0Yz+DIq1/bTL3Gsv3BmxpI5bk5rwyw77Ra+lUWJoRwFr0fWRAnr+ 24P+pWXazEbgxGNkpH9zOwC+rHxMTZ/qxDDmR5dsH3NmKtU4x1ewVPTCmPbfyjmmge7D/w== X-Gm-Gg: AeBDievFW+2StodHNaXtfxnNWEQ52LltoFN16IFjziNwgMPDmKDWR8vL9N5wC6Ig+w8 htK7I9bCsfMtVZNtZuGYsY4fo3R+Kuc7PIteMzl6ZvWFPLkk3CljK6VEZCWf45Vcc47W+pX1m8p 3c41NbIzbuf63AGbsunJ2ZxNIdki+iNoXp3ZG2ip1sZk/NxfhEArwwH7Cg27juKT6Nost3Z6Hpy ThLle4uzf8vi3koQ3qaS8DCENHRmxtS0aV6wQRTPg6PgvTgWpNJSxd6OZw1ztKFwHtLwQuyrKRu d/MWqyxnb4VkdhlD8u3W9cGUqFSFnFdQ/PMCJK3kTPVldvT/HPle7iKy4xUXKvOkKPaw602xvwU RVQdG3EMguJyshHB+9iUfuNBaDSq5Y/jDUU8wXce2Icx7nDuR8TZAa4h/IMMwxEe1tbKQ88jeis nLisbB1bKcSTFfAWYAn3AMsPSrtosXf5EHAG65qYhM2U+smxJzQjOq1c+DYxuEQ2iQudS373GLL usoerA= X-Received: by 2002:a05:6000:2995:20b0:43d:762e:76c6 with SMTP id ffacd0b85a97d-4515b05738bmr357438f8f.7.1778005741901; Tue, 05 May 2026 11:29:01 -0700 (PDT) Received: from sam-ThinkPad-X1-Carbon-Gen-11.netbird.cloud ([45.12.242.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45054b03d4csm6818780f8f.22.2026.05.05.11.29.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2026 11:29:01 -0700 (PDT) From: Sam Kent To: openembedded-core@lists.openembedded.org Cc: mathieu.dubois-briand@bootlin.com, richard.purdie@linuxfoundation.org, Sam Kent Subject: [PATCH v5 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter Date: Tue, 5 May 2026 19:28:44 +0100 Message-Id: <20260505182844.1136632-3-sam.john.kent@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260505182844.1136632-1-sam.john.kent@gmail.com> References: <20260505170521.1129945-1-sam.john.kent@gmail.com> <20260505182844.1136632-1-sam.john.kent@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, 05 May 2026 18:29:06 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/236526 Add selftest-ko-filter recipe and a PackageTests.test_kmodule_prefilter oe-selftest that builds it to verify process_split_and_strip_files() handles .ko.xz/.ko.gz alongside a real .ko without corrupting them. Regression test for YOCTO #2348. AI-Generated: Uses Claude Sonnet 4.6 Signed-off-by: Sam Kent --- .../selftest-ko-filter/files/module.c | 3 ++ .../selftest-ko-filter/selftest-ko-filter.bb | 29 +++++++++++++++++++ meta/lib/oeqa/selftest/cases/package.py | 22 ++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 meta-selftest/recipes-test/selftest-ko-filter/files/module.c create mode 100644 meta-selftest/recipes-test/selftest-ko-filter/selftest-ko-filter.bb diff --git a/meta-selftest/recipes-test/selftest-ko-filter/files/module.c b/meta-selftest/recipes-test/selftest-ko-filter/files/module.c new file mode 100644 index 0000000..f6d50ba --- /dev/null +++ b/meta-selftest/recipes-test/selftest-ko-filter/files/module.c @@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: MIT */ +/* Minimal relocatable object used as a .ko stand-in for pre-filter testing. */ +int selftest_ko_filter_marker = 42; diff --git a/meta-selftest/recipes-test/selftest-ko-filter/selftest-ko-filter.bb b/meta-selftest/recipes-test/selftest-ko-filter/selftest-ko-filter.bb new file mode 100644 index 0000000..1b8cc73 --- /dev/null +++ b/meta-selftest/recipes-test/selftest-ko-filter/selftest-ko-filter.bb @@ -0,0 +1,29 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# +SUMMARY = "Test fixture for the kernel-module file pre-filter in package.py" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +SRC_URI = "file://module.c" +S = "${UNPACKDIR}" + +MODDIR = "${libdir}/selftest-ko-filter" + +do_compile () { + ${CC} ${CFLAGS} -c module.c -o module.ko +} + +do_install () { + install -d ${D}${MODDIR} + install -m 0644 module.ko ${D}${MODDIR}/ + + # Fake compressed modules — the pre-filter must not pass these to strip. + # Use octal escapes: dash (the OE recipe shell) does not support \xHH in printf. + printf '\375\067\172\130\132\000' > ${D}${MODDIR}/module.ko.xz + printf '\037\213' > ${D}${MODDIR}/module.ko.gz +} + +FILES:${PN} = "${MODDIR}/*" diff --git a/meta/lib/oeqa/selftest/cases/package.py b/meta/lib/oeqa/selftest/cases/package.py index 38ed717..d33424b 100644 --- a/meta/lib/oeqa/selftest/cases/package.py +++ b/meta/lib/oeqa/selftest/cases/package.py @@ -185,6 +185,28 @@ class PackageTests(OESelftestTestCase): if not gdbtest(qemu, binary): self.fail('GDB %s failed' % binary) + def test_kmodule_prefilter(self): + # Regression test for YOCTO #2348: process_split_and_strip_files() must + # use f.endswith(".ko") so that compressed modules (.ko.xz, .ko.gz) are + # not fed to is_elf() / strip. + bitbake("selftest-ko-filter -c package") + + pkgdest = get_bb_var('PKGDEST', 'selftest-ko-filter') + libdir = get_bb_var('libdir', 'selftest-ko-filter') + moddir = pkgdest + "/selftest-ko-filter" + libdir + "/selftest-ko-filter" + + self.assertTrue(os.path.exists(moddir + "/module.ko"), + "module.ko missing from PKGDEST") + + for fname, magic in [("module.ko.xz", b"\xfd\x37\x7a\x58\x5a\x00"), + ("module.ko.gz", b"\x1f\x8b")]: + path = moddir + "/" + fname + self.assertTrue(os.path.exists(path), + "%s missing from PKGDEST" % fname) + with open(path, "rb") as f: + self.assertEqual(f.read(len(magic)), magic, + "%s header corrupted in PKGDEST" % fname) + def test_preserve_ownership(self): features = 'IMAGE_INSTALL:append = " selftest-chown"\n' self.write_config(features)