diff options
Diffstat (limited to 'debian/tests')
-rw-r--r-- | debian/tests/control | 14 | ||||
-rw-r--r-- | debian/tests/kbuild | 58 | ||||
-rwxr-xr-x | debian/tests/python | 11 | ||||
-rw-r--r-- | debian/tests/selftests | 88 |
4 files changed, 171 insertions, 0 deletions
diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 000000000..25c61c0ec --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,14 @@ +Tests: python +Restrictions: superficial +Depends: python3 + +Tests: selftests +Restrictions: breaks-testbed, needs-root, isolation-machine +Depends: kexec-tools, python3, gcc, make, libpopt-dev, gcc-multilib [amd64], bc, fuse, libfuse-dev, pkg-config, linux-image-6.1.0-18-alpha-generic [alpha], linux-image-6.1.0-18-alpha-smp [alpha], linux-image-6.1.0-18-amd64-unsigned [amd64], linux-image-6.1.0-18-cloud-amd64-unsigned [amd64], linux-image-6.1.0-18-rt-amd64-unsigned [amd64], linux-image-6.1.0-18-arm64-unsigned [arm64], linux-image-6.1.0-18-cloud-arm64-unsigned [arm64], linux-image-6.1.0-18-rt-arm64-unsigned [arm64], linux-image-6.1.0-18-marvell [armel], linux-image-6.1.0-18-rpi [armel], linux-image-6.1.0-18-armmp [armhf], linux-image-6.1.0-18-armmp-lpae [armhf], linux-image-6.1.0-18-rt-armmp [armhf], linux-image-6.1.0-18-parisc [hppa], linux-image-6.1.0-18-parisc64 [hppa], linux-image-6.1.0-18-686-unsigned [i386], linux-image-6.1.0-18-686-pae-unsigned [i386], linux-image-6.1.0-18-rt-686-pae-unsigned [i386], linux-image-6.1.0-18-itanium [ia64], linux-image-6.1.0-18-mckinley [ia64], linux-image-6.1.0-18-m68k [m68k], linux-image-6.1.0-18-4kc-malta [mips mipsel], linux-image-6.1.0-18-mips32r2eb [mips], linux-image-6.1.0-18-octeon [mips mips64 mips64el mipsel], linux-image-6.1.0-18-5kc-malta [mips64 mips64el], linux-image-6.1.0-18-mips64r2eb [mips64], linux-image-6.1.0-18-mips64r2el [mips64el], linux-image-6.1.0-18-loongson-3 [mips64el mipsel], linux-image-6.1.0-18-mips64r6eb [mips64r6], linux-image-6.1.0-18-mips64r6el [mips64r6el], linux-image-6.1.0-18-mips32r2el [mipsel], linux-image-6.1.0-18-mips32r6eb [mipsr6], linux-image-6.1.0-18-mips32r6el [mipsr6el], linux-image-6.1.0-18-powerpc [powerpc], linux-image-6.1.0-18-powerpc-smp [powerpc], linux-image-6.1.0-18-powerpc64 [powerpc ppc64], linux-image-6.1.0-18-powerpc64le [ppc64el], linux-image-6.1.0-18-riscv64 [riscv64], linux-image-6.1.0-18-s390x [s390x], linux-image-6.1.0-18-sh7751r [sh4], linux-image-6.1.0-18-sh7785lcr [sh4], linux-image-6.1.0-18-sparc64 [sparc64], linux-image-6.1.0-18-sparc64-smp [sparc64] +Classes: smp + +Tests: kbuild +Architecture: alpha amd64 arm64 armhf hppa i386 ia64 m68k ppc64 ppc64el riscv64 s390x sparc64 +Restrictions: superficial +Depends: python3, linux-headers-6.1.0-18-alpha-smp [alpha], linux-headers-6.1.0-18-cloud-amd64 [amd64], linux-headers-6.1.0-18-cloud-arm64 [arm64], linux-headers-6.1.0-18-armmp [armhf], linux-headers-6.1.0-18-parisc [hppa], linux-headers-6.1.0-18-686-pae [i386], linux-headers-6.1.0-18-itanium [ia64], linux-headers-6.1.0-18-m68k [m68k], linux-headers-6.1.0-18-powerpc64 [ppc64], linux-headers-6.1.0-18-powerpc64le [ppc64el], linux-headers-6.1.0-18-riscv64 [riscv64], linux-headers-6.1.0-18-s390x [s390x], linux-headers-6.1.0-18-sparc64-smp [sparc64] + diff --git a/debian/tests/kbuild b/debian/tests/kbuild new file mode 100644 index 000000000..18cbe214e --- /dev/null +++ b/debian/tests/kbuild @@ -0,0 +1,58 @@ +#!/bin/sh -eu + +mkdir "$AUTOPKGTEST_TMP"/foo +cat >"$AUTOPKGTEST_TMP"/foo/foo.c <<EOF +#include <linux/kernel.h> +#include <linux/module.h> + +static int __init foo_init(void) +{ + pr_info("foo initialised\n"); + return 0; +} +module_init(foo_init); + +static void __exit foo_exit(void) +{ +} +module_exit(foo_exit); + +MODULE_LICENSE("GPL"); +EOF +cat >"$AUTOPKGTEST_TMP"/foo/Kbuild <<EOF +obj-m += foo.o +EOF + +arch="$(dpkg --print-architecture)" +abiname="$(debian/bin/getconfig.py version abiname)" +if flavour="$(debian/bin/getconfig.py base $arch none quick-flavour)"; then + echo "I: Found quick flavour $flavour" +elif flavour="$(debian/bin/getconfig.py base $arch none default-flavour)"; then + echo "I: Found default flavour $flavour" +elif flavour="$(debian/bin/getconfig.py base $arch default-flavour)"; then + echo "I: Found default flavour $flavour" +else + echo >&2 "E: Failed to find quick or default flavour" + exit 1 +fi +release="$abiname-$flavour" + +echo "I: Build for $release" +# There are some warnings sent to stderr that we need to suppress, +# but any other output to stderr should be treated as a failure. +# We also want all stdout/stderr to appear in order in the log. +# First, duplicate stdout to fd 3 +exec 3>&1 +# Next, run the build with stdout sent to the original stdout and +# stderr sent through tee to both the original stdout and a file +make -C /lib/modules/"$release"/build M="$AUTOPKGTEST_TMP"/foo V=1 \ + 2>&1 1>&3 | tee "$AUTOPKGTEST_TMP"/foo/make.stderr +# Close fd 3 +exec 3>&- +# Check for any stderr output that doesn't match the suppressions +if grep -q -v -E 'Skipping BTF generation .* due to unavailability of vmlinux' "$AUTOPKGTEST_TMP"/foo/make.stderr; then + echo >&2 "E: Unexpected warning/error messages" +fi + +echo "I: Clean" +make -C /lib/modules/"$release"/build M="$AUTOPKGTEST_TMP"/foo V=1 clean diff --git a/debian/tests/python b/debian/tests/python new file mode 100755 index 000000000..afd36de97 --- /dev/null +++ b/debian/tests/python @@ -0,0 +1,11 @@ +#!/bin/bash -eu + +# autopkgtest checks for a non-zero exit code *or* any output to +# stderr. So we should continue after a failure, but make sure +# something is written to stderr. + +echo "I: Running debian_linux.debian unit tests..." +# unittest only writes to stderr +if ! PYTHONPATH=debian/lib/python python3 -m debian_linux.debian 2>&1; then + echo >&2 "E: some unit tests failed" +fi diff --git a/debian/tests/selftests b/debian/tests/selftests new file mode 100644 index 000000000..02cc29372 --- /dev/null +++ b/debian/tests/selftests @@ -0,0 +1,88 @@ +#!/bin/bash -eu + +PATH=/usr/sbin:/sbin:/usr/bin:/bin + +getconfig() { + debian/bin/getconfig.py "$@" +} + +# Look up current ABI name and 'localversion' (featureset/flavour) suffixes +abiname=$(getconfig version abiname) +arch=$(dpkg --print-architecture) +localversion=() +for featureset in $(getconfig base $arch featuresets); do + if [ "$(getconfig base '' $featureset enabled || echo True)" = True ]; then + for flavour in $(getconfig base $arch $featureset flavours); do + if [ "$featureset" = none ]; then + localversion+=(-$flavour) + else + localversion+=(-$featureset-$flavour) + fi + done + fi +done +steps=${#localversion[*]} + +case "${ADT_REBOOT_MARK:-}" in + "") + step=-1 + ;; + step*) + step=${ADT_REBOOT_MARK#step} + ;; +esac + +if [ "$step" -ge 0 ]; then + ver=$abiname${localversion[$step]} + + if [ "$(uname -r)" != "$ver" ]; then + echo >&2 "Should be running: $ver" + echo >&2 "Actually running: $(uname -r)" + else + cp -lR . $AUTOPKGTEST_TMP/build + cd $AUTOPKGTEST_TMP/build + make headers_install + + # Ignore compiler warnings + { + make -C tools/testing/selftests && + make -C tools/testing/selftests/memfd build_fuse + } 2>&1 || echo >&2 "Build failed" + + # Enable testing CLONE_USERNS by unprivileged users + sysctl kernel.unprivileged_userns_clone=1 + + # Some tests will write to stderr despite being successful, + # and the exit code from make will be 0 even if tests failed. + # So we have to do some post-analysis... + set -o pipefail + { + make -C tools/testing/selftests quicktest=1 run_tests && + make -C tools/testing/selftests/cpu-hotplug run_full_test && + make -C tools/testing/selftests/memory-hotplug run_full_test && + make -C tools/testing/selftests/memfd run_fuse && + make -C tools/testing/selftests/timers run_destructive_tests + } 2>&1 | tee $AUTOPKGTEST_TMP/log + set +o pipefail + if grep -E '\[(FAIL|UNSUPPORTED)\]|recipe for target .run_tests. failed' $AUTOPKGTEST_TMP/log | \ + grep -q -v \ + -e '^selftests: fw_userhelper.sh \[FAIL\]' \ + -e 'ftrace - function profiler with function tracing \[UNSUPPORTED\]' \ + -e '^selftests: ftracetest \[FAIL\]' \ + -e '|| echo .*\[FAIL\]' \ + ; then + echo >&2 "Unexpected failures found" + fi + fi +fi + +step=$((step + 1)) + +if [ "$step" -lt "$steps" ]; then + # Load the next kernel + ver=$abiname${localversion[$step]} + kexec -l /boot/vmlinuz-$ver --initrd /boot/initrd.img-$ver --reuse-cmdline + /tmp/autopkgtest-reboot step$step +fi + +exit 0 |