On Wed, Jul 30, 2025 at 09:08:57AM +0200, Geert Uytterhoeven wrote: > Hi Thadeu,, > > On Sun, 15 Jun 2025 at 23:31, Thadeu Lima de Souza Cascardo > <[email protected]> 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 <[email protected]> > > 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. >
These were made because a bug was found that devices with minor > 255 could not be opened. So I added a test for that, which used __init functions, so the test now had to be built-in. The alternative is to make these functions not __init anymore and export them. Those functions are init_mknod and init_unlink. I will see if I can cook an RFC later today. Cascardo. > > - Link to v4: > > https://lore.kernel.org/r/[email protected] > > > --- 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 -- > [email protected] > > 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

