mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-09-03 03:42:35 +01:00
Fixed WA extensions for LinuxManager
Changed method calls to devlib naming
This commit is contained in:
@@ -197,12 +197,12 @@ class Daq(Instrument):
|
||||
raise InstrumentError('GPIO sysfs not enabled on the device.')
|
||||
try:
|
||||
export_path = self.device.path.join(GPIO_ROOT, 'export')
|
||||
self.device.set_sysfile_value(export_path, self.gpio_sync, verify=False)
|
||||
self.device.write_value(export_path, self.gpio_sync, verify=False)
|
||||
pin_root = self.device.path.join(GPIO_ROOT, 'gpio{}'.format(self.gpio_sync))
|
||||
direction_path = self.device.path.join(pin_root, 'direction')
|
||||
self.device.set_sysfile_value(direction_path, 'out')
|
||||
self.device.write_value(direction_path, 'out')
|
||||
self.gpio_path = self.device.path.join(pin_root, 'value')
|
||||
self.device.set_sysfile_value(self.gpio_path, 0, verify=False)
|
||||
self.device.write_value(self.gpio_path, 0, verify=False)
|
||||
signal.connect(self.insert_start_marker, signal.BEFORE_WORKLOAD_EXECUTION, priority=11)
|
||||
signal.connect(self.insert_stop_marker, signal.AFTER_WORKLOAD_EXECUTION, priority=11)
|
||||
except DeviceError as e:
|
||||
@@ -276,7 +276,7 @@ class Daq(Instrument):
|
||||
def finalize(self, context):
|
||||
if self.gpio_path:
|
||||
unexport_path = self.device.path.join(GPIO_ROOT, 'unexport')
|
||||
self.device.set_sysfile_value(unexport_path, self.gpio_sync, verify=False)
|
||||
self.device.write_value(unexport_path, self.gpio_sync, verify=False)
|
||||
|
||||
def validate(self): # pylint: disable=too-many-branches
|
||||
if not daq:
|
||||
|
@@ -39,7 +39,7 @@ class DmesgInstrument(Instrument):
|
||||
def setup(self, context):
|
||||
if self.loglevel:
|
||||
self.old_loglevel = self.device.get_sysfile_value(self.loglevel_file)
|
||||
self.device.set_sysfile_value(self.loglevel_file, self.loglevel, verify=False)
|
||||
self.device.write_value(self.loglevel_file, self.loglevel, verify=False)
|
||||
self.before_file = _f(os.path.join(context.output_directory, 'dmesg', 'before'))
|
||||
self.after_file = _f(os.path.join(context.output_directory, 'dmesg', 'after'))
|
||||
|
||||
@@ -57,6 +57,6 @@ class DmesgInstrument(Instrument):
|
||||
|
||||
def teardown(self, context): # pylint: disable=unused-argument
|
||||
if self.loglevel:
|
||||
self.device.set_sysfile_value(self.loglevel_file, self.old_loglevel, verify=False)
|
||||
self.device.write_value(self.loglevel_file, self.old_loglevel, verify=False)
|
||||
|
||||
|
||||
|
@@ -634,7 +634,7 @@ class EnergyModelInstrument(Instrument):
|
||||
self.enable_all_idle_states()
|
||||
self.reset_cgroups()
|
||||
self.cpuset.move_all_tasks_to(self.measuring_cluster)
|
||||
server_process = 'adbd' if self.device.platform == 'android' else 'sshd'
|
||||
server_process = 'adbd' if self.device.os == 'android' else 'sshd'
|
||||
server_pids = self.device.get_pids_of(server_process)
|
||||
children_ps = [e for e in self.device.ps()
|
||||
if e.ppid in server_pids and e.name != 'sshd']
|
||||
@@ -769,7 +769,7 @@ class EnergyModelInstrument(Instrument):
|
||||
for tzpath in tzone_paths.strip().split():
|
||||
mode_file = '{}/mode'.format(tzpath)
|
||||
if self.device.file_exists(mode_file):
|
||||
self.device.set_sysfile_value(mode_file, 'disabled')
|
||||
self.device.write_value(mode_file, 'disabled')
|
||||
|
||||
def get_device_idle_states(self, cluster):
|
||||
if cluster == 'big':
|
||||
|
@@ -81,7 +81,7 @@ class JunoEnergy(Instrument):
|
||||
self.device.killall('readenergy', signal='TERM', as_root=True)
|
||||
|
||||
def update_result(self, context):
|
||||
self.device.pull_file(self.device_output_file, self.host_output_file)
|
||||
self.device.pull(self.device_output_file, self.host_output_file)
|
||||
context.add_artifact('junoenergy', self.host_output_file, 'data')
|
||||
|
||||
with open(self.host_output_file) as fh:
|
||||
@@ -99,7 +99,7 @@ class JunoEnergy(Instrument):
|
||||
context.add_metric(header, value, UNIT_MAP[header.split('_')[-1]])
|
||||
|
||||
def teardown(self, conetext):
|
||||
self.device.delete_file(self.device_output_file)
|
||||
self.device.remove(self.device_output_file)
|
||||
|
||||
def validate(self):
|
||||
if self.strict:
|
||||
|
@@ -33,9 +33,11 @@ import tarfile
|
||||
from itertools import izip, izip_longest
|
||||
from subprocess import CalledProcessError
|
||||
|
||||
from devlib.exception import TargetError
|
||||
|
||||
from wlauto import Instrument, Parameter
|
||||
from wlauto.core import signal
|
||||
from wlauto.exceptions import DeviceError, ConfigError
|
||||
from wlauto.exceptions import ConfigError
|
||||
from wlauto.utils.misc import diff_tokens, write_table, check_output, as_relative
|
||||
from wlauto.utils.misc import ensure_file_directory_exists as _f
|
||||
from wlauto.utils.misc import ensure_directory_exists as _d
|
||||
@@ -134,7 +136,7 @@ class SysfsExtractor(Instrument):
|
||||
as_root=True, check_exit_code=False)
|
||||
else: # not rooted
|
||||
for dev_dir, before_dir, _, _ in self.device_and_host_paths:
|
||||
self.device.pull_file(dev_dir, before_dir)
|
||||
self.device.pull(dev_dir, before_dir)
|
||||
|
||||
def slow_stop(self, context):
|
||||
if self.use_tmpfs:
|
||||
@@ -146,7 +148,7 @@ class SysfsExtractor(Instrument):
|
||||
as_root=True, check_exit_code=False)
|
||||
else: # not using tmpfs
|
||||
for dev_dir, _, after_dir, _ in self.device_and_host_paths:
|
||||
self.device.pull_file(dev_dir, after_dir)
|
||||
self.device.pull(dev_dir, after_dir)
|
||||
|
||||
def update_result(self, context):
|
||||
if self.use_tmpfs:
|
||||
@@ -157,10 +159,10 @@ class SysfsExtractor(Instrument):
|
||||
self.tmpfs_mount_point),
|
||||
as_root=True)
|
||||
self.device.execute('chmod 0777 {}'.format(on_device_tarball), as_root=True)
|
||||
self.device.pull_file(on_device_tarball, on_host_tarball)
|
||||
self.device.pull(on_device_tarball, on_host_tarball)
|
||||
with tarfile.open(on_host_tarball, 'r:gz') as tf:
|
||||
tf.extractall(context.output_directory)
|
||||
self.device.delete_file(on_device_tarball)
|
||||
self.device.remove(on_device_tarball)
|
||||
os.remove(on_host_tarball)
|
||||
|
||||
for paths in self.device_and_host_paths:
|
||||
@@ -181,7 +183,7 @@ class SysfsExtractor(Instrument):
|
||||
if self.use_tmpfs:
|
||||
try:
|
||||
self.device.execute('umount {}'.format(self.tmpfs_mount_point), as_root=True)
|
||||
except (DeviceError, CalledProcessError):
|
||||
except (TargetError, CalledProcessError):
|
||||
# assume a directory but not mount point
|
||||
pass
|
||||
self.device.execute('rm -rf {}'.format(self.tmpfs_mount_point),
|
||||
@@ -386,4 +388,3 @@ def _diff_sysfs_dirs(before, after, result): # pylint: disable=R0914
|
||||
else:
|
||||
dchunks = [diff_tokens(b, a) for b, a in zip(bchunks, achunks)]
|
||||
dfh.write(''.join(dchunks))
|
||||
|
||||
|
@@ -159,7 +159,7 @@ class NetstatsInstrument(Instrument):
|
||||
]
|
||||
|
||||
def initialize(self, context):
|
||||
if self.device.platform != 'android':
|
||||
if self.device.os != 'android':
|
||||
raise DeviceError('nestats instrument only supports on Android devices.')
|
||||
apk = context.resolver.get(ApkFile(self))
|
||||
self.collector = NetstatsCollector(self.device, apk) # pylint: disable=attribute-defined-outside-init
|
||||
|
@@ -106,7 +106,7 @@ class PerfInstrument(Instrument):
|
||||
self.device.kick_off(command)
|
||||
|
||||
def stop(self, context):
|
||||
as_root = self.device.platform == 'android'
|
||||
as_root = self.device.os == 'android'
|
||||
self.device.killall('sleep', as_root=as_root)
|
||||
|
||||
def update_result(self, context):
|
||||
@@ -114,7 +114,7 @@ class PerfInstrument(Instrument):
|
||||
device_file = self._get_device_outfile(label)
|
||||
host_relpath = os.path.join('perf', os.path.basename(device_file))
|
||||
host_file = _f(os.path.join(context.output_directory, host_relpath))
|
||||
self.device.pull_file(device_file, host_file)
|
||||
self.device.pull(device_file, host_file)
|
||||
context.add_iteration_artifact(label, kind='raw', path=host_relpath)
|
||||
with open(host_file) as fh:
|
||||
in_results_section = False
|
||||
@@ -165,7 +165,7 @@ class PerfInstrument(Instrument):
|
||||
def _clean_device(self):
|
||||
for label in self.labels:
|
||||
filepath = self._get_device_outfile(label)
|
||||
self.device.delete_file(filepath)
|
||||
self.device.remove(filepath)
|
||||
|
||||
def _get_device_outfile(self, label):
|
||||
return self.device.path.join(self.device.working_directory, '{}.out'.format(label))
|
||||
|
@@ -91,21 +91,21 @@ class CciPmuLogger(Instrument):
|
||||
if self.install_module:
|
||||
self.device_driver_file = self.device.path.join(self.device.working_directory, DRIVER)
|
||||
host_driver_file = os.path.join(settings.dependencies_directory, DRIVER)
|
||||
self.device.push_file(host_driver_file, self.device_driver_file)
|
||||
self.device.push(host_driver_file, self.device_driver_file)
|
||||
|
||||
def setup(self, context):
|
||||
if self.install_module:
|
||||
self.device.execute('insmod {}'.format(self.device_driver_file), check_exit_code=False)
|
||||
self.device.set_sysfile_value(CPL_PERIOD_FILE, self.period)
|
||||
self.device.write_value(CPL_PERIOD_FILE, self.period)
|
||||
for i, event in enumerate(self.events):
|
||||
counter = CPL_BASE + 'counter{}'.format(i)
|
||||
self.device.set_sysfile_value(counter, event, verify=False)
|
||||
self.device.write_value(counter, event, verify=False)
|
||||
|
||||
def start(self, context):
|
||||
self.device.set_sysfile_value(CPL_CONTROL_FILE, 1, verify=False)
|
||||
self.device.write_value(CPL_CONTROL_FILE, 1, verify=False)
|
||||
|
||||
def stop(self, context):
|
||||
self.device.set_sysfile_value(CPL_CONTROL_FILE, 1, verify=False)
|
||||
self.device.write_value(CPL_CONTROL_FILE, 1, verify=False)
|
||||
|
||||
# Doing result processing inside teardown because need to make sure that
|
||||
# trace-cmd has processed its results and generated the trace.txt
|
||||
|
@@ -65,7 +65,7 @@ class ScreenOnInstrument(Instrument):
|
||||
|
||||
def initialize(self, context):
|
||||
self.monitor = None
|
||||
if self.device.platform != 'android':
|
||||
if self.device.os != 'android':
|
||||
raise InstrumentError('screenon instrument currently only supports Android devices.')
|
||||
|
||||
def slow_setup(self, context): # slow to run before most other setups
|
||||
|
@@ -182,13 +182,13 @@ class StreamlineInstrument(Instrument):
|
||||
caiman_path = subprocess.check_output('which caiman', shell=True).strip() # pylint: disable=E1103
|
||||
self.session_file = os.path.join(context.host_working_directory, 'streamline_session.xml')
|
||||
with open(self.session_file, 'w') as wfh:
|
||||
if self.device.platform == "android":
|
||||
if self.device.os == "android":
|
||||
wfh.write(SESSION_TEXT_TEMPLATE.format('127.0.0.1', self.port, caiman_path))
|
||||
else:
|
||||
wfh.write(SESSION_TEXT_TEMPLATE.format(self.device.host, self.port, caiman_path))
|
||||
|
||||
if self.configuration_file:
|
||||
self.device.push_file(self.configuration_file, self.on_device_config)
|
||||
self.device.push(self.configuration_file, self.on_device_config)
|
||||
self._initialize_daemon()
|
||||
|
||||
def setup(self, context):
|
||||
@@ -220,7 +220,7 @@ class StreamlineInstrument(Instrument):
|
||||
|
||||
def teardown(self, context):
|
||||
self._kill_daemon()
|
||||
self.device.delete_file(self.on_device_config)
|
||||
self.device.remove(self.on_device_config)
|
||||
|
||||
def _check_has_valid_display(self): # pylint: disable=R0201
|
||||
reason = None
|
||||
@@ -243,7 +243,7 @@ class StreamlineInstrument(Instrument):
|
||||
raise
|
||||
self.logger.debug('Driver was already installed.')
|
||||
self._start_daemon()
|
||||
if self.device.platform == "android":
|
||||
if self.device.os == "android":
|
||||
port_spec = 'tcp:{}'.format(self.port)
|
||||
self.device.forward_port(port_spec, port_spec)
|
||||
|
||||
|
@@ -166,7 +166,7 @@ class TraceCmdInstrument(Instrument):
|
||||
host_file = context.resolver.get(Executable(self, self.device.abi, 'trace-cmd'))
|
||||
self.trace_cmd = self.device.install(host_file)
|
||||
else:
|
||||
self.trace_cmd = self.device.get_binary_path("trace-cmd")
|
||||
self.trace_cmd = self.device.get_installed("trace-cmd")
|
||||
if not self.trace_cmd:
|
||||
raise ConfigError('No trace-cmd found on device and no_install=True is specified.')
|
||||
|
||||
@@ -233,7 +233,7 @@ class TraceCmdInstrument(Instrument):
|
||||
# Therefore timout for the pull command must also be adjusted
|
||||
# accordingly.
|
||||
self._pull_timeout = (self.stop_time - self.start_time) # pylint: disable=attribute-defined-outside-init
|
||||
self.device.pull_file(self.output_file, context.output_directory, timeout=self._pull_timeout)
|
||||
self.device.pull(self.output_file, context.output_directory, timeout=self._pull_timeout)
|
||||
context.add_iteration_artifact('bintrace', OUTPUT_TRACE_FILE, kind='data',
|
||||
description='trace-cmd generated ftrace dump.')
|
||||
|
||||
@@ -263,7 +263,7 @@ class TraceCmdInstrument(Instrument):
|
||||
self.logger.warning('Could not generate trace.txt.')
|
||||
|
||||
def teardown(self, context):
|
||||
self.device.delete_file(os.path.join(self.device.working_directory, OUTPUT_TRACE_FILE))
|
||||
self.device.remove(os.path.join(self.device.working_directory, OUTPUT_TRACE_FILE))
|
||||
|
||||
def on_run_end(self, context):
|
||||
pass
|
||||
@@ -282,11 +282,11 @@ class TraceCmdInstrument(Instrument):
|
||||
|
||||
def insert_start_mark(self, context):
|
||||
# trace marker appears in ftrace as an ftrace/print event with TRACE_MARKER_START in info field
|
||||
self.device.set_sysfile_value("/sys/kernel/debug/tracing/trace_marker", "TRACE_MARKER_START", verify=False)
|
||||
self.device.write_value("/sys/kernel/debug/tracing/trace_marker", "TRACE_MARKER_START", verify=False)
|
||||
|
||||
def insert_end_mark(self, context):
|
||||
# trace marker appears in ftrace as an ftrace/print event with TRACE_MARKER_STOP in info field
|
||||
self.device.set_sysfile_value("/sys/kernel/debug/tracing/trace_marker", "TRACE_MARKER_STOP", verify=False)
|
||||
self.device.write_value("/sys/kernel/debug/tracing/trace_marker", "TRACE_MARKER_STOP", verify=False)
|
||||
|
||||
def _set_buffer_size(self):
|
||||
target_buffer_size = self.buffer_size
|
||||
@@ -294,7 +294,7 @@ class TraceCmdInstrument(Instrument):
|
||||
buffer_size = 0
|
||||
floor = 1000 if target_buffer_size > 1000 else target_buffer_size
|
||||
while attempt_buffer_size >= floor:
|
||||
self.device.set_sysfile_value(self.buffer_size_file, attempt_buffer_size, verify=False)
|
||||
self.device.write_value(self.buffer_size_file, attempt_buffer_size, verify=False)
|
||||
buffer_size = self.device.get_sysfile_value(self.buffer_size_file, kind=int)
|
||||
if buffer_size == attempt_buffer_size:
|
||||
break
|
||||
@@ -304,7 +304,7 @@ class TraceCmdInstrument(Instrument):
|
||||
return
|
||||
while attempt_buffer_size < target_buffer_size:
|
||||
attempt_buffer_size += self.buffer_size_step
|
||||
self.device.set_sysfile_value(self.buffer_size_file, attempt_buffer_size, verify=False)
|
||||
self.device.write_value(self.buffer_size_file, attempt_buffer_size, verify=False)
|
||||
buffer_size = self.device.get_sysfile_value(self.buffer_size_file, kind=int)
|
||||
if attempt_buffer_size != buffer_size:
|
||||
self.logger.warning('Failed to set trace buffer size to {}, value set was {}'.format(target_buffer_size, buffer_size))
|
||||
@@ -316,7 +316,7 @@ class TraceCmdInstrument(Instrument):
|
||||
txt_trace_file = os.path.join(self.device.working_directory, OUTPUT_TEXT_FILE)
|
||||
command = 'trace-cmd report {} > {}'.format(trace_file, txt_trace_file)
|
||||
self.device.execute(command)
|
||||
self.device.pull_file(txt_trace_file, context.output_directory, timeout=self._pull_timeout)
|
||||
self.device.pull(txt_trace_file, context.output_directory, timeout=self._pull_timeout)
|
||||
except DeviceError:
|
||||
raise InstrumentError('Could not generate TXT report on target.')
|
||||
|
||||
|
Reference in New Issue
Block a user