Re: [PATCH v3] lib/random32: convert selftest to KUnit

From: Geert Uytterhoeven

Date: Mon Jun 29 2026 - 05:05:35 EST


Hi Kir,

Thanks for the update!

On Mon, 29 Jun 2026 at 07:42, Kir Chou <note351@xxxxxxxxxxx> wrote:
> This patch converts the existing prandom selftest (lib/random32.c) to use
> the KUnit framework (lib/tests/random32_kunit.c). Unlike typical KUnit
> tests, this file is directly #included into lib/random32.c.
>
> The new test:
> - Removes the legacy CONFIG_RANDOM32_SELFTEST from lib/random32.c.
> - Adds CONFIG_PRANDOM_KUNIT_TEST (defaulting to KUNIT_ALL_TESTS).
> - Moves the test logic to lib/tests/random32_kunit.c.
>
> v2:

The changelog belongs under the "---" under your SoB.

> - Removes the legacy CONFIG_RANDOM32_SELFTEST from lib/Kconfig.
> - Add const to arrays in lib/tests/random32_kunit.c.
>
> v3:
> - Changes from tristate to bool in lib/Kconfig.debug.

That's (IMHO very) unfortunate...

> --- a/lib/random32.c
> +++ b/lib/random32.c

> -core_initcall(prandom_state_selftest);
> +#ifdef CONFIG_PRANDOM_KUNIT_TEST
> +#include "tests/random32_kunit.c"
> #endif

I guess that is the reason?

Any reason why the actual test code cannot be spun-off into a separate
module, so it can become modular?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds