Re: [PATCH v5] char: misc: add test cases

From: Geert Uytterhoeven
Date: Wed Jul 30 2025 - 03:09:20 EST


Hi Thadeu,,

On Sun, 15 Jun 2025 at 23:31, Thadeu Lima de Souza Cascardo
<cascardo@xxxxxxxxxx> wrote:
>
> Add test cases for static and dynamic minor number allocation and
> deallocation.
>
> While at it, improve description and test suite name.
>
> Some of the cases include:
>
> - that static and dynamic allocation reserved the expected minors.
>
> - that registering duplicate minors or duplicate names will fail.
>
> - that failing to create a sysfs file (due to duplicate names) will
> deallocate the dynamic minor correctly.
>
> - that dynamic allocation does not allocate a minor number in the static
> range.
>
> - that there are no collisions when mixing dynamic and static allocations.
>
> - that opening devices with various minor device numbers work.
>
> - that registering a static number in the dynamic range won't conflict with
> a dynamic allocation.
>
> This last test verifies the bug fixed by commit 6d04d2b554b1 ("misc:
> misc_minor_alloc to use ida for all dynamic/misc dynamic minors") has not
> regressed.
>
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@xxxxxxxxxx>

Thanks for your patch, which is now commit 74d8361be3441dff ("char:
misc: add test cases") in linus/master stable/master

> Changes in v5:
> - Make miscdevice unit test built-in only
> - Make unit test require CONFIG_KUNIT=y

Why were these changes made? This means the test is no longer available
if KUNIT=m, and I can no longer just load the module when I want to
run the test.

> - Link to v4: https://lore.kernel.org/r/20250423-misc-dynrange-v4-0-133b5ae4ca18@xxxxxxxxxx

> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -2506,8 +2506,8 @@ config TEST_IDA
> tristate "Perform selftest on IDA functions"
>
> config TEST_MISC_MINOR
> - tristate "miscdevice KUnit test" if !KUNIT_ALL_TESTS
> - depends on KUNIT
> + bool "miscdevice KUnit test" if !KUNIT_ALL_TESTS
> + depends on KUNIT=y
> default KUNIT_ALL_TESTS
> help
> Kunit test for miscdevice API, specially its behavior in respect to

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