aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-kernel/kernel-selftest/kernel-selftest.bb
diff options
context:
space:
mode:
authorHongzhi.Song <hongzhi.song@windriver.com>2018-08-01 01:32:39 -0700
committerKhem Raj <raj.khem@gmail.com>2018-08-02 11:23:03 -0700
commit146de1dfdac3e640af1b082b3a0c8bcf4ee8dad3 (patch)
tree3a9fc67faa78357e9d1b30b1c233a3b272f19e84 /meta-oe/recipes-kernel/kernel-selftest/kernel-selftest.bb
parentd3ae34eec2d312410da6cc1dd1c6fb85e8259261 (diff)
downloadmeta-openembedded-contrib-146de1dfdac3e640af1b082b3a0c8bcf4ee8dad3.tar.gz
kernel-selftest: Add a recipe on kernel selftest
The recipe builds the framework for kernel-selftest. Now, it just contains two sets of testcase, bpf and vm. We will append more to this recipe. The following kernel config fragments must be manually enabled, i.e. in local.conf, to use this test suite. KERNEL_FEATURES_append += "features/bpf/bpf.scc \ cfg/debug-kselftest.scc \ features/hugetlb/hugetlb.scc \ " Signed-off-by: Hongzhi.Song <hongzhi.song@windriver.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-oe/recipes-kernel/kernel-selftest/kernel-selftest.bb')
-rw-r--r--meta-oe/recipes-kernel/kernel-selftest/kernel-selftest.bb104
1 files changed, 104 insertions, 0 deletions
diff --git a/meta-oe/recipes-kernel/kernel-selftest/kernel-selftest.bb b/meta-oe/recipes-kernel/kernel-selftest/kernel-selftest.bb
new file mode 100644
index 0000000000..27d98a3049
--- /dev/null
+++ b/meta-oe/recipes-kernel/kernel-selftest/kernel-selftest.bb
@@ -0,0 +1,104 @@
+SUMMARY = "Kernel selftest for Linux"
+DESCRIPTION = "Kernel selftest for Linux"
+LICENSE = "GPLv2"
+
+LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7 \
+"
+
+# for musl libc
+SRC_URI_libc-musl += "file://userfaultfd.patch \
+ file://0001-bpf-test_progs.c-add-support-for-musllibc.patch \
+"
+
+PACKAGECONFIG ??= "bpf vm"
+
+PACKAGECONFIG[bpf] = ",,elfutils libcap libcap-ng rsync-native,"
+PACKAGECONFIG[vm] = ",,,libgcc bash"
+
+do_patch[depends] += "virtual/kernel:do_shared_workdir"
+
+inherit linux-kernel-base kernel-arch
+
+do_populate_lic[depends] += "virtual/kernel:do_patch"
+
+S = "${WORKDIR}/${BP}"
+
+# now we just test bpf and vm
+# we will append other kernel selftest in the future
+TEST_LIST = "bpf \
+ vm \
+"
+
+EXTRA_OEMAKE = '\
+ CROSS_COMPILE=${TARGET_PREFIX} \
+ ARCH=${ARCH} \
+ CC="${CC}" \
+ AR="${AR}" \
+ LD="${LD}" \
+'
+
+EXTRA_OEMAKE += "\
+ 'DESTDIR=${D}' \
+"
+
+KERNEL_SELFTEST_SRC ?= "Makefile \
+ include \
+ tools \
+ scripts \
+ arch \
+ COPYING \
+"
+
+python __anonymous () {
+ import re
+
+ var = d.getVar('TARGET_CC_ARCH')
+ pattern = '_FORTIFY_SOURCE=[^0]'
+
+ if re.search(pattern, var):
+ d.appendVar('TARGET_CC_ARCH', " -O")
+}
+
+do_compile() {
+ for i in ${TEST_LIST}
+ do
+ oe_runmake -C ${S}/tools/testing/selftests/${i}
+ done
+}
+
+do_install() {
+ for i in ${TEST_LIST}
+ do
+ oe_runmake -C ${S}/tools/testing/selftests/${i} INSTALL_PATH=${D}/usr/kernel-selftest/${i} install
+ done
+
+ chown root:root -R ${D}/usr/kernel-selftest
+}
+
+do_configure() {
+ :
+}
+
+do_patch[prefuncs] += "copy_kselftest_source_from_kernel remove_clang_related"
+python copy_kselftest_source_from_kernel() {
+ sources = (d.getVar("KERNEL_SELFTEST_SRC") or "").split()
+ src_dir = d.getVar("STAGING_KERNEL_DIR")
+ dest_dir = d.getVar("S")
+ bb.utils.mkdirhier(dest_dir)
+ for s in sources:
+ src = oe.path.join(src_dir, s)
+ dest = oe.path.join(dest_dir, s)
+ if os.path.isdir(src):
+ oe.path.copytree(src, dest)
+ else:
+ bb.utils.copyfile(src, dest)
+}
+
+remove_clang_related() {
+ sed -i -e '/test_pkt_access/d' -e '/test_pkt_md_access/d' ${S}/tools/testing/selftests/bpf/Makefile
+}
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+INHIBIT_PACKAGE_DEBUG_SPLIT="1"
+FILES_${PN} += "/usr/kernel-selftest"