From: "Sam Kent" <sam.john.kent@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Sam Kent <sam.john.kent@gmail.com>
Subject: [PATCH v2 3/3] oeqa/selftest: add oe-selftest for kernel module pre-filter
Date: Tue, 28 Apr 2026 09:10:46 +0100 [thread overview]
Message-ID: <20260428081046.1660101-4-sam.john.kent@gmail.com> (raw)
In-Reply-To: <20260428081046.1660101-1-sam.john.kent@gmail.com>
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
next prev parent reply other threads:[~2026-04-28 9:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Sam Kent [this message]
2026-04-29 12:45 ` [PATCH v3 1/2] oelib: " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260428081046.1660101-4-sam.john.kent@gmail.com \
--to=sam.john.kent@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.