Re: [PATCH v6 1/2] rust: allocator: add KUnit tests for alignment guarantees
From: Hui Zhu
Date: Wed Jul 30 2025 - 22:54:32 EST
2025年7月30日 17:16, "Miguel Ojeda" <miguel.ojeda.sandonis@xxxxxxxxx mailto:miguel.ojeda.sandonis@xxxxxxxxx?to=%22Miguel%20Ojeda%22%20%3Cmiguel.ojeda.sandonis%40gmail.com%3E > 写到:
>
> On Wed, Jul 30, 2025 at 5:37 AM Hui Zhu <hui.zhu@xxxxxxxxx> wrote:
>
> >
> > +#[macros::kunit_tests(rust_allocator_kunit)]
> >
> Is there any reason for the `_kunit` suffix? If not, then we should
> avoid suffixing `_kunit` to every suite name.
>
> I see we already have `rust_kernel_kunit`, but that one is because it
> is the KUnit file itself.
>
> There is also `rust_kvec_kunit`, but we should clean that one up.
>
> >
> > + fn test_alignment() -> Result<()> {
> >
> `-> Result` since the prelude is available.
>
> >
> > + fn alignment_valid(&self, align: usize) -> bool {
> >
> We typically prefix these with `is_`.
>
> I would also call it `is_aligned_to`, to match the upstream Rust one,
> which we could perhaps use if it becomes stable.
>
Hi Miguel,
I sent the v7 version according to your comments.
Thanks,
Hui
> Cheers,
> Miguel
>