[LTP] [PATCH 2/4] lib: Add .modprobe

Li Wang liwang@redhat.com
Fri Oct 13 15:27:58 CEST 2023


On Fri, Oct 13, 2023 at 8:31 PM Petr Vorel <pvorel@suse.cz> wrote:

> Hi all,
>
> maybe .modprobe is too short name, but I'm not sure what would be better.
> Maybe .modprobe_module ?
>

.modprobe_module sounds better.

Also, I think that maybe we can support modprobe some
third-party modules (written by users) in test case, there are
a few managed by shell scripts, but if .modprobe_module
manages them unify in C, it would be nice for test variety.



>
> ...
> > +++ b/doc/C-Test-API.asciidoc
> > @@ -1609,6 +1609,11 @@ first missing driver.
> >  The detection is based on reading 'modules.dep' and 'modules.builtin'
> files
> >  generated by kmod. The check is skipped on Android.
>
> > +NULL terminated array '.modprobe' of kernel module names are tried to
> be loaded
> > +with 'modprobe' unless they are builtin or already loaded. Test exits
> with
> > +'TCONF' on first 'modprobe' non-zero exit. During cleanup are the
> modules
> > +loaded by the test unloaded with 'rmmod'.
>
> ...
>
> > +     if (tst_test->modprobe) {
> > +             const char *name;
> > +             int i;
> > +
> > +             for (i = 0; (name = tst_test->modprobe[i]); ++i) {
> > +                     /* only load module if not already loaded */
> > +                     if (!module_loaded(name) &&
> tst_check_builtin_driver(name)) {
>
> Also we could make it independent on modules.builtin (NixOS based problem -
> missing these files). I.e. we would keep only module_loaded(), remove
> tst_check_builtin_driver(). But then we could not run rmmod / modprobe -r,
> or we would have to ignore it's exit code (rmmod on builtin module) fails.
>

Or we add one step to detect modules.builtin file, if no,
then just print a Warning at unload in fails?



>
> Kind regards,
> Petr
>
> > +                             const char *const cmd_modprobe[] =
> {"modprobe", name, NULL};
> > +                             SAFE_CMD(cmd_modprobe, NULL, NULL);
> > +                             modules_loaded[i] = 1;
> > +                     }
> > +             }
> > +     }
> > +
>
>

-- 
Regards,
Li Wang


More information about the ltp mailing list