Esempio n. 1
0
    def on_run_init(self, context):
        try:
            self.host_daemon_file = context.resolver.get(File(self, self.daemon))
            self.logger.debug('Using daemon from {}.'.format(self.host_daemon_file))
            self.device.killall(self.daemon)  # in case a version is already running
            self.device.install(self.host_daemon_file)
        except ResourceError:
            self.logger.debug('Using on-device daemon.')

        try:
            self.host_driver_file = context.resolver.get(File(self, self.driver))
            self.logger.debug('Using driver from {}.'.format(self.host_driver_file))
            self.device_driver_file = self.device.install(self.host_driver_file)
        except ResourceError:
            self.logger.debug('Using on-device driver.')

        try:
            self.configuration_file = (os.path.expanduser(self.configxml or '') or
                                       context.resolver.get(File(self, self.configuration_file_name)))
            self.logger.debug('Using {}'.format(self.configuration_file))
            self.on_device_config = self.device.path.join(self.device.working_directory, 'configuration.xml')
            shutil.copy(self.configuration_file, settings.meta_directory)
        except ResourceError:
            self.logger.debug('No configuration file was specfied.')

        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:
            wfh.write(SESSION_TEXT_TEMPLATE.format(self.port, caiman_path))
Esempio n. 2
0
 def setup(self, context):
     self.defs_host = context.resolver.get(File(self, "defs.sh"))
     self.defs_target = self.device.install(self.defs_host)
     self.recentfling_host = context.resolver.get(
         File(self, "recentfling.sh"))
     self.recentfling_target = self.device.install(self.recentfling_host)
     self._kill_recentfling()
     self.device.ensure_screen_is_on()
Esempio n. 3
0
 def setup(self, context):
     self.defs_host = context.resolver.get(File(self, "defs.sh"))
     self.recentfling_host = context.resolver.get(
         File(self, "recentfling.sh"))
     self.device.push_file(self.recentfling_host,
                           self.device.working_directory)
     self.device.push_file(self.defs_host, self.device.working_directory)
     self._kill_recentfling()
     self.device.ensure_screen_is_on()
Esempio n. 4
0
 def initialize(self, context):
     self.number_of_cpus = {}
     self.report_template_file = context.resolver.get(File(self, REPORT_TEMPLATE_FILE))
     self.em_template_file = context.resolver.get(File(self, EM_TEMPLATE_FILE))
     self.little_core = (set(self.device.core_names) - set([self.big_core])).pop()
     self.perform_runtime_validation()
     self.enable_all_cores()
     self.configure_clusters()
     self.discover_idle_states()
     self.disable_thermal_management()
     self.initialize_job_queue(context)
     self.initialize_result_tracking()
Esempio n. 5
0
 def _get_raw_json_config(self, resolver):
     if os.path.splitext(self.config)[1] != '.json':
         self.config += '.json'
     if os.path.isfile(self.config):
         return os.path.abspath(self.config)
     partial_path = os.path.join('use_cases', self.config)
     return resolver.get(File(self, partial_path))
Esempio n. 6
0
 def _read_map(self, context, filename, errormsg):
     mapfile = context.resolver.get(File(self, filename))
     if mapfile:
         with open(mapfile) as fh:
             reader = csv.reader(fh)
             return dict([c.strip() for c in r] for r in reader)
     else:
         self.logger.warning(errormsg)
         return {}
Esempio n. 7
0
 def setup(self, context):
     if self.version == "6.0.1":
         antutu_3d = context.resolver.get(File(self, "com.antutu.benchmark.full-1.apk"))
         info = ApkInfo(antutu_3d)
         if not context.device.is_installed(info.package):
             self.device.install_apk(antutu_3d, timeout=120)
         # Antutu doesnt seem to list this as one of its permissions, but it asks for it.
         self.device.execute("pm grant com.antutu.ABenchMark android.permission.ACCESS_FINE_LOCATION")
     super(Antutu, self).setup(context)
Esempio n. 8
0
 def initialize(self, context):
     # initialize() runs once per run. setting a class variable to make it
     # available to other instances of the workload
     RtApp.device_working_directory = self.device.path.join(self.device.working_directory,
                                                            'rt-app-working')
     RtApp.host_binary = context.resolver.get(Executable(self,
                                                         self.device.abi,
                                                         BINARY_NAME), strict=False)
     RtApp.workgen_script = context.resolver.get(File(self, 'workgen'))
     if not self.device.is_rooted:  # some use cases require root privileges
         raise WorkloadError('rt-app requires the device to be rooted.')
     self.device.execute('mkdir -p {}'.format(self.device_working_directory))
     self._deploy_rt_app_binary_if_necessary()
