diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-06-18 07:31:56 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-06-18 07:31:56 +0000 |
commit | 1a3d95b73cd016850033b8e2730e9607fe0f652e (patch) | |
tree | 591cba4ff7d57fb995b19d5b0088b1151787bfbe | |
parent | dbc9fdda5cb3c65633057ff892c425170f5d0f29 (diff) | |
parent | 4bf0be2f1f065bdbeb5e55f86280147fc18b8ae7 (diff) | |
download | devlib-1a3d95b73cd016850033b8e2730e9607fe0f652e.tar.gz |
release-request-c9e3b153-009d-4386-b83e-337752602795-for-git_oc-mr1-release-4111654 snap-temp-L22900000075285650
Change-Id: I6169e709d4f6ab9a04c5c2fff68de40b22746cda
-rw-r--r-- | devlib/instrument/monsoon.py | 4 | ||||
-rw-r--r-- | devlib/module/cpufreq.py | 11 | ||||
-rw-r--r-- | devlib/target.py | 28 | ||||
-rw-r--r-- | devlib/utils/ssh.py | 54 | ||||
-rw-r--r-- | setup.py | 1 |
5 files changed, 76 insertions, 22 deletions
diff --git a/devlib/instrument/monsoon.py b/devlib/instrument/monsoon.py index df908b1..dd99df0 100644 --- a/devlib/instrument/monsoon.py +++ b/devlib/instrument/monsoon.py @@ -14,8 +14,8 @@ MonsoonInstrument requires the monsoon.py tool, available from AOSP: https://android.googlesource.com/platform/cts/+/master/tools/utils/monsoon.py Download this script and put it in your $PATH (or pass it as the monsoon_bin -parameter to MonsoonInstrument). `pip install gflags pyserial` to install the -dependencies. +parameter to MonsoonInstrument). `pip install python-gflags pyserial` to install +the dependencies. """ class MonsoonInstrument(Instrument): diff --git a/devlib/module/cpufreq.py b/devlib/module/cpufreq.py index d72b8fd..01fb79b 100644 --- a/devlib/module/cpufreq.py +++ b/devlib/module/cpufreq.py @@ -421,3 +421,14 @@ class CpufreqModule(Module): sysfile = '/sys/devices/system/cpu/{}/cpufreq/affected_cpus'.format(cpu) return [int(c) for c in self.target.read_value(sysfile).split()] + + def iter_domains(self): + """ + Iterate over the frequency domains in the system + """ + cpus = set(range(self.target.number_of_cpus)) + while cpus: + cpu = iter(cpus).next() + domain = self.target.cpufreq.get_domain_cpus(cpu) + yield domain + cpus = cpus.difference(domain) diff --git a/devlib/target.py b/devlib/target.py index 5bddad4..35473b4 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -4,6 +4,7 @@ import time import logging import posixpath import subprocess +import tarfile import tempfile import threading from collections import namedtuple @@ -281,6 +282,33 @@ class Target(object): def pull(self, source, dest, timeout=None): return self.conn.pull(source, dest, timeout=timeout) + def get_directory(self, source_dir, dest): + """ Pull a directory from the device, after compressing dir """ + # Create all file names + tar_file_name = source_dir.lstrip(self.path.sep).replace(self.path.sep, '.') + # Host location of dir + outdir = os.path.join(dest, tar_file_name) + # Host location of archive + tar_file_name = '{}.tar'.format(tar_file_name) + tempfile = os.path.join(dest, tar_file_name) + + # Does the folder exist? + self.execute('ls -la {}'.format(source_dir)) + # Try compressing the folder + try: + self.execute('{} tar -cvf {} {}'.format(self.busybox, tar_file_name, + source_dir)) + except TargetError: + self.logger.debug('Failed to run tar command on target! ' \ + 'Not pulling directory {}'.format(source_dir)) + # Pull the file + os.mkdir(outdir) + self.pull(tar_file_name, tempfile ) + # Decompress + f = tarfile.open(tempfile, 'r') + f.extractall(outdir) + os.remove(tempfile) + # execution def execute(self, command, timeout=None, check_exit_code=True, as_root=False): diff --git a/devlib/utils/ssh.py b/devlib/utils/ssh.py index f87746a..8704008 100644 --- a/devlib/utils/ssh.py +++ b/devlib/utils/ssh.py @@ -439,26 +439,40 @@ class Gem5Connection(TelnetConnection): # First check if the connection is set up to interact with gem5 self._check_ready() - filename = os.path.basename(source) - - logger.debug("pull_file {} {}".format(source, filename)) - # We don't check the exit code here because it is non-zero if the source - # and destination are the same. The ls below will cause an error if the - # file was not where we expected it to be. - if os.path.dirname(source) != os.getcwd(): - self._gem5_shell("cat '{}' > '{}'".format(source, filename)) - self._gem5_shell("sync") - self._gem5_shell("ls -la {}".format(filename)) - logger.debug('Finished the copy in the simulator') - self._gem5_util("writefile {}".format(filename)) - - if 'cpu' not in filename: - while not os.path.exists(os.path.join(self.gem5_out_dir, filename)): - time.sleep(1) - - # Perform the local move - shutil.move(os.path.join(self.gem5_out_dir, filename), dest) - logger.debug("Pull complete.") + result = self._gem5_shell("ls {}".format(source)) + files = result.split() + + for filename in files: + dest_file = os.path.basename(filename) + logger.debug("pull_file {} {}".format(filename, dest_file)) + # writefile needs the file to be copied to be in the current + # working directory so if needed, copy to the working directory + # We don't check the exit code here because it is non-zero if the + # source and destination are the same. The ls below will cause an + # error if the file was not where we expected it to be. + if os.path.isabs(source): + if os.path.dirname(source) != self.execute('pwd', + check_exit_code=False): + self._gem5_shell("cat '{}' > '{}'".format(filename, + dest_file)) + self._gem5_shell("sync") + self._gem5_shell("ls -la {}".format(dest_file)) + logger.debug('Finished the copy in the simulator') + self._gem5_util("writefile {}".format(dest_file)) + + if 'cpu' not in filename: + while not os.path.exists(os.path.join(self.gem5_out_dir, + dest_file)): + time.sleep(1) + + # Perform the local move + if os.path.exists(os.path.join(dest, dest_file)): + logger.warning( + 'Destination file {} already exists!'\ + .format(dest_file)) + else: + shutil.move(os.path.join(self.gem5_out_dir, dest_file), dest) + logger.debug("Pull complete.") def execute(self, command, timeout=1000, check_exit_code=True, as_root=False, strip_colors=True): @@ -74,6 +74,7 @@ params = dict( extras_require={ 'daq': ['daqpower'], 'doc': ['sphinx'], + 'monsoon': ['python-gflags'], }, # https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[ |