Re: [PATCH v3 1/3] rust: kunit: add #[should_panic] support
From: Rob Herring
Date: Wed Nov 18 2026 - 09:01:22 EST
On Fri, Nov 13, 2026 at 03:20:55PM -0300, Nicolás Antinori wrote:
> KUnit tests in Rust are written using user-space like syntax. This patch
> adds support for the `#[should_panic]` attribute, enabling the user to
> test conditions that are expected to cause a panic and report the test
> as successful.
>
> Signed-off-by: Nicolás Antinori <nico.antinori.7@xxxxxxxxx>
> ---
> Documentation/rust/testing.rst | 8 ++++-
> drivers/of/overlay_test.c | 6 +++-
Acked-by: Rob Herring (Arm) <robh@xxxxxxxxxx>
> include/kunit/test.h | 9 ++++-
> lib/kunit/attributes.c | 18 ++++++++++
> lib/kunit/kunit-test.c | 36 ++++++++++++++++----
> lib/kunit/platform-test.c | 6 +++-
> lib/kunit/string-stream-test.c | 9 ++++-
> lib/kunit/test.c | 10 ++++--
> rust/kernel/kunit.rs | 32 ++++++++++++++++++
> rust/kernel/lib.rs | 43 +++++++++++++++++++++--
> rust/macros/kunit.rs | 77 +++++++++++++++++++++++++++++-------------
> 11 files changed, 215 insertions(+), 39 deletions(-)