diff --git a/meta-arm-gcs/gcs.yml b/meta-arm-gcs/gcs.yml index d3dcb17e..094f0808 100644 --- a/meta-arm-gcs/gcs.yml +++ b/meta-arm-gcs/gcs.yml @@ -53,7 +53,7 @@ local_conf_header: IMAGE_CLASSES += "testimage" TEST_SUITES = "ping ssh gcs" IMAGE_FEATURES += "ssh-server-dropbear" - CORE_IMAGE_EXTRA_INSTALL += "ssh-pregen-hostkeys binutils" + CORE_IMAGE_EXTRA_INSTALL += "ssh-pregen-hostkeys binutils kselftest" target: - core-image-full-cmdline diff --git a/meta-arm-gcs/lib/oeqa/runtime/cases/gcs.py b/meta-arm-gcs/lib/oeqa/runtime/cases/gcs.py index 1dc7d39e..3e9a676d 100644 --- a/meta-arm-gcs/lib/oeqa/runtime/cases/gcs.py +++ b/meta-arm-gcs/lib/oeqa/runtime/cases/gcs.py @@ -2,14 +2,13 @@ # SPDX-License-Identifier: MIT # +import unittest + from oeqa.runtime.case import OERuntimeTestCase from oeqa.runtime.decorator.package import OEHasPackage class GCSTests(OERuntimeTestCase): - # TODO: - # - Need a test that fails if GCS is enabled. kselftest most likely has tests here? - def test_dmesg(self): """ Verify that the kernel detected the GCS processor feature. @@ -47,3 +46,23 @@ class GCSTests(OERuntimeTestCase): status, output = self.target.run(cmd) self.assertEqual(status, 0, f"ls failed: {output}") self.assertEqual(output, "/usr") + + + @OEHasPackage(['kselftest']) + @unittest.expectedFailure + def test_kselftest(self): + """ + Run the GCS tests in the kselftest. + """ + cmd = """ + cd /usr/libexec/kselftest; \ + ./run_kselftest.sh $(./run_kselftest.sh -l | awk -e '/arm64.*gcs/ { print "-t " $1 }') \ + """ + status, output = self.target.run(cmd) + + # kselftest normally returns 0 even if tests fail, so a failure here is serious + self.assertEqual(status, 0, f"kselftest failed: {output}") + + # Identify any test failure lines, and assert that the list is empty + fails = [l for l in output.splitlines() if "not ok " in l] + self.assertFalse(fails) diff --git a/meta-arm-gcs/recipes-kernel/linux/kselftest.bb b/meta-arm-gcs/recipes-kernel/linux/kselftest.bb new file mode 100644 index 00000000..3b515121 --- /dev/null +++ b/meta-arm-gcs/recipes-kernel/linux/kselftest.bb @@ -0,0 +1,51 @@ +SUMMARY = "kselftest, the kernel test suite" +SECTION = "kernel" +LICENSE = "GPL-2.0-only" + +DEPENDS = "rsync-native alsa-lib libcap libcap-ng numactl popt libmnl" + +inherit kernelsrc kernel-arch + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +B = "${WORKDIR}/build" + +do_compile[cleandirs] = "${B}" + +CC:remove:aarch64 = "-mbranch-protection=standard" +SECURITY_CFLAGS = "" + +# Disable BPF and HID as they need clang for BPF compilation +SKIP_TARGETS ?= "bpf hid" + +EXTRA_OEMAKE += "\ + O=${B} \ + V=1 \ + ARCH=${ARCH} \ + CROSS_COMPILE=${TARGET_PREFIX} \ + CC="${CC}" \ + AR="${AR}" \ + LD="${LD}" \ + KHDR_INCLUDES="-isystem ${STAGING_KERNEL_BUILDDIR}" \ + SKIP_TARGETS="${SKIP_TARGETS}" \ +" + +# Force all tests to build successfully +#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 + chown -R root:root ${D}/${libexecdir}/kselftest +} + +RDEPENDS:${PN} += "bash python3-core python3 perl perl-module-io-handle" + +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INSANE_SKIP:${PN} = "already-stripped buildpaths ldflags textrel" + +# TODO test with musl