1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-31 10:11:17 +00:00

framework: pep8 fixes

Fix issues reported by flake8.
This commit is contained in:
Sergei Trofimov 2018-07-05 14:02:05 +01:00 committed by Marc Bonnici
parent 88c5005b38
commit 03eafe6b33
20 changed files with 435 additions and 389 deletions

View File

@ -144,12 +144,14 @@ class LoggingConfig(dict):
def to_pod(self): def to_pod(self):
return self return self
def expanded_path(path): def expanded_path(path):
""" """
Ensure that the provided path has been expanded if applicable Ensure that the provided path has been expanded if applicable
""" """
return os.path.expanduser(str(path)) return os.path.expanduser(str(path))
def get_type_name(kind): def get_type_name(kind):
typename = str(kind) typename = str(kind)
if '\'' in typename: if '\'' in typename:
@ -377,12 +379,11 @@ class Configuration(object):
name)) name))
try: try:
self.configuration[name].set_value(self, value, self.configuration[name].set_value(self, value,
check_mandatory=check_mandatory) check_mandatory=check_mandatory)
except (TypeError, ValueError, ConfigError) as e: except (TypeError, ValueError, ConfigError) as e:
msg = 'Invalid value "{}" for "{}": {}' msg = 'Invalid value "{}" for "{}": {}'
raise ConfigError(msg.format(value, name, e)) raise ConfigError(msg.format(value, name, e))
def update_config(self, values, check_mandatory=True): def update_config(self, values, check_mandatory=True):
for k, v in values.items(): for k, v in values.items():
self.set(k, v, check_mandatory=check_mandatory) self.set(k, v, check_mandatory=check_mandatory)
@ -899,7 +900,6 @@ class JobSpec(Configuration):
self.label = self.workload_name self.label = self.workload_name
# This is used to construct the list of Jobs WA will run # This is used to construct the list of Jobs WA will run
class JobGenerator(object): class JobGenerator(object):

View File

@ -18,12 +18,14 @@ from wa.framework.configuration.plugin_cache import PluginCache
from wa.utils.serializer import yaml from wa.utils.serializer import yaml
from wa.utils.doc import strip_inlined_text from wa.utils.doc import strip_inlined_text
DEFAULT_AUGMENTATIONS = ['execution_time',
'interrupts', DEFAULT_AUGMENTATIONS = [
'cpufreq', 'execution_time',
'status', 'interrupts',
'csv' 'cpufreq',
] 'status',
'csv',
]
def _format_yaml_comment(param, short_description=False): def _format_yaml_comment(param, short_description=False):

View File

@ -84,7 +84,6 @@ class ConfigParser(object):
log.dedent() log.dedent()
class AgendaParser(object): class AgendaParser(object):
def load_from_path(self, state, filepath): def load_from_path(self, state, filepath):
@ -244,7 +243,7 @@ def merge_augmentations(raw):
""" """
cfg_point = JobSpec.configuration['augmentations'] cfg_point = JobSpec.configuration['augmentations']
names = [cfg_point.name,] + cfg_point.aliases names = [cfg_point.name, ] + cfg_point.aliases
entries = [] entries = []
for n in names: for n in names:
@ -253,9 +252,9 @@ def merge_augmentations(raw):
value = raw.pop(n) value = raw.pop(n)
try: try:
entries.append(toggle_set(value)) entries.append(toggle_set(value))
except TypeError as e: except TypeError as exc:
msg = 'Invalid value "{}" for "{}": {}' msg = 'Invalid value "{}" for "{}": {}'
raise ConfigError(msg.format(value, n, e)) raise ConfigError(msg.format(value, n, exc))
# Make sure none of the specified aliases conflict with each other # Make sure none of the specified aliases conflict with each other
to_check = [e for e in entries] to_check = [e for e in entries]

View File

