mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-19 12:24:32 +00:00
Merge pull request #87 from setrofim/master
Added functions for manipulating kernel modules + pep8 fix.
This commit is contained in:
commit
2d1f0e99b9
@ -158,6 +158,7 @@ class ReplayCommand(RecordCommand):
|
|||||||
self.device.execute(command)
|
self.device.execute(command)
|
||||||
self.logger.info("Finished replay")
|
self.logger.info("Finished replay")
|
||||||
|
|
||||||
|
|
||||||
# Used to satisfy the API
|
# Used to satisfy the API
|
||||||
class LightContext(object):
|
class LightContext(object):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
|
@ -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'])
|
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 BaseLinuxDevice(Device): # pylint: disable=abstract-method
|
class BaseLinuxDevice(Device): # pylint: disable=abstract-method
|
||||||
@ -821,6 +822,30 @@ class LinuxDevice(BaseLinuxDevice):
|
|||||||
|
|
||||||
# misc
|
# 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):
|
def ping(self):
|
||||||
try:
|
try:
|
||||||
# May be triggered inside initialize()
|
# May be triggered inside initialize()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user