diff --git a/wlauto/commands/record.py b/wlauto/commands/record.py index 2fc640aa..ae6e2ab1 100644 --- a/wlauto/commands/record.py +++ b/wlauto/commands/record.py @@ -158,6 +158,7 @@ class ReplayCommand(RecordCommand): self.device.execute(command) self.logger.info("Finished replay") + # Used to satisfy the API class LightContext(object): def __init__(self, config): diff --git a/wlauto/common/linux/device.py b/wlauto/common/linux/device.py index 32924af4..12191f95 100644 --- a/wlauto/common/linux/device.py +++ b/wlauto/common/linux/device.py @@ -37,6 +37,7 @@ FSTAB_ENTRY_REGEX = re.compile(r'(\S+) on (\S+) type (\S+) \((\S+)\)') FstabEntry = namedtuple('FstabEntry', ['device', 'mount_point', 'fs_type', 'options', 'dump_freq', 'pass_num']) PsEntry = namedtuple('PsEntry', 'user pid ppid vsize rss wchan pc state name') +LsmodEntry = namedtuple('LsmodEntry', ['name', 'size', 'use_count', 'used_by']) class BaseLinuxDevice(Device): # pylint: disable=abstract-method @@ -821,6 +822,30 @@ class LinuxDevice(BaseLinuxDevice): # misc + def lsmod(self): + """List loaded kernel modules.""" + lines = self.execute('lsmod').splitlines() + entries = [] + for line in lines[1:]: # first line is the header + if not line.strip(): + continue + parts = line.split() + name = parts[0] + size = int(parts[1]) + use_count = int(parts[2]) + if len(parts) > 3: + used_by = ''.join(parts[3:]).split(',') + else: + used_by = [] + entries.append(LsmodEntry(name, size, use_count, used_by)) + return entries + + def insmod(self, path): + """Install a kernel module located on the host on the target device.""" + target_path = self.path.join(self.working_directory, os.path.basename(path)) + self.push_file(path, target_path) + self.execute('insmod {}'.format(target_path), as_root=True) + def ping(self): try: # May be triggered inside initialize()