Exemplo n.º 1
0
 def _get_fastest_cpu(self):
     cpu_types = set(self.device.core_names)
     if len(cpu_types) == 1:
         return cpu_types.pop()
     fastest_cpu = None
     fastest_freq = 0
     for cpu_type in cpu_types:
         try:
             idx = self.device.get_core_online_cpu(cpu_type)
             freq = self.device.get_cpu_max_frequency(idx)
             if freq > fastest_freq:
                 fastest_freq = freq
                 fastest_cpu = cpu_type
         except ValueError:
             pass
     if not fastest_cpu:
         raise WorkloadError(
             'No active CPUs found on device. Something is very wrong...')
     return fastest_cpu
Exemplo n.º 2
0
    def _deploy_resource_tarball(self, context, resource_file, timeout=300):
        kind = 'data'
        if ':' in resource_file:
            kind, resource_file = resource_file.split(':', 1)
        ondevice_cache = self.device.path.join(self.device.resource_cache, self.name, resource_file)
        if not self.device.file_exists(ondevice_cache):
            asset_tarball = context.resolver.get(ExtensionAsset(self, resource_file))
            if not asset_tarball:
                message = 'Could not find resource {} for workload {}.'
                raise WorkloadError(message.format(resource_file, self.name))
            # adb push will create intermediate directories if they don't
            # exist.
            self.device.push_file(asset_tarball, ondevice_cache)

        device_asset_directory = self.device.path.join(self.device.external_storage_directory, 'Android', kind)
        deploy_command = 'cd {} && {} tar -xzf {}'.format(device_asset_directory,
                                                          self.device.busybox,
                                                          ondevice_cache)
        self.device.execute(deploy_command, timeout=timeout, as_root=True)
Exemplo n.º 3
0
 def install_apk(self, context, replace=False):
     success = False
     if replace and self.device.package_is_installed(self.package):
         self.device.uninstall(self.package)
     output = self.device.install_apk(self.apk_file,
                                      timeout=self.install_timeout,
                                      replace=replace,
                                      allow_downgrade=True)
     if 'Failure' in output:
         if 'ALREADY_EXISTS' in output:
             self.logger.warn(
                 'Using already installed APK (did not unistall properly?)')
             self.reset(context)
         else:
             raise WorkloadError(output)
     else:
         self.logger.debug(output)
         success = True
     self.do_post_install(context)
     return success
Exemplo n.º 4
0
 def non_root_update_result(self, context):
     failed = []
     with open(self.logcat_log) as fh:
         iteration_result_regex = re.compile(
             "VELLAMO RESULT: (Browser|Metal|Multicore) (\d+)")
         for line in fh:
             if 'VELLAMO ERROR:' in line:
                 self.logger.warning(
                     "Browser crashed during benchmark, results may not be accurate"
                 )
             result = iteration_result_regex.findall(line)
             if result:
                 for (metric, score) in result:
                     if not score:
                         failed.append(metric)
                     else:
                         context.result.add_metric(metric, score)
     if failed:
         raise WorkloadError(
             "The following benchmark groups failed: {}".format(
                 ", ".join(failed)))
Exemplo n.º 5
0
 def build_command(self):
     device_opts = ''
     if self.target_config:
         device_opts = self.target_config
     else:
         if self.device.platform == 'chromeos':
             if '--remote' not in self.run_benchmark_params:
                 device_opts += '--remote={} '.format(self.device.host)
             if '--browser' not in self.run_benchmark_params:
                 device_opts += '--browser=cros-chrome '
         elif self.device.platform == 'android':
             if '--device' not in self.run_benchmark_params and self.device.adb_name:
                 device_opts += '--device={} '.format(self.device.adb_name)
             if '--browser' not in self.run_benchmark_params:
                 device_opts += '--browser=android-webview-shell '
         else:
             raise WorkloadError(
                 'Unless you\'re running Telemetry on a ChromeOS or Android device, '
                 'you mast specify target_config option')
     return '{} {} {} {}'.format(self.run_benchmark_path, self.test,
                                 device_opts, self.run_benchmark_params)
Exemplo n.º 6
0
 def non_root_update_result(self, context):
     failed = []
     with open(self.logcat_log) as logcat:
         metrics = OrderedDict()
         for line in logcat:
             if 'VELLAMO RESULT:' in line:
                 info = line.split(':')
                 parts = info[2].split(" ")
                 metric = parts[1].strip()
                 value = int(parts[2].strip())
                 metrics[metric] = value
             if 'VELLAMO ERROR:' in line:
                 self.logger.warning(
                     "Browser crashed during benchmark, results may not be accurate"
                 )
         for key, value in metrics.iteritems():
             key = key.replace(' ', '_')
             context.result.add_metric(key, value)
             if value == 0:
                 failed.append(key)
     if failed:
         raise WorkloadError(
             "The following benchmark groups failed: {}".format(
                 ", ".join(failed)))
Exemplo n.º 7
0
 def initialise(self, context):  # pylint: disable=no-self-use
     if context.device.get_sdk_version() < 23:
         raise WorkloadError("This workload relies on ``dumpsys gfxinfo`` \
                              only present in Android M and onwards")
Exemplo n.º 8
0
 def validate(self):
     if not self.apk_file:
         raise WorkloadError('No APK file found for workload {}.'.format(self.name))
Exemplo n.º 9
0
 def start_activity(self):
     output = self.device.execute('am start -W -n {}/{}'.format(self.package, self.activity))
     if 'Error:' in output:
         self.device.execute('am force-stop {}'.format(self.package))  # this will dismiss any erro dialogs
         raise WorkloadError(output)
     self.logger.debug(output)
Exemplo n.º 10
0
 def validate(self):
     if not self.uiauto_file:
         raise WorkloadError('No UI automation JAR file found for workload {}.'.format(self.name))
     if not self.uiauto_package:
         raise WorkloadError('No UI automation package specified for workload {}.'.format(self.name))
 def initialize(self, context):
     if self.version == '3' and not self.device.is_rooted:
         raise WorkloadError(
             'Geekbench workload only works on rooted devices.')
Exemplo n.º 12
0
 def initialize(self, context):
     if not self.device.is_rooted:
         raise WorkloadError('stress-ng requires root premissions to run')
Exemplo n.º 13
0
 def check_network_connected(self):
     if not self.device.is_network_connected():
         message = 'Workload "{}" requires internet. Device "{}" does not appear to be connected to the internet.'
         raise WorkloadError(message.format(self.name, self.device.name))
Exemplo n.º 14
0
 def initialize(self, context):
     if not self.device.is_rooted:
         raise WorkloadError('Androbench workload only works on rooted devices.')
Exemplo n.º 15
0
def find_line_with(text, fh):
    for line in fh:
        if text in line:
            return
    message = 'Could not extract sysbench results from {}; did not see "{}"'
    raise WorkloadError(message.format(fh.name, text))