Re: [PATCH] lib: kunit: add list_sort test conversion to KUnit

From: Marco Elver
Date: Thu Aug 27 2020 - 06:23:46 EST


On Wed, Jul 29, 2020 at 04:23PM -0300, Vitor Massaru Iha wrote:
> This adds the conversion of the runtime tests of test_list_sort,
> from `lib/test_list_sort.c` to KUnit tests.
>
> Please apply this commit first (linux-kselftest/kunit-fixes):
> 3f37d14b8a3152441f36b6bc74000996679f0998 kunit: kunit_config: Fix parsing of CONFIG options with space
>
> Code Style Documentation: [0]
>
> Signed-off-by: Vitor Massaru Iha <vitor@xxxxxxxxxxx>
> Link: [0] https://lore.kernel.org/linux-kselftest/20200620054944.167330-1-davidgow@xxxxxxxxxx/T/#u
> ---
> lib/Kconfig.debug | 29 +++++---
> lib/Makefile | 2 +-
> lib/{test_list_sort.c => list_sort_kunit.c} | 73 +++++++++++----------
> 3 files changed, 58 insertions(+), 46 deletions(-)
> rename lib/{test_list_sort.c => list_sort_kunit.c} (62%)
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index 9ad9210d70a1..de4fd020a4af 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -1854,16 +1854,6 @@ config LKDTM
> Documentation on how to use the module can be found in
> Documentation/fault-injection/provoke-crashes.rst
>
> -config TEST_LIST_SORT
> - tristate "Linked list sorting test"
> - depends on DEBUG_KERNEL || m
> - help
> - Enable this to turn on 'list_sort()' function test. This test is
> - executed only once during system boot (so affects only boot time),
> - or at module load time.
> -
> - If unsure, say N.
> -
> config TEST_MIN_HEAP
> tristate "Min heap test"
> depends on DEBUG_KERNEL || m
> @@ -2173,6 +2163,25 @@ config LIST_KUNIT_TEST
>
> If unsure, say N.
>
> +config LIST_SORT_KUNIT
> + tristate "KUnit Linked list sorting test"
> + depends on KUNIT
> + depends on DEBUG_KERNEL || m

I think the style [0] you linked suggests '*_KUNIT_TEST' for config
variables.

Only noticed this because I was doing a

git grep 'config.*TEST'

to find tests in the kernel + new tests floating on the LKML.

Apologies for picking this patch to comment on, but if it's still
changeable it might be worth adjusting.

> + help
> + Enable this to turn on 'list_sort()' function test. This test is
> + executed only once during system boot (so affects only boot time),
> + or at module load time.
> +
> + KUnit tests run during boot and output the results to the debug log
> + in TAP format (http://testanything.org/). Only useful for kernel devs
> + running the KUnit test harness, and not intended for inclusion into a
> + production build.

Not a big deal, but I'm not sure if summarizing KUnit here is useful.
You already link to the documentation below.

> + For more information on KUnit and unit tests in general please refer
> + to the KUnit documentation in Documentation/dev-tools/kunit/.
...

Thanks,
-- Marco