[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260130091838-33f432c5-8a36-4844-aa8c-bd71b7470f52@linutronix.de>
Date: Fri, 30 Jan 2026 09:23:45 +0100
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: Kir Chou <note351@...mail.com>
Cc: akpm@...ux-foundation.org, davidgow@...gle.com, geert@...ux-m68k.org,
visitorckw@...il.com, brendan.higgins@...ux.dev, linux-kselftest@...r.kernel.org,
kunit-dev@...glegroups.com, Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>, Alexander Gordeev <agordeev@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>, Sven Schnelle <svens@...ux.ibm.com>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
"open list:S390 ARCHITECTURE" <linux-s390@...r.kernel.org>, open list <linux-kernel@...r.kernel.org>,
"open list:NETWORKING [GENERAL]" <netdev@...r.kernel.org>
Subject: Re: [PATCH] lib/random32: convert selftest to KUnit
On Sat, Jan 24, 2026 at 02:41:33PM +0900, Kir Chou 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.
>
> Only the file name "random32_kunit.c" keeps random32, "prandom" is used
> for all other places for aligning with the API semantics and avoiding
> confusion with the cryptographically secure random.c,
>
> The new test:
> - Removes the legacy CONFIG_RANDOM32_SELFTEST.
This bit seems to be missing from the patch.
'config RANDOM32_SELFTEST' still exists in lib/Kconfig.
> - Adds CONFIG_PRANDOM_KUNIT_TEST (defaulting to KUNIT_ALL_TESTS).
> - Moves the test logic to lib/tests/random32_kunit.c.
> - Updates arch/s390/configs/debug_defconfig to use the new KUnit symbol.
>
> This commit is verified by `./tools/testing/kunit/kunit.py run`
> with the .kunit/.kunitconfig:
>
> ```
> CONFIG_KUNIT=y
> CONFIG_PRANDOM_KUNIT_TEST=y
> ```
>
> Signed-off-by: Kir Chou <note351@...mail.com>
> ---
> arch/s390/configs/debug_defconfig | 2 +-
> lib/Kconfig.debug | 12 +++
> lib/random32.c | 173 +----------------------------
> lib/tests/random32_kunit.c | 174 ++++++++++++++++++++++++++++++
> 4 files changed, 189 insertions(+), 172 deletions(-)
> create mode 100644 lib/tests/random32_kunit.c
>
(...)
> diff --git a/lib/tests/random32_kunit.c b/lib/tests/random32_kunit.c
> new file mode 100644
> index 000000000..ee50205b8
> --- /dev/null
> +++ b/lib/tests/random32_kunit.c
> @@ -0,0 +1,174 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Test cases for random32 functions.
> + */
> +
> +#include <kunit/test.h>
> +
> +static struct prandom_test1 {
> + u32 seed;
> + u32 result;
> +} test1[] = {
> + { 1U, 3484351685U },
> + { 2U, 2623130059U },
> + { 3U, 3125133893U },
> + { 4U, 984847254U },
> +};
> +
> +static struct prandom_test2 {
These arrays can be 'const'.
> + u32 seed;
> + u32 iteration;
> + u32 result;
> +} test2[] = {
(...)
Powered by blists - more mailing lists