Re: [PATCH 0/3] rust: kunit: support #[should_panic] and same test name with different #[cfg(...)]

From: Nicolás Antinori

Date: Thu Oct 01 2026 - 10:15:04 EST


On Wed Sep 30, 2026 at 11:54 AM -03, Gary Guo wrote:
> On Wed Sep 30, 2026 at 2:23 PM BST, Nicolás Antinori via B4 Relay wrote:
>> This patch series intends to implement two features for KUnit tests
>> written in Rust. The work is based on a TODO comment made in the
>> `bitmap.rs` module [1].
>>
>> Changelog:
>> - RFC patch: [3]
>>
>> 1. Supporting `#[should_panic]` [2]:
>>
>> KUnit tests in Rust follow the user-space syntax, but at the moment
>> `#[should_panic]` is not supported. The first patch of this series adds
>> support for the attribute (only in its basic form, `#[should_panic =
>> "message"]` is not supported yet).
>>
>> The way it is supported is by adding a new boolean property called
>> `rust_should_panic` to `kunit_attributes` struct in kunit/test.h and
>
> This is now more general than Rust panics? Perhaps this should just be
> "should_bug"?

I used the name suggested by David Gow in the RFC Patch [1]. I believe
"should_panic" is better because it directly matches the attribute name
and will stay consistent in case the panic handler changes the way it
trigger kernel panics (although this is very unlikely I think).

That said, I'd be happy to change it to should_bug if that is preferred,
please let me know what you think!

Best regards,
Nicolás

[1] https://lore.kernel.org/rust-for-linux/d20cc2b2-afeb-432c-924b-55ad00d980fe@xxxxxxxxxxxx/