Re: [PATCH v1 0/8] Run KUnit tests late and handle faults

David Gow
2024-03-01T07:15:21Z

[-- Attachment #1: Type: text/plain, Size: 3211 bytes --]

On Fri, 1 Mar 2024 at 01:04, Mickaël Salaün <mic@digikod.net> wrote:
>
> Hi,
>

Thanks very much. I think there's a lot going on in this series, and
it'd probably be easier to address if it were broken up a bit more.

To take things one at a time:

> This patch series moves KUnit test execution at the very end of kernel
> initialization, just before launching the init process. This opens the
> way to test any kernel code in its normal state (i.e. fully
> initialized).

I like the general idea here, but there are a few things to keep in mind:
- We can already do this with tests built as modules.
- We have explicit support for testing __init code, so if we want to
keep that (and I think we do), we'll need to make sure that there
remains a way to run tests before __init.
- Behaviour changes here will need to be documented and tested well
across all tests and architectures, so it's not something I'd want to
land quickly.
- The requirement to have a root filesystem set up is another thing
we'll want to handle carefully.
- As-is, the patch seems to break arm64.

>
> This patch series also teaches KUnit to handle kthread faults as errors,
> and it brings a few related fixes and improvements.

These seem very good overall. I want to look at the last location
stuff in a bit more detail, but otherwise this is okay.

Personally, I'd like to see this split out into a separate series,
partly because I don't want to delay it while we sort the other parts
of this series out, and partly because I have some other changes to
the thread context stuff I think we need to make.

>
> New tests check NULL pointer dereference and read-only memory, which
> wasn't possible before.

These look interesting, but I don't like that they are listed as x86-specific.

>
> This is useful to test current kernel self-protection mechanisms or
> future ones such as Heki: https://github.com/heki-linux
>
> Regards,

Thanks again. I'll do a more detailed review of the individual patches
next week, but I'm excited to see this overall.

Cheers,
-- David

>
> Mickaël Salaün (8):
> kunit: Run tests when the kernel is fully setup
> kunit: Handle thread creation error
> kunit: Fix kthread reference
> kunit: Fix timeout message
> kunit: Handle test faults
> kunit: Fix KUNIT_SUCCESS() calls in iov_iter tests
> kunit: Print last test location on fault
> kunit: Add tests for faults
>
> include/kunit/test.h | 24 +++++-
> include/kunit/try-catch.h | 3 -
> init/main.c | 4 +-
> lib/bitfield_kunit.c | 8 +-
> lib/checksum_kunit.c | 2 +-
> lib/kunit/executor.c | 81 ++++++++++++++------
> lib/kunit/kunit-example-test.c | 6 +-
> lib/kunit/kunit-test.c | 115 +++++++++++++++++++++++++++-
> lib/kunit/try-catch.c | 33 +++++---
> lib/kunit_iov_iter.c | 70 ++++++++---------
> tools/testing/kunit/kunit_kernel.py | 6 +-
> 11 files changed, 261 insertions(+), 91 deletions(-)
>
>
> base-commit: d206a76d7d2726f3b096037f2079ce0bd3ba329b
> --
> 2.44.0
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4014 bytes --]