@ -81,7 +81,7 @@ class PluginCache(object):
if caseless_string(plugin_name) in ['global', 'config']: if caseless_string(plugin_name) in ['global', 'config']:
msg = '"{}" entry specified inside config/global section; If this is ' \ msg = '"{}" entry specified inside config/global section; If this is ' \
'defined in a config file, move the entry content into the top level' 'defined in a config file, move the entry content into the top level'
raise ConfigError(msg.format((plugin_name))) raise ConfigError(msg.format((plugin_name)))
if (not self.loader.has_plugin(plugin_name) and if (not self.loader.has_plugin(plugin_name) and
@ -270,7 +270,6 @@ class PluginCache(object):
raise AttributeError(name) raise AttributeError(name)
class MergeState(object): class MergeState(object):
def __init__(self): def __init__(self):
@ -289,13 +288,13 @@ def update_config_from_source(final_config, source, state):
if name in state.generic_config[source]: if name in state.generic_config[source]:
if name in state.seen_specific_config: if name in state.seen_specific_config:
msg = ('"{generic_name}" configuration "{config_name}" has ' msg = ('"{generic_name}" configuration "{config_name}" has '
'already been specified more specifically for ' 'already been specified more specifically for '
'{specific_name} in:\n\t\t{sources}') '{specific_name} in:\n\t\t{sources}')
seen_sources = state.seen_specific_config[name] seen_sources = state.seen_specific_config[name]
msg = msg.format(generic_name=state.generic_name, msg = msg.format(generic_name=state.generic_name,
config_name=name, config_name=name,
specific_name=state.specific_name, specific_name=state.specific_name,
sources=", ".join(seen_sources)) sources=", ".join(seen_sources))
raise ConfigError(msg) raise ConfigError(msg)
value = state.generic_config[source].pop(name) value = state.generic_config[source].pop(name)
cfg_point.set_value(final_config, value, check_mandatory=False) cfg_point.set_value(final_config, value, check_mandatory=False)

View File

@ -25,8 +25,8 @@ from datetime import datetime
import wa.framework.signal as signal import wa.framework.signal as signal
from wa.framework import instrument from wa.framework import instrument
from wa.framework.configuration.core import Status from wa.framework.configuration.core import Status
from wa.framework.exception import TargetError, HostError, WorkloadError,\ from wa.framework.exception import TargetError, HostError, WorkloadError
TargetNotRespondingError, TimeoutError from wa.framework.exception import TargetNotRespondingError, TimeoutError
from wa.framework.job import Job from wa.framework.job import Job
from wa.framework.output import init_job_output from wa.framework.output import init_job_output
from wa.framework.output_processor import ProcessorManager from wa.framework.output_processor import ProcessorManager
@ -130,8 +130,8 @@ class ExecutionContext(object):
self.run_state.status = status self.run_state.status = status
self.run_output.status = status self.run_output.status = status
self.run_output.info.end_time = datetime.utcnow() self.run_output.info.end_time = datetime.utcnow()
self.run_output.info.duration = self.run_output.info.end_time -\ self.run_output.info.duration = (self.run_output.info.end_time -
self.run_output.info.start_time self.run_output.info.start_time)
self.write_output() self.write_output()
def finalize(self): def finalize(self):
@ -356,8 +356,8 @@ class Executor(object):
output.write_config(config) output.write_config(config)
self.target_manager = TargetManager(config.run_config.device, self.target_manager = TargetManager(config.run_config.device,
config.run_config.device_config, config.run_config.device_config,
output.basepath) output.basepath)
self.logger.info('Initializing execution context') self.logger.info('Initializing execution context')
context = ExecutionContext(config_manager, self.target_manager, output) context = ExecutionContext(config_manager, self.target_manager, output)
@ -540,7 +540,7 @@ class Runner(object):
context.tm.start() context.tm.start()
self.do_run_job(job, context) self.do_run_job(job, context)
job.set_status(Status.OK) job.set_status(Status.OK)
except (Exception, KeyboardInterrupt) as e: # pylint: disable=broad-except except (Exception, KeyboardInterrupt) as e: # pylint: disable=broad-except
log.log_error(e, self.logger) log.log_error(e, self.logger)
if isinstance(e, KeyboardInterrupt): if isinstance(e, KeyboardInterrupt):
context.run_interrupted = True context.run_interrupted = True

View File

@ -75,7 +75,7 @@ def get_path_matches(resource, files):
for f in files: for f in files:
if resource.match_path(f): if resource.match_path(f):
matches.append(f) matches.append(f)
return matches return matches
def get_from_location(basepath, resource): def get_from_location(basepath, resource):

View File

@ -86,23 +86,28 @@ def convert_wa2_agenda(filepath, output_path):
# Add additional config points to extract from config file. # Add additional config points to extract from config file.
# Also allows for aliasing of renamed parameters # Also allows for aliasing of renamed parameters
config_points.extend([ config_points.extend([
ConfigurationPoint('augmentations', ConfigurationPoint(
aliases=["instruments", "processors", "instrumentation", 'augmentations',
"output_processors", "augment", "result_processors"], aliases=["instruments", "processors", "instrumentation",
description='''The augmentations enabled by default. "output_processors", "augment", "result_processors"],
This combines the "instrumentation" description='''
and "result_processors" from previous The augmentations enabled by default.
versions of WA (the old entries are This combines the "instrumentation"
now aliases for this).'''), and "result_processors" from previous
ConfigurationPoint('device_config', versions of WA (the old entries are
description='''Generic configuration for device.''', now aliases for this).
default={}), '''),
ConfigurationPoint('cleanup_assets', ConfigurationPoint(
aliases=['clean_up'], 'device_config',
description='''Specify whether to clean up assets description='''Generic configuration for device.''',
deployed to the target''', default={}),
default=True), ConfigurationPoint(
]) 'cleanup_assets',
aliases=['clean_up'],
description='''Specify whether to clean up assets
deployed to the target''',
default=True),
])
for param in list(orig_agenda.keys()): for param in list(orig_agenda.keys()):
for cfg_point in config_points: for cfg_point in config_points:
@ -137,6 +142,6 @@ def convert_wa2_agenda(filepath, output_path):
def format_parameter(param): def format_parameter(param):
if isinstance(param, dict): if isinstance(param, dict):
return {identifier(k) : v for k, v in param.items()} return {identifier(k): v for k, v in param.items()}
else: else:
return param return param

View File

@ -13,6 +13,9 @@
# limitations under the License. # limitations under the License.
# #
# Because of use of Enum (dynamic attrs)
# pylint: disable=no-member
import logging import logging
from copy import copy from copy import copy
from datetime import datetime from datetime import datetime
@ -21,8 +24,6 @@ from wa.framework import pluginloader, signal, instrument
from wa.framework.configuration.core import Status from wa.framework.configuration.core import Status
from wa.utils.log import indentcontext from wa.utils.log import indentcontext
# Because of use of Enum (dynamic attrs)
# pylint: disable=no-member
class Job(object): class Job(object):

View File

@ -119,7 +119,6 @@ class Output(object):
self.result.status = Status.UNKNOWN self.result.status = Status.UNKNOWN
self.add_event(str(e)) self.add_event(str(e))
def write_result(self): def write_result(self):
write_pod(self.result.to_pod(), self.resultfile) write_pod(self.result.to_pod(), self.resultfile)
@ -167,7 +166,6 @@ class Output(object):
return os.path.basename(self.basepath) return os.path.basename(self.basepath)
class RunOutput(Output): class RunOutput(Output):
kind = 'run' kind = 'run'
@ -648,10 +646,10 @@ def init_run_output(path, wa_state, force=False):
touch(os.path.join(path, 'run.log')) touch(os.path.join(path, 'run.log'))
info = RunInfo( info = RunInfo(
run_name=wa_state.run_config.run_name, run_name=wa_state.run_config.run_name,
project=wa_state.run_config.project, project=wa_state.run_config.project,
project_stage=wa_state.run_config.project_stage, project_stage=wa_state.run_config.project_stage,
) )
write_pod(info.to_pod(), os.path.join(meta_dir, 'run_info.json')) write_pod(info.to_pod(), os.path.join(meta_dir, 'run_info.json'))
write_pod(RunState().to_pod(), os.path.join(path, '.run_state.json')) write_pod(RunState().to_pod(), os.path.join(path, '.run_state.json'))
write_pod(Result().to_pod(), os.path.join(path, 'result.json')) write_pod(Result().to_pod(), os.path.join(path, 'result.json'))
@ -678,7 +676,7 @@ def init_job_output(run_output, job):
def discover_wa_outputs(path): def discover_wa_outputs(path):
for root, dirs, _ in os.walk(path): for root, dirs, _ in os.walk(path):
if '__meta' in dirs: if '__meta' in dirs:
yield RunOutput(root) yield RunOutput(root)
def _save_raw_config(meta_dir, state): def _save_raw_config(meta_dir, state):

View File

@ -139,7 +139,7 @@ class ProcessorManager(object):
try: try:
self.logger.info(message.format(proc.name)) self.logger.info(message.format(proc.name))
proc_func(*args) proc_func(*args)
except Exception as e: # pylint: disable=broad-except except Exception as e: # pylint: disable=broad-except
if isinstance(e, KeyboardInterrupt): if isinstance(e, KeyboardInterrupt):
raise raise
log_error(e, self.logger) log_error(e, self.logger)

View File

@ -316,8 +316,8 @@ class Plugin(with_metaclass(PluginMeta, object)):
appropriate exception. appropriate exception.
""" """
modules = list(reversed(self.core_modules)) +\ modules = list(reversed(self.core_modules))
list(reversed(self.modules or [])) modules += list(reversed(self.modules or []))
if not modules: if not modules:
return return
for module_spec in modules: for module_spec in modules:

View File

@ -27,7 +27,6 @@ from wa.utils.misc import get_object_name
from wa.utils.types import enum, list_or_string, prioritylist from wa.utils.types import enum, list_or_string, prioritylist
SourcePriority = enum(['package', 'remote', 'lan', 'local', SourcePriority = enum(['package', 'remote', 'lan', 'local',
'perferred'], start=0, step=10) 'perferred'], start=0, step=10)
@ -172,9 +171,8 @@ class ApkFile(Resource):
abi_matches = apk_abi_matches(path, self.supported_abi, abi_matches = apk_abi_matches(path, self.supported_abi,
self.exact_abi) self.exact_abi)
return name_matches and version_matches and \ return name_matches and version_matches and \
uiauto_matches and package_matches and \ uiauto_matches and package_matches and \
abi_matches abi_matches
def __str__(self): def __str__(self):
text = '<{}\'s apk'.format(self.owner) text = '<{}\'s apk'.format(self.owner)
@ -280,6 +278,7 @@ def apk_version_matches(path, version):
return True return True
return loose_version_matching(version, info.version_name) return loose_version_matching(version, info.version_name)
def loose_version_matching(config_version, apk_version): def loose_version_matching(config_version, apk_version):
config_version = config_version.split('.') config_version = config_version.split('.')
apk_version = apk_version.split('.') apk_version = apk_version.split('.')
@ -301,14 +300,17 @@ def file_name_matches(path, pattern):
return True return True
return False return False
def uiauto_test_matches(path, uiauto): def uiauto_test_matches(path, uiauto):
info = ApkInfo(path) info = ApkInfo(path)
return uiauto == ('com.arm.wa.uiauto' in info.package) return uiauto == ('com.arm.wa.uiauto' in info.package)
def package_name_matches(path, package): def package_name_matches(path, package):
info = ApkInfo(path) info = ApkInfo(path)
return info.package == package return info.package == package
def apk_abi_matches(path, supported_abi, exact_abi=False): def apk_abi_matches(path, supported_abi, exact_abi=False):
supported_abi = list_or_string(supported_abi) supported_abi = list_or_string(supported_abi)
info = ApkInfo(path) info = ApkInfo(path)

View File

@ -12,6 +12,10 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
# Because of use of Enum (dynamic attrs)
# pylint: disable=no-member
import uuid import uuid
from collections import OrderedDict, Counter from collections import OrderedDict, Counter
from copy import copy from copy import copy
@ -19,8 +23,6 @@ from datetime import datetime, timedelta
from wa.framework.configuration.core import Status from wa.framework.configuration.core import Status
# Because of use of Enum (dynamic attrs)
# pylint: disable=no-member
class RunInfo(object): class RunInfo(object):
""" """
@ -36,8 +38,7 @@ class RunInfo(object):
uid = uuid.UUID(uid) uid = uuid.UUID(uid)
instance = RunInfo(**pod) instance = RunInfo(**pod)
instance.uuid = uid instance.uuid = uid
instance.duration = duration if duration is None else\ instance.duration = duration if duration is None else timedelta(seconds=duration)
timedelta(seconds=duration)
return instance return instance
def __init__(self, run_name=None, project=None, project_stage=None, def __init__(self, run_name=None, project=None, project_stage=None,

View File

@ -110,8 +110,7 @@ BEFORE_WORKLOAD_EXECUTION = Signal('before-workload-execution', invert_priority=
SUCCESSFUL_WORKLOAD_EXECUTION = Signal('successful-workload-execution') SUCCESSFUL_WORKLOAD_EXECUTION = Signal('successful-workload-execution')
AFTER_WORKLOAD_EXECUTION = Signal('after-workload-execution') AFTER_WORKLOAD_EXECUTION = Signal('after-workload-execution')
BEFORE_WORKLOAD_RESULT_EXTRACTION = Signal('before-workload-result-extracton', BEFORE_WORKLOAD_RESULT_EXTRACTION = Signal('before-workload-result-extracton', invert_priority=True)
invert_priority=True)
SUCCESSFUL_WORKLOAD_RESULT_EXTRACTION = Signal('successful-workload-result-extracton') SUCCESSFUL_WORKLOAD_RESULT_EXTRACTION = Signal('successful-workload-result-extracton')
AFTER_WORKLOAD_RESULT_EXTRACTION = Signal('after-workload-result-extracton') AFTER_WORKLOAD_RESULT_EXTRACTION = Signal('after-workload-result-extracton')
@ -183,8 +182,6 @@ AFTER_RUN_OUTPUT_PROCESSED = Signal(
'after-run-output-processed') 'after-run-output-processed')
CallbackPriority = enum(['extremely_low', 'very_low', 'low', 'normal', CallbackPriority = enum(['extremely_low', 'very_low', 'low', 'normal',
'high', 'very_high', 'extremely_high'], -30, 10) 'high', 'very_high', 'extremely_high'], -30, 10)

View File

@ -15,7 +15,6 @@
from copy import copy from copy import copy
#Not going to be used for now.
class TargetConfig(dict): class TargetConfig(dict):
""" """

View File

@ -289,117 +289,137 @@ GEM5_PLATFORM_PARAMS = [
CONNECTION_PARAMS = { CONNECTION_PARAMS = {
AdbConnection: [ AdbConnection: [
Parameter('device', kind=str, Parameter(
aliases=['adb_name'], 'device', kind=str,
description=""" aliases=['adb_name'],
ADB device name description="""
"""), ADB device name
Parameter('adb_server', kind=str, """),
description=""" Parameter(
ADB server to connect to. 'adb_server', kind=str,
"""), description="""
ADB server to connect to.
"""),
], ],
SshConnection: [ SshConnection: [
Parameter('host', kind=str, mandatory=True, Parameter(
description=""" 'host', kind=str, mandatory=True,
Host name or IP address of the target. description="""
"""), Host name or IP address of the target.
Parameter('username', kind=str, mandatory=True, """),
description=""" Parameter(
User name to connect with 'username', kind=str, mandatory=True,
"""), description="""
Parameter('password', kind=str, User name to connect with
description=""" """),
Password to use. Parameter(
"""), 'password', kind=str,
Parameter('keyfile', kind=str, description="""
description=""" Password to use.
Key file to use """),
"""), Parameter(
Parameter('port', kind=int, 'keyfile', kind=str,
description=""" description="""
The port SSH server is listening on on the target. Key file to use
"""), """),
Parameter('telnet', kind=bool, default=False, Parameter(
description=""" 'port', kind=int,
If set to ``True``, a Telnet connection, rather than description="""
SSH will be used. The port SSH server is listening on on the target.
"""), """),
Parameter('password_prompt', kind=str, Parameter(
description=""" 'telnet', kind=bool, default=False,
Password prompt to expect description="""
"""), If set to ``True``, a Telnet connection, rather than
Parameter('original_prompt', kind=str, SSH will be used.
description=""" """),
Original shell prompt to expect. Parameter(
"""), 'password_prompt', kind=str,
Parameter('sudo_cmd', kind=str, description="""
default="sudo -- sh -c '{}'", Password prompt to expect
description=""" """),
Sudo command to use. Must have ``"{}"`` specified Parameter(
somewhere in the string it indicate where the command 'original_prompt', kind=str,
to be run via sudo is to go. description="""
"""), Original shell prompt to expect.
"""),
Parameter(
'sudo_cmd', kind=str,
default="sudo -- sh -c '{}'",
description="""
Sudo command to use. Must have ``"{}"`` specified
somewhere in the string it indicate where the command
to be run via sudo is to go.
"""),
], ],
Gem5Connection: [ Gem5Connection: [
Parameter('host', kind=str, mandatory=False, Parameter(
description=""" 'host', kind=str, mandatory=False,
Host name or IP address of the target. description="""
"""), Host name or IP address of the target.
Parameter('username', kind=str, default='root', """),
description=""" Parameter(
User name to connect to gem5 simulation. 'username', kind=str, default='root',
"""), description="""
Parameter('password', kind=str, User name to connect to gem5 simulation.
description=""" """),
Password to use. Parameter(
"""), 'password', kind=str,
Parameter('port', kind=int, description="""
description=""" Password to use.
The port SSH server is listening on on the target. """),
"""), Parameter(
Parameter('password_prompt', kind=str, 'port', kind=int,
description=""" description="""
Password prompt to expect The port SSH server is listening on on the target.
"""), """),
Parameter('original_prompt', kind=str, Parameter(
description=""" 'password_prompt', kind=str,
Original shell prompt to expect. description="""
"""), Password prompt to expect
"""),
Parameter(
'original_prompt', kind=str,
description="""
Original shell prompt to expect.
"""),
], ],
LocalConnection: [ LocalConnection: [
Parameter('password', kind=str, Parameter(
description=""" 'password', kind=str,
Password to use for sudo. if not specified, the user will description="""
be prompted during intialization. Password to use for sudo. if not specified, the user will
"""), be prompted during intialization.
Parameter('keep_password', kind=bool, default=True, """),
description=""" Parameter(
If ``True`` (the default), the password will be cached in 'keep_password', kind=bool, default=True,
memory after it is first obtained from the user, so that the description="""
user would not be prompted for it again. If ``True`` (the default), the password will be cached in
"""), memory after it is first obtained from the user, so that the
Parameter('unrooted', kind=bool, default=False, user would not be prompted for it again.
description=""" """),
Indicate that the target should be considered unrooted; do not Parameter(
attempt sudo or ask the user for their password. 'unrooted', kind=bool, default=False,
"""), description="""
Indicate that the target should be considered unrooted; do not
attempt sudo or ask the user for their password.
"""),
], ],
} }
CONNECTION_PARAMS['ChromeOsConnection'] = \ CONNECTION_PARAMS['ChromeOsConnection'] = \
CONNECTION_PARAMS[AdbConnection] + CONNECTION_PARAMS[SshConnection] CONNECTION_PARAMS[AdbConnection] + CONNECTION_PARAMS[SshConnection]
# name --> ((target_class, conn_class), params_list, defaults) # name --> ((target_class, conn_class), params_list, defaults)
TARGETS = { TARGETS = {
'linux': ((LinuxTarget, SshConnection), COMMON_TARGET_PARAMS, None), 'linux': ((LinuxTarget, SshConnection), COMMON_TARGET_PARAMS, None),
'android': ((AndroidTarget, AdbConnection), COMMON_TARGET_PARAMS + 'android': ((AndroidTarget, AdbConnection), COMMON_TARGET_PARAMS +
[Parameter('package_data_directory', kind=str, default='/data/data', [Parameter('package_data_directory', kind=str, default='/data/data',
description=''' description='''
Directory containing Android data Directory containing Android data
'''), '''),
], None), ], None),
'chromeos': ((ChromeOsTarget, 'ChromeOsConnection'), COMMON_TARGET_PARAMS + 'chromeos': ((ChromeOsTarget, 'ChromeOsConnection'), COMMON_TARGET_PARAMS +
[Parameter('package_data_directory', kind=str, default='/data/data', [Parameter('package_data_directory', kind=str, default='/data/data',
description=''' description='''
@ -524,7 +544,6 @@ class DefaultTargetDescriptor(TargetDescriptor):
return cls, updated_params return cls, updated_params
_adhoc_target_descriptions = [] _adhoc_target_descriptions = []

View File

@ -130,7 +130,7 @@ class CpuidleInfo(object):
def __repr__(self): def __repr__(self):
return 'Cpuidle({}/{} {} states)'.format( return 'Cpuidle({}/{} {} states)'.format(
self.governor, self.driver, self.num_states) self.governor, self.driver, self.num_states)
__str__ = __repr__ __str__ = __repr__

View File

@ -53,7 +53,6 @@ class TargetManager(object):
self.parameters = parameters self.parameters = parameters
self.disconnect = parameters.get('disconnect') self.disconnect = parameters.get('disconnect')
def initialize(self): def initialize(self):
self._init_target() self._init_target()

View File

@ -131,49 +131,46 @@ class HotplugRuntimeConfig(RuntimeConfig):
return return
param_name = 'num_cores' param_name = 'num_cores'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=int, RuntimeParameter(param_name, kind=int,
constraint=lambda x: constraint=lambda x: 0 <= x <= self.target.number_of_cpus,
0 <= x <= self.target.number_of_cpus, description="""
description=""" The number of cpu cores to be online
The number of cpu cores to be online """,
""", setter=self.set_num_cores,
setter=self.set_num_cores, setter_params={'core': None})
setter_params={'core': None})
for name in unique(self.target.platform.core_names): for name in unique(self.target.platform.core_names):
param_name = 'num_{}_cores'.format(name) param_name = 'num_{}_cores'.format(name)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=int, RuntimeParameter(param_name, kind=int,
constraint=lambda x, name=name: constraint=lambda x, name=name: 0 <= x <= len(self.target.core_cpus(name)),
0 <= x <= len(self.target.core_cpus(name)), description="""
description=""" The number of {} cores to be online
The number of {} cores to be online """.format(name),
""".format(name), setter=self.set_num_cores,
setter=self.set_num_cores, setter_params={'core': name})
setter_params={'core': name})
for cpu_no in range(self.target.number_of_cpus): for cpu_no in range(self.target.number_of_cpus):
param_name = 'cpu{}_online'.format(cpu_no) param_name = 'cpu{}_online'.format(cpu_no)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=bool, RuntimeParameter(param_name, kind=bool,
description=""" description="""
Specify whether cpu{} should be online Specify whether cpu{} should be online
""".format(cpu_no), """.format(cpu_no),
setter=self.set_num_cores, setter=self.set_num_cores,
setter_params={'core': cpu_no}) setter_params={'core': cpu_no})
if self.target.has('bl'): if self.target.has('bl'):
for cluster in ['big', 'little']: for cluster in ['big', 'little']:
param_name = 'num_{}_cores'.format(cluster) param_name = 'num_{}_cores'.format(cluster)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=int, RuntimeParameter(param_name, kind=int,
constraint=lambda x, cluster=cluster: constraint=lambda x, c=cluster: 0 <= x <= len(resolve_cpus(c, self.target)),
0 <= x <= len(resolve_cpus(cluster, self.target)), description="""
description=""" The number of cores on the {} cluster to be online
The number of cores on the {} cluster to be online """.format(cluster),
""".format(cluster), setter=self.set_num_cores,
setter=self.set_num_cores, setter_params={'core': cluster})
setter_params={'core': cluster})
def check_target(self): def check_target(self):
if not self.target.has('hotplug'): if not self.target.has('hotplug'):
@ -224,11 +221,11 @@ class SysfileValuesRuntimeConfig(RuntimeConfig):
def initialize(self): def initialize(self):
self._runtime_params['sysfile_values'] = \ self._runtime_params['sysfile_values'] = \
RuntimeParameter('sysfile_values', kind=dict, merge=True, RuntimeParameter('sysfile_values', kind=dict, merge=True,
setter=self.set_sysfile, setter=self.set_sysfile,
setter_params={'core': None}, setter_params={'core': None},
description=""" description="""
Sysfile path to be set Sysfile path to be set
""") """)
def check_target(self): def check_target(self):
return True return True
@ -334,49 +331,54 @@ class CpufreqRuntimeConfig(RuntimeConfig):
freq_val = FreqValue(common_freqs) freq_val = FreqValue(common_freqs)
param_name = 'frequency' param_name = 'frequency'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(
setter=self.set_frequency, param_name, kind=freq_val,
setter_params={'core': None}, setter=self.set_frequency,
description=""" setter_params={'core': None},
The desired frequency for all cores description="""
""") The desired frequency for all cores
""")
param_name = 'max_frequency' param_name = 'max_frequency'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(
setter=self.set_max_frequency, param_name, kind=freq_val,
setter_params={'core': None}, setter=self.set_max_frequency,
description=""" setter_params={'core': None},
The maximum frequency for all cores description="""
""") The maximum frequency for all cores
""")
param_name = 'min_frequency' param_name = 'min_frequency'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(
setter=self.set_min_frequency, param_name, kind=freq_val,
setter_params={'core': None}, setter=self.set_min_frequency,
description=""" setter_params={'core': None},
The minimum frequency for all cores description="""
""") The minimum frequency for all cores
""")
if common_gov: if common_gov:
param_name = 'governor' param_name = 'governor'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=str, RuntimeParameter(
allowed_values=common_gov, param_name, kind=str,
setter=self.set_governor, allowed_values=common_gov,
setter_params={'core': None}, setter=self.set_governor,
description=""" setter_params={'core': None},
The governor to be set for all cores description="""
""") The governor to be set for all cores
""")
param_name = 'governor_tunables' param_name = 'governor_tunables'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=dict, RuntimeParameter(
merge=True, param_name, kind=dict,
setter=self.set_governor_tunables, merge=True,
setter_params={'core': None}, setter=self.set_governor_tunables,
description=""" setter_params={'core': None},
The governor tunables to be set for all cores description="""
""") The governor tunables to be set for all cores
""")
# Add core name parameters # Add core name parameters
for name in unique(self.target.platform.core_names): for name in unique(self.target.platform.core_names):
@ -386,46 +388,51 @@ class CpufreqRuntimeConfig(RuntimeConfig):
param_name = '{}_frequency'.format(name) param_name = '{}_frequency'.format(name)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(
setter=self.set_frequency, param_name, kind=freq_val,
setter_params={'core': name}, setter=self.set_frequency,
description=""" setter_params={'core': name},
The desired frequency for the {} cores description="""
""".format(name)) The desired frequency for the {} cores
""".format(name))
param_name = '{}_max_frequency'.format(name) param_name = '{}_max_frequency'.format(name)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(
setter=self.set_max_frequency, param_name, kind=freq_val,
setter_params={'core': name}, setter=self.set_max_frequency,
description=""" setter_params={'core': name},
The maximum frequency for the {} cores description="""
""".format(name)) The maximum frequency for the {} cores
""".format(name))
param_name = '{}_min_frequency'.format(name) param_name = '{}_min_frequency'.format(name)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(
setter=self.set_min_frequency, param_name, kind=freq_val,
setter_params={'core': name}, setter=self.set_min_frequency,
description=""" setter_params={'core': name},
The minimum frequency for the {} cores description="""
""".format(name)) The minimum frequency for the {} cores
""".format(name))
param_name = '{}_governor'.format(name) param_name = '{}_governor'.format(name)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=str, RuntimeParameter(
allowed_values=avail_govs, param_name, kind=str,
setter=self.set_governor, allowed_values=avail_govs,
setter_params={'core': name}, setter=self.set_governor,
description=""" setter_params={'core': name},
The governor to be set for the {} cores description="""
""".format(name)) The governor to be set for the {} cores
""".format(name))
param_name = '{}_gov_tunables'.format(name) param_name = '{}_gov_tunables'.format(name)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=dict, RuntimeParameter(
setter=self.set_governor_tunables, param_name, kind=dict,
setter_params={'core': name}, setter=self.set_governor_tunables,
merge=True, setter_params={'core': name},
description=""" merge=True,
The governor tunables to be set for the {} cores description="""
""".format(name)) The governor tunables to be set for the {} cores
""".format(name))
# Add cpuX parameters. # Add cpuX parameters.
for cpu_no in range(self.target.number_of_cpus): for cpu_no in range(self.target.number_of_cpus):
@ -434,46 +441,51 @@ class CpufreqRuntimeConfig(RuntimeConfig):
param_name = 'cpu{}_frequency'.format(cpu_no) param_name = 'cpu{}_frequency'.format(cpu_no)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(
setter=self.set_frequency, param_name, kind=freq_val,
setter_params={'core': cpu_no}, setter=self.set_frequency,
description=""" setter_params={'core': cpu_no},
The desired frequency for cpu{} description="""
""".format(cpu_no)) The desired frequency for cpu{}
""".format(cpu_no))
param_name = 'cpu{}_max_frequency'.format(cpu_no) param_name = 'cpu{}_max_frequency'.format(cpu_no)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(
setter=self.set_max_frequency, param_name, kind=freq_val,
setter_params={'core': cpu_no}, setter=self.set_max_frequency,
description=""" setter_params={'core': cpu_no},
The maximum frequency for cpu{} description="""
""".format(cpu_no)) The maximum frequency for cpu{}
""".format(cpu_no))
param_name = 'cpu{}_min_frequency'.format(cpu_no) param_name = 'cpu{}_min_frequency'.format(cpu_no)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(
setter=self.set_min_frequency, param_name, kind=freq_val,
setter_params={'core': cpu_no}, setter=self.set_min_frequency,
description=""" setter_params={'core': cpu_no},
The minimum frequency for cpu{} description="""
""".format(cpu_no)) The minimum frequency for cpu{}
""".format(cpu_no))
param_name = 'cpu{}_governor'.format(cpu_no) param_name = 'cpu{}_governor'.format(cpu_no)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=str, RuntimeParameter(
allowed_values=avail_govs, param_name, kind=str,
setter=self.set_governor, allowed_values=avail_govs,
setter_params={'core': cpu_no}, setter=self.set_governor,
description=""" setter_params={'core': cpu_no},
The governor to be set for cpu{} description="""
""".format(cpu_no)) The governor to be set for cpu{}
""".format(cpu_no))
param_name = 'cpu{}_gov_tunables'.format(cpu_no) param_name = 'cpu{}_gov_tunables'.format(cpu_no)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=dict, RuntimeParameter(
setter=self.set_governor_tunables, param_name, kind=dict,
setter_params={'core': cpu_no}, setter=self.set_governor_tunables,
merge=True, setter_params={'core': cpu_no},
description=""" merge=True,
The governor tunables to be set for cpu{} description="""
""".format(cpu_no)) The governor tunables to be set for cpu{}
""".format(cpu_no))
# Add big.little cores if present on device. # Add big.little cores if present on device.
if self.target.has('bl'): if self.target.has('bl'):
@ -484,46 +496,51 @@ class CpufreqRuntimeConfig(RuntimeConfig):
param_name = '{}_frequency'.format(cluster) param_name = '{}_frequency'.format(cluster)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(
setter=self.set_frequency, param_name, kind=freq_val,
setter_params={'core': cluster}, setter=self.set_frequency,
description=""" setter_params={'core': cluster},
The desired frequency for the {} cluster description="""
""".format(cluster)) The desired frequency for the {} cluster
""".format(cluster))
param_name = '{}_max_frequency'.format(cluster) param_name = '{}_max_frequency'.format(cluster)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(
setter=self.set_max_frequency, param_name, kind=freq_val,
setter_params={'core': cluster}, setter=self.set_max_frequency,
description=""" setter_params={'core': cluster},
The maximum frequency for the {} cluster description="""
""".format(cluster)) The maximum frequency for the {} cluster
""".format(cluster))
param_name = '{}_min_frequency'.format(cluster) param_name = '{}_min_frequency'.format(cluster)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(
setter=self.set_min_frequency, param_name, kind=freq_val,
setter_params={'core': cluster}, setter=self.set_min_frequency,
description=""" setter_params={'core': cluster},
The minimum frequency for the {} cluster description="""
""".format(cluster)) The minimum frequency for the {} cluster
""".format(cluster))
param_name = '{}_governor'.format(cluster) param_name = '{}_governor'.format(cluster)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=str, RuntimeParameter(
allowed_values=avail_govs, param_name, kind=str,
setter=self.set_governor, allowed_values=avail_govs,
setter_params={'core': cluster}, setter=self.set_governor,
description=""" setter_params={'core': cluster},
The governor to be set for the {} cores description="""
""".format(cluster)) The governor to be set for the {} cores
""".format(cluster))
param_name = '{}_gov_tunables'.format(cluster) param_name = '{}_gov_tunables'.format(cluster)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=dict, RuntimeParameter(
setter=self.set_governor_tunables, param_name, kind=dict,
setter_params={'core': cluster}, setter=self.set_governor_tunables,
merge=True, setter_params={'core': cluster},
description=""" merge=True,
The governor tunables to be set for the {} cores description="""
""".format(cluster)) The governor tunables to be set for the {} cores
""".format(cluster))
def check_target(self): def check_target(self):
if not self.target.has('cpufreq'): if not self.target.has('cpufreq'):
@ -679,6 +696,7 @@ class CpufreqRuntimeConfig(RuntimeConfig):
return all_freqs, common_freqs, common_gov return all_freqs, common_freqs, common_gov
class IdleStateValue(object): class IdleStateValue(object):
def __init__(self, values): def __init__(self, values):
@ -750,35 +768,38 @@ class CpuidleRuntimeConfig(RuntimeConfig):
if common_idle_states: if common_idle_states:
param_name = 'idle_states' param_name = 'idle_states'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=idle_state_val, RuntimeParameter(
setter=self.set_idle_state, param_name, kind=idle_state_val,
setter_params={'core': None}, setter=self.set_idle_state,
description=""" setter_params={'core': None},
The idle states to be set for all cores description="""
""") The idle states to be set for all cores
""")
for name in unique(self.target.platform.core_names): for name in unique(self.target.platform.core_names):
cpu = resolve_cpus(name, self.target)[0] cpu = resolve_cpus(name, self.target)[0]
idle_state_val = IdleStateValue(self.supported_idle_states.get(cpu)) idle_state_val = IdleStateValue(self.supported_idle_states.get(cpu))
param_name = '{}_idle_states'.format(name) param_name = '{}_idle_states'.format(name)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=idle_state_val, RuntimeParameter(
setter=self.set_idle_state, param_name, kind=idle_state_val,
setter_params={'core': name}, setter=self.set_idle_state,
description=""" setter_params={'core': name},
The idle states to be set for {} cores description="""
""".format(name)) The idle states to be set for {} cores
""".format(name))
for cpu_no in range(self.target.number_of_cpus): for cpu_no in range(self.target.number_of_cpus):
idle_state_val = IdleStateValue(self.supported_idle_states.get(cpu_no)) idle_state_val = IdleStateValue(self.supported_idle_states.get(cpu_no))
param_name = 'cpu{}_idle_states'.format(cpu_no) param_name = 'cpu{}_idle_states'.format(cpu_no)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=idle_state_val, RuntimeParameter(
setter=self.set_idle_state, param_name, kind=idle_state_val,
setter_params={'core': cpu_no}, setter=self.set_idle_state,
description=""" setter_params={'core': cpu_no},
The idle states to be set for cpu{} description="""
""".format(cpu_no)) The idle states to be set for cpu{}
""".format(cpu_no))
if self.target.has('bl'): if self.target.has('bl'):
for cluster in ['big', 'little']: for cluster in ['big', 'little']:
@ -786,12 +807,13 @@ class CpuidleRuntimeConfig(RuntimeConfig):
idle_state_val = IdleStateValue(self.supported_idle_states.get(cpu)) idle_state_val = IdleStateValue(self.supported_idle_states.get(cpu))
param_name = '{}_idle_states'.format(cluster) param_name = '{}_idle_states'.format(cluster)
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=idle_state_val, RuntimeParameter(
setter=self.set_idle_state, param_name, kind=idle_state_val,
setter_params={'core': cluster}, setter=self.set_idle_state,
description=""" setter_params={'core': cluster},
The idle states to be set for the {} cores description="""
""".format(cluster)) The idle states to be set for the {} cores
""".format(cluster))
def check_target(self): def check_target(self):
if not self.target.has('cpuidle'): if not self.target.has('cpuidle'):
@ -826,6 +848,7 @@ class CpuidleRuntimeConfig(RuntimeConfig):
common_idle_states.append(state) common_idle_states.append(state)
return common_idle_states return common_idle_states
ScreenOrientation = enum(['NATURAL', 'LEFT', 'INVERTED', 'RIGHT']) ScreenOrientation = enum(['NATURAL', 'LEFT', 'INVERTED', 'RIGHT'])
@ -865,41 +888,45 @@ class AndroidRuntimeConfig(RuntimeConfig):
param_name = 'brightness' param_name = 'brightness'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=int, RuntimeParameter(
constraint=lambda x: 0 <= x <= 255, param_name, kind=int,
default=127, constraint=lambda x: 0 <= x <= 255,
setter=self.set_brightness, default=127,
description=""" setter=self.set_brightness,
Specify the screen brightness to be set for description="""
the device Specify the screen brightness to be set for
""") the device
""")
if self.target.os == 'android': if self.target.os == 'android':
param_name = 'airplane_mode' param_name = 'airplane_mode'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=bool, RuntimeParameter(
setter=self.set_airplane_mode, param_name, kind=bool,
description=""" setter=self.set_airplane_mode,
Specify whether airplane mode should be description="""
enabled for the device Specify whether airplane mode should be
""") enabled for the device
""")
param_name = 'rotation' param_name = 'rotation'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=ScreenOrientation, RuntimeParameter(
setter=self.set_rotation, param_name, kind=ScreenOrientation,
description=""" setter=self.set_rotation,
Specify the screen orientation for the device description="""
""") Specify the screen orientation for the device
""")
param_name = 'screen_on' param_name = 'screen_on'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=bool, RuntimeParameter(
default=True, param_name, kind=bool,
setter=self.set_screen_state, default=True,
description=""" setter=self.set_screen_state,
Specify whether the device screen should be on description="""
""") Specify whether the device screen should be on
""")
def check_target(self): def check_target(self):
if self.target.os != 'android' and self.target.os != 'chromeos': if self.target.os != 'android' and self.target.os != 'chromeos':

View File

@ -114,7 +114,6 @@ class Workload(TargetedPlugin):
'Workload "{}" requires internet. Target does not appear ' 'Workload "{}" requires internet. Target does not appear '
'to be connected to the internet.'.format(self.name)) 'to be connected to the internet.'.format(self.name))
def run(self, context): def run(self, context):
""" """
Execute the workload. This is the method that performs the actual Execute the workload. This is the method that performs the actual
@ -288,7 +287,6 @@ class ApkWorkload(Workload):
super(ApkWorkload, self).teardown(context) super(ApkWorkload, self).teardown(context)
self.apk.teardown() self.apk.teardown()
def deploy_assets(self, context): def deploy_assets(self, context):
super(ApkWorkload, self).deploy_assets(context) super(ApkWorkload, self).deploy_assets(context)
self.target.refresh_files(self.deployed_assets) self.target.refresh_files(self.deployed_assets)
@ -373,6 +371,7 @@ class ApkReventWorkload(ApkUIWorkload):
self.extract_results_timeout, self.extract_results_timeout,
self.teardown_timeout) self.teardown_timeout)
class UIWorkload(Workload): class UIWorkload(Workload):
def __init__(self, target, **kwargs): def __init__(self, target, **kwargs):
@ -459,7 +458,6 @@ class ReventWorkload(UIWorkload):
self.teardown_timeout) self.teardown_timeout)
class UiAutomatorGUI(object): class UiAutomatorGUI(object):
stages = ['setup', 'runWorkload', 'extractResults', 'teardown'] stages = ['setup', 'runWorkload', 'extractResults', 'teardown']
@ -571,12 +569,12 @@ class ReventGUI(object):
stage='run', stage='run',
target=self.target.model)) target=self.target.model))
self.revent_extract_results_file = resolver.get(ReventFile(owner=self.workload, self.revent_extract_results_file = resolver.get(ReventFile(owner=self.workload,
stage='extract_results', stage='extract_results',
target=self.target.model), target=self.target.model),
strict=False) strict=False)
self.revent_teardown_file = resolver.get(resource=ReventFile(owner=self.workload, self.revent_teardown_file = resolver.get(resource=ReventFile(owner=self.workload,
stage='teardown', stage='teardown',
target=self.target.model), target=self.target.model),
strict=False) strict=False)
def deploy(self): def deploy(self):
@ -833,7 +831,7 @@ class PackageHandler(object):
raise WorkloadError(message.format(package)) raise WorkloadError(message.format(package))
package_info = self.target.get_package_info(package) package_info = self.target.get_package_info(package)
self.target.pull(package_info.apk_path, self.owner.dependencies_directory, self.target.pull(package_info.apk_path, self.owner.dependencies_directory,
timeout=self.install_timeout) timeout=self.install_timeout)
apk_name = self.target.path.basename(package_info.apk_path) apk_name = self.target.path.basename(package_info.apk_path)
return os.path.join(self.owner.dependencies_directory, apk_name) return os.path.join(self.owner.dependencies_directory, apk_name)