1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-20 20:09:11 +00:00

BaseLinuxDevice: added lsmod() method

Execute lsmod on the target device and parses the output into named
tuples.
This commit is contained in:
Sergei Trofimov 2016-01-27 16:37:46 +00:00
parent a402bfd7f9
commit dc07c8d87e

View File

@ -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,24 @@ 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 ping(self):
try:
# May be triggered inside initialize()