Re: [PATCH v5 2/2] lib/prime_numbers: convert self-test to KUnit

From: Kees Cook
Date: Mon Feb 10 2025 - 21:37:31 EST


On Sat, Feb 08, 2025 at 09:44:39PM -0500, Tamir Duberstein wrote:
> Extract a private header and convert the prime_numbers self-test to a
> KUnit test. I considered parameterizing the test using
> `KUNIT_CASE_PARAM` but didn't see how it was possible since the test
> logic is entangled with the test parameter generation logic.
>
> Signed-off-by: Tamir Duberstein <tamird@xxxxxxxxx>
> ---
> lib/Kconfig.debug | 14 +++++
> lib/math/prime_numbers.c | 87 +++++-----------------------
> lib/math/prime_numbers_private.h | 17 ++++++
> lib/math/tests/Makefile | 1 +
> lib/math/tests/prime_numbers_kunit.c | 59 +++++++++++++++++++
> tools/testing/selftests/lib/config | 1 -
> tools/testing/selftests/lib/prime_numbers.sh | 4 --
> 7 files changed, 106 insertions(+), 77 deletions(-)

Thanks! I've applied this and rebased it onto:
https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=for-next/move-kunit-tests

--
Kees Cook