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

Petr Vorel
2023-11-03T14:58:32Z

Hi Cyril,

> Hi!
> > Yes, but see safe_cmd() in lib/tst_safe_macros.c. tst_cmd() is called with
> > TST_CMD_PASS_RETVAL | TST_CMD_TCONF_ON_MISSING, thus this is covered.

> TCONF_ON_MISSING means to TCONF when the command is missing, i.e. if
> modprobe is not installed on the system. When module is missing modprobe
> will return 1 so I suppose we have to handle the return value from the
> TST_CMD() or do I missing something?

Ah yes, you're right:
modprobe: FATAL: Module foo not found in directory /lib/modules/6.5.0-1-amd64
uevent02.c:134: TBROK: modprobe failed (1)

But unfortunately we will have to parse error log, because exit code is still 1 [1]:

return err >= 0 ? EXIT_SUCCESS : EXIT_FAILURE;

And indeed, although this would be expected:

# modprobe foo; echo $?
modprobe: FATAL: Module foo not found in directory /lib/modules/6.5.0-1-amd64
1

This would deserve different exit code:

$ modprobe dccp; echo $?
modprobe: ERROR: could not insert 'dccp': Operation not permitted
1

> > > modprobe -r please, rmmod has been deprecated for ages.

> > Ah, here goes the reason. Should it be replaced also in tst_module_unload_()?

> Yes please.

+1

Kind regards,
Petr

[1] https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/tools/modprobe.c#n1047