There's a similar recipe in meta-oe (kernel-selftest) but it needs clang
and seems overly complicated.

This recipe still needs further improvements, primarily that there is no
integration into oeqa, but that can come later.

Signed-off-by: Ross Burton <ross.bur...@arm.com>
---
 meta/conf/distro/include/maintainers.inc |  1 +
 meta/recipes-kernel/linux/kselftest.bb   | 65 ++++++++++++++++++++++++
 2 files changed, 66 insertions(+)
 create mode 100644 meta/recipes-kernel/linux/kselftest.bb

diff --git a/meta/conf/distro/include/maintainers.inc 
b/meta/conf/distro/include/maintainers.inc
index 4cac0647c2a..3485c9df1b0 100644
--- a/meta/conf/distro/include/maintainers.inc
+++ b/meta/conf/distro/include/maintainers.inc
@@ -304,6 +304,7 @@ RECIPE_MAINTAINER:pn-kexec-tools = "Unassigned 
<unassig...@yoctoproject.org>"
 RECIPE_MAINTAINER:pn-keymaps = "Alexander Kanavin <alex.kana...@gmail.com>"
 RECIPE_MAINTAINER:pn-kmod = "Chen Qi <qi.c...@windriver.com>"
 RECIPE_MAINTAINER:pn-kmscube = "Carlos Rafael Giani <crg7...@mailbox.org>"
+RECIPE_MAINTAINER:pn-kselftest = "Ross Burton <ross.bur...@arm.com>"
 RECIPE_MAINTAINER:pn-l3afpad = "Anuj Mittal <anuj.mit...@intel.com>"
 RECIPE_MAINTAINER:pn-lame = "Michael Opdenacker <mich...@opdenacker.org>"
 RECIPE_MAINTAINER:pn-ldconfig-native = "Khem Raj <raj.k...@gmail.com>"
diff --git a/meta/recipes-kernel/linux/kselftest.bb 
b/meta/recipes-kernel/linux/kselftest.bb
new file mode 100644
index 00000000000..dec57aca071
--- /dev/null
+++ b/meta/recipes-kernel/linux/kselftest.bb
@@ -0,0 +1,65 @@
+SUMMARY = "kselftest, the kernel test suite"
+SECTION = "kernel"
+LICENSE = "GPL-2.0-only"
+
+DEPENDS = "rsync-native"
+
+inherit kernelsrc kernel-arch pkgconfig
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+# Unconventional usage of PACKAGECONFIG to control how the tests are built.
+#
+# Enabled should be unused, Disabled is the list of test targets which should
+# be skipped if this dependency isn't present.
+PACKAGECONFIG ??= "alsa libcap libcapng netlink numa openssl popt"
+PACKAGECONFIG[alsa] = ",alsa,alsa-lib"
+PACKAGECONFIG[bpf] = ",bpf hid,clang-native elfutils"
+PACKAGECONFIG[fuse] = ",,fuse"
+PACKAGECONFIG[libcap] = ",,libcap"
+PACKAGECONFIG[libcapng] = ",,libcap-ng"
+PACKAGECONFIG[netlink] = ",,libmnl"
+PACKAGECONFIG[numa] = ",,numactl"
+PACKAGECONFIG[openssl] = ",,openssl"
+PACKAGECONFIG[popt] = ",,popt"
+
+B = "${WORKDIR}/build"
+
+do_compile[cleandirs] = "${B}"
+
+CC:remove:aarch64 = "-mbranch-protection=standard"
+SECURITY_CFLAGS = ""
+
+SKIP_TARGETS = "${PACKAGECONFIG_CONFARGS}"
+
+EXTRA_OEMAKE += "\
+    O=${B} \
+    V=1 \
+    ARCH=${ARCH} \
+    CROSS_COMPILE=${TARGET_PREFIX} \
+    CC="${CC} ${DEBUG_PREFIX_MAP}" \
+    AR="${AR}" \
+    LD="${LD}" \
+    HOSTPKG_CONFIG=pkg-config-native \
+    SKIP_TARGETS="${SKIP_TARGETS}" \
+"
+
+# Force all tests to build successfully. Usually we just package what
+# successfully builds.
+# EXTRA_OEMAKE += "FORCE_TARGETS=1"
+
+do_compile() {
+       oe_runmake -C ${S}/tools/testing/selftests
+}
+
+do_install() {
+       oe_runmake -C ${S}/tools/testing/selftests install 
INSTALL_PATH=${D}/${libexecdir}/kselftest
+       # install uses rsync -a so reset the permissions
+       chown -R root:root ${D}/${libexecdir}/kselftest
+}
+
+RDEPENDS:${PN} += "bash coreutils grep iproute2 python3-core python3 perl 
perl-module-io-handle"
+
+# Some binaries appear to be explicitly built without debug info, and often
+# don't pass LDFLAGS. As this is a testing tool this is acceptable.
+INSANE_SKIP:${PN} = "ldflags already-stripped textrel"
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#208149): 
https://lists.openembedded.org/g/openembedded-core/message/208149
Mute This Topic: https://lists.openembedded.org/mt/109884369/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to