Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Fix .ko file pre-filter to use endswith instead of string contains
@ 2026-04-28  8:10 Sam Kent
  2026-04-28  8:10 ` [PATCH v2 1/3] package.py: fix kernel module file pre-filter and document strip asymmetry Sam Kent
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Sam Kent @ 2026-04-28  8:10 UTC (permalink / raw)
  To: openembedded-core; +Cc: Sam Kent


Sam Kent (3):
  package.py: fix kernel module file pre-filter and document strip
    asymmetry
  oe/package: add unit tests for kernel module detection helpers
  oeqa/selftest: add oe-selftest for kernel module pre-filter

 .../selftest-ko-filter/files/module.c         |   3 +
 .../selftest-ko-filter/selftest-ko-filter.bb  |  29 +++++
 meta/lib/oe/package.py                        |   5 +-
 meta/lib/oe/tests/__init__.py                 |   0
 meta/lib/oe/tests/test_package.py             | 121 ++++++++++++++++++
 meta/lib/oeqa/selftest/cases/package.py       |  22 ++++
 6 files changed, 178 insertions(+), 2 deletions(-)
 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
 create mode 100644 meta/lib/oe/tests/__init__.py
 create mode 100644 meta/lib/oe/tests/test_package.py

-- 
2.34.1



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 1/3] package.py: fix kernel module file pre-filter and document strip asymmetry
  2026-04-28  8:10 [PATCH v2 0/3] Fix .ko file pre-filter to use endswith instead of string contains Sam Kent
@ 2026-04-28  8:10 ` Sam Kent
  2026-04-28  8:10 ` [PATCH v2 2/3] oe/package: add unit tests for kernel module detection helpers Sam Kent
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 19+ messages in thread
From: Sam Kent @ 2026-04-28  8:10 UTC (permalink / raw)
  To: openembedded-core; +Cc: Sam Kent

Change the check to f.endswith(".ko"), consistent with strip_execs() and
with the /lib/modules/ guard already present in is_elf() and
splitdebuginfo().

Fixes [YOCTO #2348]

Signed-off-by: Sam Kent <sam.john.kent@gmail.com>
---
 meta/lib/oe/package.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index 279cd56..c375acc 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -37,7 +37,8 @@ def runstrip(file, elftype, strip, extra_strip_sections=''):
 
     stripcmd = [strip]
     skip_strip = False
-    # kernel module
+    # kernel module: use --strip-debug and --preserve-dates (required for
+    # module signing to remain valid after stripping)
     if elftype & 16:
         if is_kernel_module_signed(file):
             bb.debug(1, "Skip strip on signed module %s" % file)
@@ -1167,7 +1168,7 @@ def process_split_and_strip_files(d):
                         or (s[stat.ST_MODE] & stat.S_IXOTH) \
                         or ((file.startswith(libdir) or file.startswith(baselibdir)) \
                         and (".so" in f or ".node" in f)) \
-                        or (f.startswith('vmlinux') or ".ko" in f):
+                        or (f.startswith('vmlinux') or f.endswith(".ko")):
 
                     if cpath.islink(file):
                         checkelflinks[file] = ltarget
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 2/3] oe/package: add unit tests for kernel module detection helpers
  2026-04-28  8:10 [PATCH v2 0/3] Fix .ko file pre-filter to use endswith instead of string contains Sam Kent
  2026-04-28  8:10 ` [PATCH v2 1/3] package.py: fix kernel module file pre-filter and document strip asymmetry Sam Kent
