1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

target: added lsmod method

Added a wrapper for lsmod that parses the output into named tuples.
This commit is contained in:
Sergei Trofimov 2016-01-27 16:34:26 +00:00
parent 798745ff4e
commit 5a81fe9888

View File

@ -437,6 +437,23 @@ class Target(object):
def has(self, modname): def has(self, modname):
return hasattr(self, identifier(modname)) return hasattr(self, identifier(modname))
def lsmod(self):
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).split(',')
else:
used_by = []
entries.append(LsmodEntry(name, size, use_count, used_by))
return entries
def _update_modules(self, stage): def _update_modules(self, stage):
for mod in self.modules: for mod in self.modules:
if isinstance(mod, dict): if isinstance(mod, dict):
@ -840,6 +857,7 @@ class AndroidTarget(Target):
FstabEntry = namedtuple('FstabEntry', ['device', 'mount_point', 'fs_type', 'options', 'dump_freq', 'pass_num']) 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') PsEntry = namedtuple('PsEntry', 'user pid ppid vsize rss wchan pc state name')
LsmodEntry = namedtuple('LsmodEntry', ['name', 'size', 'use_count', 'used_by'])
class Cpuinfo(object): class Cpuinfo(object):