From: "Nicolás Antinori" <nico.antinori.7@gmail.com>
To: "David Gow" <david@davidgow.net>,
"Alice Ryhl" <aliceryhl@google.com>,
"Benno Lossin" <lossin@kernel.org>,
"Boqun Feng" <boqun@kernel.org>,
"Brendan Higgins" <brendan.higgins@linux.dev>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Gary Guo" <gary@garyguo.net>, "Miguel Ojeda" <ojeda@kernel.org>,
"Onur Özkan" <work@onurozkan.dev>
Cc: "Shuah Khan" <skhan@linuxfoundation.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Burak Emir" <burak.emir@gmail.com>,
"Rae Moar" <raemoar63@gmail.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Yury Norov" <yury.norov@gmail.com>,
kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: Re: [PATCH v3 1/3] rust: kunit: add #[should_panic] support
Date: Thu, 26 Nov 2026 12:16:18 -0300 [thread overview]
Message-ID: <DN58PQ0UNTCV.2C8E5QAXJ53I7@gmail.com> (raw)
In-Reply-To: <0e68f60e-e9e0-4443-8189-72180ff07a14@davidgow.net>
On Mon Nov 23, 2026 at 10:36 AM -03, David Gow wrote:
> Le 14/11/2026 à 02:20, 'Nicolás Antinori via B4 Relay' via KUnit
> Development a écrit :
>> From: Nicolás Antinori <nico.antinori.7@gmail.com>
>>
>> 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@gmail.com>
>> ---
>
> Okay -- this looks good to go to me. Thanks very much for all of your
> effort!
Thank you for the reviews and explanations! I'll be sending the
implementation for `#[should_panic = "message"]` once this lands.
There's a sashiko observation [1] but I dismissed it because before this
patch `KUNIT_ASSERT_NOT_ERR_OR_NULL` already aborted before setting
`priv` and executing `kunit_init_test` and `kunit_resource_test_exit`
performed the frees without any check. I assume that this is acceptable
in this context, but let me know otherwise!
> I'm not 100% happy with how pushing the attributes into struct kunit has
> balooned into all of the different kunit_init_test() call, but I think
> all of the other options are either worse, or involve even more invasive
> refactoring. (That being said, I do think this might be the thing which
> finally makes me look into refactoring how we handle the struct kunit /
> struct kunit_case dichotomy better... :-))
Yes, this was tricky! The alternative I thought was setting attrs
directly when declaring `struct kunit ...` (right before the two calls
of `kunit_init_test` in `test.c`) but I was not sure if it was the right
place (we would have avoided passing the attrs in all the calls if I am
not mistaken though).
Regards,
Nicolás
[1] https://sashiko.dev/#/patchset/20261113-rust_kunit_v6_send-v3-0-0d7832c07166@gmail.com?part=1
next prev parent reply other threads:[~2026-11-26 15:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 18:20 [PATCH v3 0/3] rust: kunit: support #[should_panic] and same test name with different #[cfg(...)] Nicolás Antinori via B4 Relay
2026-11-13 18:20 ` [PATCH v3 1/3] rust: kunit: add #[should_panic] support Nicolás Antinori via B4 Relay
2026-11-18 14:01 ` Rob Herring
2026-11-23 13:36 ` David Gow
2026-11-26 15:16 ` Nicolás Antinori [this message]
2026-11-13 18:20 ` [PATCH v3 2/3] rust: kunit: allow same test name with different #[cfg(...)] Nicolás Antinori via B4 Relay
2026-11-13 18:20 ` [PATCH v3 3/3] rust: bitmap: kunit: uncomment owned_bitmap_out_of_bounds panic case Nicolás Antinori via B4 Relay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DN58PQ0UNTCV.2C8E5QAXJ53I7@gmail.com \
--to=nico.antinori.7@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=brendan.higgins@linux.dev \
--cc=burak.emir@gmail.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=david@davidgow.net \
--cc=gary@garyguo.net \
--cc=kunit-dev@googlegroups.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=raemoar63@gmail.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox