The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 0/2] kunit: add optional assertions to catch taint and lockdep warnings
@ 2026-08-24 13:32 Malte Wechter
  2026-08-24 13:32 ` [PATCH v2 1/2] kunit: add extra assertions to KUnit test cases Malte Wechter
  2026-08-24 13:32 ` [PATCH v2 2/2] kunit: add KUnit test to assert kernel state before KUnit suites are run Malte Wechter
  0 siblings, 2 replies; 5+ messages in thread
From: Malte Wechter @ 2026-08-24 13:32 UTC (permalink / raw)
  To: Brendan Higgins, David Gow, Rae Moar, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan
  Cc: linux-kselftest, kunit-dev, linux-kernel, rust-for-linux,
	Malte Wechter

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 <maltewechter@gmail.com>
---
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/20260818-lockdep-kunit-v1-0-66ceb1a272e3@gmail.com

To: Brendan Higgins <brendan.higgins@linux.dev>
To: David Gow <david@davidgow.net>
To: Rae Moar <raemoar63@gmail.com>
To: Miguel Ojeda <ojeda@kernel.org>
To: Boqun Feng <boqun@kernel.org>
To: Gary Guo <gary@garyguo.net>
To: Björn Roy Baron <bjorn3_gh@protonmail.com>
To: Benno Lossin <lossin@kernel.org>
To: Andreas Hindborg <a.hindborg@kernel.org>
To: Alice Ryhl <aliceryhl@google.com>
To: Trevor Gross <tmgross@umich.edu>
To: Danilo Krummrich <dakr@kernel.org>
To: Daniel Almeida <daniel.almeida@collabora.com>
To: Tamir Duberstein <tamird@kernel.org>
To: Alexandre Courbot <acourbot@nvidia.com>
To: Onur Özkan <work@onurozkan.dev>
Cc: linux-kselftest@vger.kernel.org
Cc: kunit-dev@googlegroups.com
Cc: linux-kernel@vger.kernel.org
Cc: rust-for-linux@vger.kernel.org

---
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 <maltewechter@gmail.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-25 11:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24 13:32 [PATCH v2 0/2] kunit: add optional assertions to catch taint and lockdep warnings Malte Wechter
2026-08-24 13:32 ` [PATCH v2 1/2] kunit: add extra assertions to KUnit test cases Malte Wechter
2026-08-25 11:00   ` David Gow
2026-08-24 13:32 ` [PATCH v2 2/2] kunit: add KUnit test to assert kernel state before KUnit suites are run Malte Wechter
2026-08-25 11:00   ` David Gow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox