[PATCH v2 0/2] kunit: add optional assertions to catch taint and lockdep warnings
Malte Wechter <[email protected]>
| Newsgroups | org.kernel.vger.rust-for-linux,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest |
|---|---|
| Message-ID | <[email protected]> |
this patch tries to expand KUnit by using existing kernel diagnostics to catch certain locking related bugs. Specifically this adds assertions for `debug_locks` from `lockdep` and the `TAINT_WARN` flag from `panic`. This tries to prevent bugs as: circular locking dependency and sleeping function called from invalid context. Add config CONFIG_KUNIT_EXTRA_ASSERTS that enables extra assertions to be emitted: First, before _any_ KUnit test suite is ran, this is to ensure that the extra assertions are triggered by a KUnit test and not prior. Secondly, assertions a made for each test case, failing them if the assertions fail, even if the KUnit test is marked as passed. Signed-off-by: Malte Wechter <[email protected]> --- Changes in v2: - Implement changes directly in C KUnit instead of Rust KUnit wrapper - Remove rust specific configs and add general CONFIG_KUNIT_EXTRA_ASSERTS config - Link to v1: https://patch.msgid.link/[email protected] To: Brendan Higgins <[email protected]> To: David Gow <[email protected]> To: Rae Moar <[email protected]> To: Miguel Ojeda <[email protected]> To: Boqun Feng <[email protected]> To: Gary Guo <[email protected]> To: Björn Roy Baron <[email protected]> To: Benno Lossin <[email protected]> To: Andreas Hindborg <[email protected]> To: Alice Ryhl <[email protected]> To: Trevor Gross <[email protected]> To: Danilo Krummrich <[email protected]> To: Daniel Almeida <[email protected]> To: Tamir Duberstein <[email protected]> To: Alexandre Courbot <[email protected]> To: Onur Özkan <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] --- Malte Wechter (2): kunit: add extra assertions to KUnit test cases kunit: add KUnit test to assert kernel state before KUnit suites are run lib/kunit/Kconfig | 12 ++++++++++++ lib/kunit/executor.c | 8 +++++++- lib/kunit/test.c | 30 ++++++++++++++++++++++++++++++ lib/kunit/try-catch.c | 23 ++++++++++++++++++++++- 4 files changed, 71 insertions(+), 2 deletions(-) --- base-commit: 8cdeaa50eae8dad34885515f62559ee83e7e8dda change-id: 20260812-lockdep-kunit-9628f4bcad90 Best regards, -- Malte Wechter <[email protected]>