KernelModuleUtils

public class KernelModuleUtils
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.KernelModuleUtils


Summary

Public constructors

KernelModuleUtils()

Public methods

static String[] getDependentModules(String modName, String lsmodOutput)

Return the names of the modules that the given module depends on.

static String getDisplayedModuleName(String fullPath)

Return module name as it's displayed after loading.

static void installModule(ITestDevice device, String modulePath, String arg, long timeoutMs)

Install a kernel module on the given device.

static String removeKoExtension(String s)

Remove `.ko` extension if present

static void removeModule(ITestDevice device, String module)

Remove a kernel module and dependent modules from the given device.

Public constructors

KernelModuleUtils

public KernelModuleUtils ()

Public methods

getDependentModules

public static String[] getDependentModules (String modName, 
                String lsmodOutput)

Return the names of the modules that the given module depends on.

For example, if the given module is `kunit`, and the `lsmod` output is:

$ lsmod
 Module        Size    Used by
 kunit_test    663552  0
 time_test     663558  0
 kunit         57344   15 kunit_test,time_test
 
Then this method will return an array containing `kunit_test` and `time_test`.

Parameters
modName String

lsmodOutput String

Returns
String[]

getDisplayedModuleName

public static String getDisplayedModuleName (String fullPath)

Return module name as it's displayed after loading.

For example, see the difference between the file name and that returned by `lsmod`:

$ insmod kunit.ko
 $ lsmod | grep kunit
 kunit 20480 0
 

Parameters
fullPath String

Returns
String

installModule

public static void installModule (ITestDevice device, 
                String modulePath, 
                String arg, 
                long timeoutMs)

Install a kernel module on the given device.

Parameters
device ITestDevice: the device to install the module on

modulePath String: the path to the module to install

arg String: the argument to pass to the install command

timeoutMs long: the timeout in milliseconds

Throws
TargetSetupError if the module cannot be installed
DeviceNotAvailableException if the device is not available

removeKoExtension

public static String removeKoExtension (String s)

Remove `.ko` extension if present

Parameters
s String

Returns
String

removeModule

public static void removeModule (ITestDevice device, 
                String module)

Remove a kernel module and dependent modules from the given device.

This method attempts to remove the target kernel module from the device. If the module has any dependencies, those dependent modules will be removed before the target module with best effort.

Parameters
device ITestDevice: the device to remove the module from

module String: the name or the path to the module to remove

Throws
DeviceNotAvailableException if the device is not available