]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
oeqa/sdk: add out-of-tree kernel module building test
authorRoss Burton <ross.burton@arm.com>
Fri, 12 Jul 2024 18:43:58 +0000 (19:43 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 18 Jul 2024 16:21:01 +0000 (17:21 +0100)
Validate that out-of-tree kernel module building using kernel-devsrc
works as expected.

This test uses cryptodev-linux as a idiomatic out of tree module. As the
latest release doesn't actually build with kernel 6.7+, use the same
commit that our recipe uses.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/sdk/cases/kmod.py [new file with mode: 0644]

diff --git a/meta/lib/oeqa/sdk/cases/kmod.py b/meta/lib/oeqa/sdk/cases/kmod.py
new file mode 100644 (file)
index 0000000..9e8fdbc
--- /dev/null
@@ -0,0 +1,41 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+import subprocess
+import tempfile
+import unittest
+
+from oeqa.sdk.case import OESDKTestCase
+from oeqa.utils.subprocesstweak import errors_have_output
+errors_have_output()
+
+class KernelModuleTest(OESDKTestCase):
+    """
+    Test that out-of-tree kernel modules build.
+    """
+
+    def setUp(self):
+        if not self.tc.hasTargetPackage("kernel-devsrc"):
+            raise unittest.SkipTest("KernelModuleTest needs kernel-devsrc")
+
+        # These targets need to be built before kernel modules can be built.
+        self._run("make -j -C $OECORE_TARGET_SYSROOT/usr/src/kernel prepare scripts")
+
+
+    def test_cryptodev(self):
+        with tempfile.TemporaryDirectory(prefix="cryptodev", dir=self.tc.sdk_dir) as testdir:
+            git_url = "https://github.com/cryptodev-linux/cryptodev-linux"
+            # This is a knnown-good commit post-1.13 that builds with kernel 6.7+
+            git_sha = "bb8bc7cf60d2c0b097c8b3b0e807f805b577a53f"
+
+            sourcedir = os.path.join(testdir, "cryptodev-linux")
+            subprocess.check_output(["git", "clone", git_url, sourcedir], stderr=subprocess.STDOUT)
+            self.assertTrue(os.path.isdir(sourcedir))
+            subprocess.check_output(["git", "-C", sourcedir, "checkout", git_sha], stderr=subprocess.STDOUT)
+
+            self._run("make -C %s V=1 KERNEL_DIR=$OECORE_TARGET_SYSROOT/usr/src/kernel" % sourcedir)
+            self.check_elf(os.path.join(sourcedir, "cryptodev.ko"))