Esempio n. 9
0
 def setup(self, context):
     if self.version == "6.0.1":
         antutu_3d = context.resolver.get(
             File(self, "com.antutu.benchmark.full-1.apk"))
         info = ApkInfo(antutu_3d)
         if not context.device.is_installed(info.package):
             self.device.install_apk(antutu_3d, timeout=120)
         if self.device.get_sdk_version() >= 23:
             # Antutu doesnt seem to list this as one of its permissions, but on some devices it asks for it.
             try:
                 self.device.execute(
                     "pm grant com.antutu.ABenchMark android.permission.ACCESS_FINE_LOCATION"
                 )
             except DeviceError:
                 self.logger.debug(
                     "failed to grant ACCESS_FINE_LOCATION, continuing")
     super(Antutu, self).setup(context)
Esempio n. 10
0
 def on_run_init(self, context):
     local_file = context.resolver.get(File(self, 'readenergy'))
     self.device.killall('readenergy', as_root=True)
     self.readenergy = self.device.install(local_file)
Esempio n. 11
0
    def execute(self, args):
        self.logger.debug('Program arguments: {}'.format(vars(args)))
        if args.force:
            self.logger.info('Force-download of assets requested')
        if not args.url:
            self.logger.debug(
                'URL not provided, falling back to default setting in config')
        self.logger.info('Downloading external assets from {}'.format(
            args.url))

        # Get file index of assets
        ext_loader = ExtensionLoader(packages=settings.extension_packages,
                                     paths=settings.extension_paths)
        getter = ext_loader.get_resource_getter('http_assets',
                                                None,
                                                url=args.url,
                                                always_fetch=args.force)
        try:
            getter.index = getter.fetch_index()
        except (ConnectionError, RequestException) as e:
            self.exit_with_error(str(e))
        all_assets = dict()
        for k, v in getter.index.iteritems():
            all_assets[str(k)] = [str(asset['path']) for asset in v]

        # Here we get a list of all extensions present in the current WA installation,
        # and cross-check that against the list of extensions whose assets are requested.
        # The aim is to avoid downloading assets for extensions that do not exist, since
        # WA extensions and asset index can be updated independently and go out of sync.
        all_extensions = [ext.name for ext in ext_loader.list_extensions()]
        assets_to_get = set(all_assets).intersection(all_extensions)
        if args.exts:
            assets_to_get = assets_to_get.intersection(args.exts)
        # Check list is not empty
        if not assets_to_get:
            if args.all:
                self.exit_with_error('Could not find extensions: {}'.format(
                    ', '.join(all_assets.keys())))
            else:  # args.exts
                self.exit_with_error(
                    'Asset index has no entries for: {}'.format(', '.join(
                        args.exts)))

        # Check out of sync extensions i.e. do not exist in both WA and assets index
        missing = set(all_assets).difference(all_extensions) | set(
            args.exts or []).difference(all_assets)
        if missing:
            self.logger.warning(
                'Not getting assets for missing extensions: {}'.format(
                    ', '.join(missing)))

        # Ideally the extension loader would be used to instantiate, but it does full
        # validation of the extension, like checking connected devices or supported
        # platform(s). This info might be unavailable and is not required to download
        # assets, since they are classified by extension name alone. So instead we use
        # a simple subclass of ``Extension`` providing a valid ``name`` attribute.
        for ext_name in assets_to_get:
            owner = _instantiate(NamedExtension, ext_name)
            self.logger.info('Getting assets for: {}'.format(ext_name))
            for asset in all_assets[ext_name]:
                getter.get(File(owner, asset))  # Download the files
Esempio n. 12
0
 def initialize(self, context):
     file_resource = File(self, self.notebook_template)
     self.notebook_template_file = context.resolver.get(file_resource)
     nbbasename_template = self.notebook_name_prefix + '%y%m%d-%H%M%S.ipynb'
     self.nbbasename = datetime.now().strftime(nbbasename_template)
Esempio n. 13
0
    def setup(self, context):
        apk_file = context.resolver.get(File(self, self.apk_file))
        self.package = ApkInfo(apk_file).package  # pylint: disable=attribute-defined-outside-init

        self.logger.info('Installing {}'.format(apk_file))
        return self.device.install(apk_file)