@ 2026-04-28  8:10 ` Sam Kent
  2026-04-28 20:48   ` [OE-core] " Richard Purdie
  2026-06-04 11:51   ` Richard Purdie
  2026-04-28  8:10 ` [PATCH v2 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
  2026-04-29 12:45 ` [PATCH v3 1/2] oelib: add unit tests for kernel module detection helpers Sam Kent
  3 siblings, 2 replies; 19+ messages in thread
From: Sam Kent @ 2026-04-28  8:10 UTC (permalink / raw)
  To: openembedded-core; +Cc: Sam Kent

Add unit tests for the filename pre-filter logic, is_kernel_module(),
and the is_kernel_module_signed() detection.

Signed-off-by: Sam Kent <sam.john.kent@gmail.com>
---
 meta/lib/oe/tests/__init__.py     |   0
 meta/lib/oe/tests/test_package.py | 121 ++++++++++++++++++++++++++++++
 2 files changed, 121 insertions(+)
 create mode 100644 meta/lib/oe/tests/__init__.py
 create mode 100644 meta/lib/oe/tests/test_package.py

diff --git a/meta/lib/oe/tests/__init__.py b/meta/lib/oe/tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/meta/lib/oe/tests/test_package.py b/meta/lib/oe/tests/test_package.py
new file mode 100644
index 0000000..29e393c
--- /dev/null
+++ b/meta/lib/oe/tests/test_package.py
@@ -0,0 +1,121 @@
+#!/usr/bin/env python3
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+import mmap
+import os
+import tempfile
+import unittest
+
+
+# Copied from oe/package.py to allow standalone execution without bitbake.
+def is_kernel_module(path):
+    with open(path) as f:
+        return mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ).find(b"vermagic=") >= 0
+
+def is_kernel_module_signed(path):
+    with open(path, "rb") as f:
+        f.seek(-28, 2)
+        module_tail = f.read()
+        return "Module signature appended" in "".join(chr(c) for c in bytearray(module_tail))
+
+
+class TestKernelModuleFilenameFilter(unittest.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):
+        # Demonstrate that 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(unittest.TestCase):
+    """
+    is_kernel_module() detects kernel modules by searching for the
+    "vermagic=" string, which is always present in genuine .ko files.
+    """
+
+    def _make_tmp(self, content: bytes) -> str:
+        f = tempfile.NamedTemporaryFile(delete=False, suffix=".ko")
+        f.write(content)
+        f.close()
+        return f.name
+
+    def tearDown(self):
+        # Clean up any temp files created during the test.
+        for attr in ("_tmpfile",):
+            path = getattr(self, attr, None)
+            if path and os.path.exists(path):
+                os.unlink(path)
+
+    def test_detects_vermagic(self):
+        self._tmpfile = self._make_tmp(b"\x7fELF\x00" * 10 + b"vermagic=5.15.0" + b"\x00" * 10)
+        self.assertTrue(is_kernel_module(self._tmpfile))
+
+    def test_rejects_plain_elf(self):
+        self._tmpfile = self._make_tmp(b"\x7fELF\x00" * 50)
+        self.assertFalse(is_kernel_module(self._tmpfile))
+
+
+class TestIsKernelModuleSigned(unittest.TestCase):
+    """
+    is_kernel_module_signed() detects the "Module signature appended" tail
+    that the kernel's modsign infrastructure writes.
+    """
+
+    def _make_tmp(self, content: bytes) -> str:
+        f = tempfile.NamedTemporaryFile(delete=False, suffix=".ko")
+        f.write(content)
+        f.close()
+        return f.name
+
+    def tearDown(self):
+        for attr in ("_tmpfile",):
+            path = getattr(self, attr, None)
+            if path and os.path.exists(path):
+                os.unlink(path)
+
+    def test_detects_signed(self):
+        # Pad to >28 bytes so the seek(-28, 2) works; place the magic at the end.
+        tail = b"Module signature appended\n\x00\x00"
+        self._tmpfile = self._make_tmp(b"\x00" * 64 + tail)
+        self.assertTrue(is_kernel_module_signed(self._tmpfile))
+
+    def test_rejects_unsigned(self):
+        self._tmpfile = self._make_tmp(b"\x7fELF\x00" * 20)
+        self.assertFalse(is_kernel_module_signed(self._tmpfile))
+
+
+if __name__ == "__main__":
+    unittest.main()
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter
  2026-04-28  8:10 [PATCH v2 0/3] Fix .ko file pre-filter to use endswith instead of string contains Sam Kent
  2026-04-28  8:10 ` [PATCH v2 1/3] package.py: fix kernel module file pre-filter and document strip asymmetry Sam Kent
  2026-04-28  8:10 ` [PATCH v2 2/3] oe/package: add unit tests for kernel module detection helpers Sam Kent
@ 2026-04-28  8:10 ` Sam Kent
  2026-04-29 12:45 ` [PATCH v3 1/2] oelib: add unit tests for kernel module detection helpers Sam Kent
  3 siblings, 0 replies; 19+ messages in thread
From: Sam Kent @ 2026-04-28  8:10 UTC (permalink / raw)
  To: openembedded-core; +Cc: Sam Kent

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 <sam.john.kent@gmail.com>
---
 .../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)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [OE-core] [PATCH v2 2/3] oe/package: add unit tests for kernel module detection helpers
  2026-04-28  8:10 ` [PATCH v2 2/3] oe/package: add unit tests for kernel module detection helpers Sam Kent
@ 2026-04-28 20:48   ` Richard Purdie
  2026-06-04 11:51   ` Richard Purdie
  1 sibling, 0 replies; 19+ messages in thread
From: Richard Purdie @ 2026-04-28 20:48 UTC (permalink / raw)
  To: sam.john.kent, openembedded-core

On Tue, 2026-04-28 at 09:10 +0100, Sam Kent via lists.openembedded.org wrote:
> Add unit tests for the filename pre-filter logic, is_kernel_module(),
> and the is_kernel_module_signed() detection.
> 
> Signed-off-by: Sam Kent <sam.john.kent@gmail.com>
> ---
>  meta/lib/oe/tests/__init__.py     |   0
>  meta/lib/oe/tests/test_package.py | 121 ++++++++++++++++++++++++++++++
>  2 files changed, 121 insertions(+)
>  create mode 100644 meta/lib/oe/tests/__init__.py
>  create mode 100644 meta/lib/oe/tests/test_package.py

Thanks, this is a good step in the right direction, however if won't be
executed by our standard autobuilder tests if it is in this location.
We run tests via oe-selftest (amongst other places).

The tests for lib/oe are in lib/oeqa/sefltest/cases/oelib/

You can run them with "oe-selftest -r oelib"

A recent example of a change which adds tests would be:

https://git.openembedded.org/openembedded-core/commit/?id=20322406a77b178a6655427612ed25e79b308b21

If we extend them that way, they will be run as part of our regular
testing and then hopefully regressions get caught.

Your base patch 1/3 looked fine and passed review so we've merged that,
thanks!

Cheers,

Richard


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v3 1/2] oelib: add unit tests for kernel module detection helpers
  2026-04-28  8:10 [PATCH v2 0/3] Fix .ko file pre-filter to use endswith instead of string contains Sam Kent
                   ` (2 preceding siblings ...)
  2026-04-28  8:10 ` [PATCH v2 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
@ 2026-04-29 12:45 ` Sam Kent
  2026-04-29 12:45   ` [PATCH v3 2/2] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
                     ` (2 more replies)
  3 siblings, 3 replies; 19+ messages in thread
From: Sam Kent @ 2026-04-29 12:45 UTC (permalink / raw)
  To: openembedded-core; +Cc: richard.purdie, Sam Kent

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 <sam.john.kent@gmail.com>
---
 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))
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 2/2] oeqa/selftest: add oe-selftest for kernel module pre-filter
  2026-04-29 12:45 ` [PATCH v3 1/2] oelib: add unit tests for kernel module detection helpers Sam Kent
@ 2026-04-29 12:45   ` Sam Kent
  2026-05-04  7:59     ` [OE-core] " Mathieu Dubois-Briand
  2026-05-05 12:35   ` [OE-core] [PATCH v3 1/2] oelib: add unit tests for kernel module detection helpers Mathieu Dubois-Briand
  2026-05-05 17:05   ` [PATCH v4 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling Sam Kent
  2 siblings, 1 reply; 19+ messages in thread
From: Sam Kent @ 2026-04-29 12:45 UTC (permalink / raw)
  To: openembedded-core; +Cc: richard.purdie, Sam Kent

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 <sam.john.kent@gmail.com>
---
 .../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)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [OE-core] [PATCH v3 2/2] oeqa/selftest: add oe-selftest for kernel module pre-filter
  2026-04-29 12:45   ` [PATCH v3 2/2] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
@ 2026-05-04  7:59     ` Mathieu Dubois-Briand
  2026-05-04  8:01       ` Mathieu Dubois-Briand
  0 siblings, 1 reply; 19+ messages in thread
From: Mathieu Dubois-Briand @ 2026-05-04  7:59 UTC (permalink / raw)
  To: sam.john.kent, openembedded-core; +Cc: richard.purdie

On Wed Apr 29, 2026 at 2:45 PM CEST, Sam Kent via lists.openembedded.org wrote:
> 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 <sam.john.kent@gmail.com>
> ---

Hi Sam,

Thanks for your patch.

> 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

I have some trouble to find a version with this patch in. Are you based
on the master branch?

Thanks,
Mathieu

-- 
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [OE-core] [PATCH v3 2/2] oeqa/selftest: add oe-selftest for kernel module pre-filter
  2026-05-04  7:59     ` [OE-core] " Mathieu Dubois-Briand
@ 2026-05-04  8:01       ` Mathieu Dubois-Briand
  0 siblings, 0 replies; 19+ messages in thread
From: Mathieu Dubois-Briand @ 2026-05-04  8:01 UTC (permalink / raw)
  To: sam.john.kent, openembedded-core; +Cc: richard.purdie

On Mon May 4, 2026 at 9:59 AM CEST, Mathieu Dubois-Briand wrote:
> On Wed Apr 29, 2026 at 2:45 PM CEST, Sam Kent via lists.openembedded.org wrote:
>> 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 <sam.john.kent@gmail.com>
>> ---
>
> Hi Sam,
>
> Thanks for your patch.
>
>> 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
>
> I have some trouble to find a version with this patch in. Are you based
> on the master branch?
>
> Thanks,
> Mathieu

Ignore this, Monday morning, I just messed up my patch apply.

Sorry for the noise.


-- 
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [OE-core] [PATCH v3 1/2] oelib: add unit tests for kernel module detection helpers
  2026-04-29 12:45 ` [PATCH v3 1/2] oelib: add unit tests for kernel module detection helpers Sam Kent
  2026-04-29 12:45   ` [PATCH v3 2/2] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
@ 2026-05-05 12:35   ` Mathieu Dubois-Briand
  2026-05-05 17:05   ` [PATCH v4 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling Sam Kent
  2 siblings, 0 replies; 19+ messages in thread
From: Mathieu Dubois-Briand @ 2026-05-05 12:35 UTC (permalink / raw)
  To: sam.john.kent, openembedded-core; +Cc: richard.purdie

On Wed Apr 29, 2026 at 2:45 PM CEST, Sam Kent via lists.openembedded.org wrote:
> 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 <sam.john.kent@gmail.com>
> ---

Hi Sam,

Now I remember why I had your patch flagged.

This is triggering a fail in another test, as can be seen on the
autobuilder:

2026-05-05 09:36:25,307 - oe-selftest - INFO - pkgdata.OePkgdataUtilTests.test_lookup_recipe (subunit.RemotedTestCase)
2026-05-05 09:36:25,307 - oe-selftest - INFO -  ... FAIL
...
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/pkgdata.py", line 62, in test_lookup_recipe
    self.assertEqual(result.output, 'zlib\nbusybox')
  File "/usr/lib/python3.12/unittest/case.py", line 885, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/usr/lib/python3.12/unittest/case.py", line 1251, in assertMultiLineEqual
    self.fail(self._formatMessage(msg, standardMsg))
  File "/usr/lib/python3.12/unittest/case.py", line 715, in fail
    raise self.failureException(msg)
AssertionError: 'zlib' != 'zlib\nbusybox'
  zlib
+ busybox

https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/3792
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/3665

Can you have a look at the issue?

Thanks,
Mathieu

-- 
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v4 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling
  2026-04-29 12:45 ` [PATCH v3 1/2] oelib: add unit tests for kernel module detection helpers Sam Kent
  2026-04-29 12:45   ` [PATCH v3 2/2] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
  2026-05-05 12:35   ` [OE-core] [PATCH v3 1/2] oelib: add unit tests for kernel module detection helpers Mathieu Dubois-Briand
@ 2026-05-05 17:05   ` Sam Kent
  2026-05-05 17:05     ` [PATCH v4 2/3] oelib: add unit tests for kernel module detection helpers Sam Kent
                       ` (3 more replies)
  2 siblings, 4 replies; 19+ messages in thread
From: Sam Kent @ 2026-05-05 17:05 UTC (permalink / raw)
  To: openembedded-core; +Cc: mathieu.dubois-briand, richard.purdie, Sam Kent

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.
---
 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)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v4 2/3] oelib: add unit tests for kernel module detection helpers
  2026-05-05 17:05   ` [PATCH v4 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling Sam Kent
@ 2026-05-05 17:05     ` Sam Kent
  2026-05-05 17:05     ` [PATCH v4 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 19+ messages in thread
From: Sam Kent @ 2026-05-05 17:05 UTC (permalink / raw)
  To: openembedded-core; +Cc: mathieu.dubois-briand, richard.purdie, Sam Kent

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 <sam.john.kent@gmail.com>
---
 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))
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v4 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter
  2026-05-05 17:05   ` [PATCH v4 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling Sam Kent
  2026-05-05 17:05     ` [PATCH v4 2/3] oelib: add unit tests for kernel module detection helpers Sam Kent
@ 2026-05-05 17:05     ` Sam Kent
  2026-05-05 17:17     ` Patchtest results for [PATCH v4 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling patchtest
  2026-05-05 18:28     ` [PATCH v5 " Sam Kent
  3 siblings, 0 replies; 19+ messages in thread
From: Sam Kent @ 2026-05-05 17:05 UTC (permalink / raw)
  To: openembedded-core; +Cc: mathieu.dubois-briand, richard.purdie, Sam Kent

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 <sam.john.kent@gmail.com>
---
 .../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)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Patchtest results for [PATCH v4 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling
  2026-05-05 17:05   ` [PATCH v4 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling Sam Kent
  2026-05-05 17:05     ` [PATCH v4 2/3] oelib: add unit tests for kernel module detection helpers Sam Kent
  2026-05-05 17:05     ` [PATCH v4 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
@ 2026-05-05 17:17     ` patchtest
  2026-05-05 18:28     ` [PATCH v5 " Sam Kent
  3 siblings, 0 replies; 19+ messages in thread
From: patchtest @ 2026-05-05 17:17 UTC (permalink / raw)
  To: Sam Kent; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 2232 bytes --]

Thank you for your submission. Patchtest identified one
or more issues with the patch. Please see the log below for
more information:

---
Testing patch /home/patchtest/share/mboxes/v4-1-3-oe-pkgdata-util-fix-empty-runtime-rprovides-directory-handling.patch

FAIL: test Signed-off-by presence: Mbox is missing Signed-off-by. Add it manually or with "git commit --amend -s" (test_mbox.TestMbox.test_signed_off_by_presence)

PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this
email with an explanation of why the patch should be accepted. If you
believe these results are due to an error in patchtest, please submit a
bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category
under 'Yocto Project Subprojects'). For more information on specific
failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank
you!

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v5 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling
  2026-05-05 17:05   ` [PATCH v4 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling Sam Kent
                       ` (2 preceding siblings ...)
  2026-05-05 17:17     ` Patchtest results for [PATCH v4 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling patchtest
@ 2026-05-05 18:28     ` Sam Kent
  2026-05-05 18:28       ` [PATCH v5 2/3] oelib: add unit tests for kernel module detection helpers Sam Kent
  2026-05-05 18:28       ` [PATCH v5 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
  3 siblings, 2 replies; 19+ messages in thread
From: Sam Kent @ 2026-05-05 18:28 UTC (permalink / raw)
  To: openembedded-core; +Cc: mathieu.dubois-briand, richard.purdie, Sam Kent

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 <sam.john.kent@gmail.com>
---
 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)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v5 2/3] oelib: add unit tests for kernel module detection helpers
  2026-05-05 18:28     ` [PATCH v5 " Sam Kent
@ 2026-05-05 18:28       ` Sam Kent
  2026-05-05 18:28       ` [PATCH v5 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
  1 sibling, 0 replies; 19+ messages in thread
From: Sam Kent @ 2026-05-05 18:28 UTC (permalink / raw)
  To: openembedded-core; +Cc: mathieu.dubois-briand, richard.purdie, Sam Kent

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 <sam.john.kent@gmail.com>
---
 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))
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v5 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter
  2026-05-05 18:28     ` [PATCH v5 " Sam Kent
  2026-05-05 18:28       ` [PATCH v5 2/3] oelib: add unit tests for kernel module detection helpers Sam Kent
@ 2026-05-05 18:28       ` Sam Kent
  2026-06-04 12:04         ` Paul Barker
  1 sibling, 1 reply; 19+ messages in thread
From: Sam Kent @ 2026-05-05 18:28 UTC (permalink / raw)
  To: openembedded-core; +Cc: mathieu.dubois-briand, richard.purdie, Sam Kent

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 <sam.john.kent@gmail.com>
---
 .../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)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [OE-core] [PATCH v2 2/3] oe/package: add unit tests for kernel module detection helpers
  2026-04-28  8:10 ` [PATCH v2 2/3] oe/package: add unit tests for kernel module detection helpers Sam Kent
  2026-04-28 20:48   ` [OE-core] " Richard Purdie
@ 2026-06-04 11:51   ` Richard Purdie
  1 sibling, 0 replies; 19+ messages in thread
From: Richard Purdie @ 2026-06-04 11:51 UTC (permalink / raw)
  To: sam.john.kent, openembedded-core

On Tue, 2026-04-28 at 09:10 +0100, Sam Kent via lists.openembedded.org wrote:
> Add unit tests for the filename pre-filter logic, is_kernel_module(),
> and the is_kernel_module_signed() detection.
> 
> Signed-off-by: Sam Kent <sam.john.kent@gmail.com>
> ---
>  meta/lib/oe/tests/__init__.py     |   0
>  meta/lib/oe/tests/test_package.py | 121 ++++++++++++++++++++++++++++++
>  2 files changed, 121 insertions(+)
>  create mode 100644 meta/lib/oe/tests/__init__.py
>  create mode 100644 meta/lib/oe/tests/test_package.py
> 
> +class TestIsKernelModule(unittest.TestCase):
> +    """
> +    is_kernel_module() detects kernel modules by searching for the
> +    "vermagic=" string, which is always present in genuine .ko files.
> +    """
> +
> +    def _make_tmp(self, content: bytes) -> str:
> +        f = tempfile.NamedTemporaryFile(delete=False, suffix=".ko")
> +        f.write(content)
> +        f.close()
> +        return f.name
> +
> +    def tearDown(self):
> +        # Clean up any temp files created during the test.
> +        for attr in ("_tmpfile",):
> +            path = getattr(self, attr, None)
> +            if path and os.path.exists(path):
> +                os.unlink(path)
> +
> +    def test_detects_vermagic(self):
> +        self._tmpfile = self._make_tmp(b"\x7fELF\x00" * 10 + b"vermagic=5.15.0" + b"\x00" * 10)
> +        self.assertTrue(is_kernel_module(self._tmpfile))
> +
> +    def test_rejects_plain_elf(self):
> +        self._tmpfile = self._make_tmp(b"\x7fELF\x00" * 50)
> +        self.assertFalse(is_kernel_module(self._tmpfile))

Sorry about the delay in replying to this, I think we were all confused
about who was going to do it!

The code above is a little bit more complex than it needs to be. It can
be simplified to something like:

with NamedTemporaryFile(suffix=".ko") as f:
    f.write(b"\x7fELF\x00" * 10 + b"vermagic=5.15.0" + b"\x00" * 10)
    self.assertTrue(is_kernel_module(f.name))

which will self clean up. Could you make that tweak, then we should be
able to merge, thanks!

Cheers,

Richard



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter
  2026-05-05 18:28       ` [PATCH v5 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
@ 2026-06-04 12:04         ` Paul Barker
  0 siblings, 0 replies; 19+ messages in thread
From: Paul Barker @ 2026-06-04 12:04 UTC (permalink / raw)
  To: Sam Kent, openembedded-core; +Cc: mathieu.dubois-briand, richard.purdie

[-- Attachment #1: Type: text/plain, Size: 4728 bytes --]

On Tue, 2026-05-05 at 19:28 +0100, Sam Kent wrote:
> 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 <sam.john.kent@gmail.com>
> ---
>  .../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

Hi Sam,

Why are you writing bytes via printf here instead of using gzip and xz
to compess module.ko? You don't necessarily need to change this, but
please explain it in the commit message or comment.

> +}
> +
> +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")]:

I find it very confusing that we have octal escapes in do_install() and
hex escapes here. If we have to use octal escapes due to dash
limitations, let's also use octal escapes here.

> +            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)

Best regards,

-- 
Paul Barker


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-06-04 12:04 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-28  8:10 [PATCH v2 0/3] Fix .ko file pre-filter to use endswith instead of string contains Sam Kent
2026-04-28  8:10 ` [PATCH v2 1/3] package.py: fix kernel module file pre-filter and document strip asymmetry Sam Kent
2026-04-28  8:10 ` [PATCH v2 2/3] oe/package: add unit tests for kernel module detection helpers Sam Kent
2026-04-28 20:48   ` [OE-core] " Richard Purdie
2026-06-04 11:51   ` Richard Purdie
2026-04-28  8:10 ` [PATCH v2 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
2026-04-29 12:45 ` [PATCH v3 1/2] oelib: add unit tests for kernel module detection helpers Sam Kent
2026-04-29 12:45   ` [PATCH v3 2/2] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
2026-05-04  7:59     ` [OE-core] " Mathieu Dubois-Briand
2026-05-04  8:01       ` Mathieu Dubois-Briand
2026-05-05 12:35   ` [OE-core] [PATCH v3 1/2] oelib: add unit tests for kernel module detection helpers Mathieu Dubois-Briand
2026-05-05 17:05   ` [PATCH v4 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling Sam Kent
2026-05-05 17:05     ` [PATCH v4 2/3] oelib: add unit tests for kernel module detection helpers Sam Kent
2026-05-05 17:05     ` [PATCH v4 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
2026-05-05 17:17     ` Patchtest results for [PATCH v4 1/3] oe-pkgdata-util: fix empty runtime-rprovides directory handling patchtest
2026-05-05 18:28     ` [PATCH v5 " Sam Kent
2026-05-05 18:28       ` [PATCH v5 2/3] oelib: add unit tests for kernel module detection helpers Sam Kent
2026-05-05 18:28       ` [PATCH v5 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter Sam Kent
2026-06-04 12:04         ` Paul Barker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox