Hi ChenXiaoSong,
On Tue, 10 Feb 2026 at 10:53, ChenXiaoSong
<[email protected]> wrote:
> The KUnit test cases are only executed when the CONFIG_SMB_KUNIT_TESTS
> is enabled.
... which defaults to KUNIT_ALL_TESTS, so if KUNIT_ALL_TESTS is enabled,
the test is enabled by default, too.
> Making it a separate test module would require exporting local variables
> and functions so that the test code can access them. However, exporting
> local variables and functions would likely make the code much uglier, as
> it would require adding "#if" conditionals into the production code to
> isolate the test code.
>
> Geert, please let me know if you have a better idea.
>
> I am also discussing this with the ext4 community, and we all hope to
> find a way to make the tests a separate module.
There are ways to restrict exported symbols to test modules only,
see EXPORT_SYMBOL_FOR_TESTS_ONLY(), EXPORT_SYMBOL_FOR_MODULES(),
and EXPORT_SYMBOL_NS().
If it is really hard to convert the tests into a separate module,
you can add a new kernel/module parameter, which needs to be specified
explicitly to run the test. That would avoid running the tests when just
(auto)loading cifs.ko.
> On 2/10/26 4:10 PM, Geert Uytterhoeven wrote:
> > Thanks for your patch, which is now commit 480afcb19b61385d
> > ("smb/client: introduce KUnit test to check search result of
> > smb2_error_map_table") in linus/master
> >
> >> The KUnit test are executed when cifs.ko is loaded.
> > This means the tests are_always_ executed when cifs.ko is loaded,
> > which is different from how most other test modules work.
> > Please make it a separate test module, so it can be loaded independently
> > of the main cifs module. That way people can enable all tests in
> > production kernels, without affecting the system unless a test module
> > is actually loaded.
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