kernelci / kernelci-project

KernelCI Linux Foundation project documentation
9 stars 26 forks source link

Standardize the way kernel's testing modules report results #414

Open musamaanjum opened 1 month ago

musamaanjum commented 1 month ago

We discussed that all kernel testing modules should use a standard way to report results. The log messages should be informative at the same time. Initially, we need to see which kind of logs are being outputted by the current models. Based on this, better improvements should be suggested.

Non-exhaustive list of test suites using test modules:

bpf, sparc
    <skip>
lib
    test_bitmap
    prime_numbers
    test_printf
    test_scanf
    test_strscpy
lkdm
    lkdtm module
lock
    test-ww_mutex module
net
    test_blackhole_dev
user
    test_user_copy
firmware
    test_firmware
static_keys
    test_static_key_base
    test_static_keys
memory-hotplug
    memory-notifier-error-inject
drivers
    test-drm_mm
fpu
    test_fpu
ntb
    ntb_msi_test
ftrace
    trace-printk
    ftrace-direct-too
rust
    rust_minimal
    rust_print

The kselftest only loads and unloads the module. It doesn't check the status of executed tests to decide if test passed or failed.

These tests can be divided into 2 categories of their dependence:

  1. tools/testing/selftests/kselftest_module.h and tools/testing/selftests/kselftest/module.sh provide a standard way to write a test module which can be loaded from kselftest. These modules are found in the lib/. One such example is lib test suite. It 5 tests. Each test just loads the test module and exits successfully. It doesn't check the status of the modules if the module test got passed or failed. Every test module has a separate config option to turn on and off.
  2. The second type of test modules are scattered around the kernel code. They are enabled by separate config options as needed. lkdtm suite is one example. Its module is found in the drivers/lkdtm.

musamaanjum commented 1 month ago

I've found an effort by Kees Cook where he has been converting such self-tests into kunit tests. This seems like the general direction for all kselftest test modules. I'll start a discussion thread.

musamaanjum commented 1 month ago

Started discussion upstream: https://lore.kernel.org/all/327831fb-47ab-4555-8f0b-19a8dbcaacd7@collabora.com

musamaanjum commented 1 month ago

Kees and David Gow agree that several of test modules are more suitable to run as kunit. Jhon Hubbard also jumped in and mentioned more such modules.

I'm pausing work on this ticket. I convert lib suite into kunit and so on. Once we convert several such test modules into kunit, we can come back to this ticket of improving the output of remaining modules.