summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authoraberent@chromium.org <aberent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-08 14:54:42 +0000
committeraberent@chromium.org <aberent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-08 14:54:42 +0000
commitdcf8bae838a1ac4c4afe09c3d3c8b378d581b522 (patch)
tree7c3b0b5be0a20ad7601390ede59c261d82790738 /build
parent7530ec460685b317fd3b145deb92abbd81bb2941 (diff)
downloadchromium_src-dcf8bae838a1ac4c4afe09c3d3c8b378d581b522.zip
chromium_src-dcf8bae838a1ac4c4afe09c3d3c8b378d581b522.tar.gz
chromium_src-dcf8bae838a1ac4c4afe09c3d3c8b378d581b522.tar.bz2
Upstreaming latest build/android changes
Includes: Fix to reboot so that it works on all devices Handling EOF in logcat Clear caches as root - required for recent android versions Print standard deviation for performance tests BUG= Review URL: https://chromiumcodereview.appspot.com/11026040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160651 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build')
-rw-r--r--build/android/pylib/android_commands.py85
-rw-r--r--build/android/pylib/perf_tests_helper.py10
2 files changed, 66 insertions, 29 deletions
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 62cb64b..3c75261 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -46,10 +46,6 @@ LOCAL_PROPERTIES_PATH = '/data/local.prop'
# Property in /data/local.prop that controls Java assertions.
JAVA_ASSERT_PROPERTY = 'dalvik.vm.enableassertions'
-BOOT_COMPLETE_RE = re.compile(
- 'android.intent.action.MEDIA_MOUNTED path: /\w+/sdcard\d?'
- '|PowerManagerService(\(\s+\d+\))?: bootCompleted')
-
MEMORY_INFO_RE = re.compile('^(?P<key>\w+):\s+(?P<usage_kb>\d+) kB$')
NVIDIA_MEMORY_INFO_RE = re.compile('^\s*(?P<user>\S+)\s*(?P<name>\S+)\s*'
'(?P<pid>\d+)\s*(?P<usage_bytes>\d+)$')
@@ -284,9 +280,10 @@ class AndroidCommands(object):
else:
self.RestartShell()
timeout = 120
+ # To run tests we need at least the package manager and the sd card (or
+ # other external storage) to be ready.
self.WaitForDevicePm()
- self.StartMonitoringLogcat(timeout=timeout)
- self.WaitForLogMatch(BOOT_COMPLETE_RE, None)
+ self.WaitForSdCardReady(timeout)
def Uninstall(self, package):
"""Uninstalls the specified package from the device.
@@ -519,6 +516,11 @@ class AndroidCommands(object):
cmd += ' --start-profiler ' + trace_file_name
self.RunShellCommand(cmd)
+ def GoHome(self):
+ """Tell the device to return to the home screen. Blocks until completion."""
+ self.RunShellCommand('am start -W '
+ '-a android.intent.action.MAIN -c android.intent.category.HOME')
+
def CloseApplication(self, package):
"""Attempt to close down the application, using increasing violence.
@@ -667,6 +669,17 @@ class AndroidCommands(object):
enable and 'all' or ''))
return True
+ def GetBuildId(self):
+ """Returns the build ID of the system (e.g. JRM79C)."""
+ build_id = self.RunShellCommand('getprop ro.build.id')[0]
+ assert build_id
+ return build_id
+
+ def GetBuildType(self):
+ """Returns the build type of the system (e.g. eng)."""
+ build_type = self.RunShellCommand('getprop ro.build.type')[0]
+ assert build_type
+ return build_type
def StartMonitoringLogcat(self, clear=True, timeout=10, logfile=None,
filters=None):
@@ -728,31 +741,44 @@ class AndroidCommands(object):
The re match object if |success_re| is matched first or None if |error_re|
is matched first.
"""
- if not self._logcat:
- self.StartMonitoringLogcat(clear)
logging.info('<<< Waiting for logcat:' + str(success_re.pattern))
t0 = time.time()
- try:
- while True:
- # Note this will block for upto the timeout _per log line_, so we need
- # to calculate the overall timeout remaining since t0.
- time_remaining = t0 + self._logcat.timeout - time.time()
- if time_remaining < 0: raise pexpect.TIMEOUT(self._logcat)
- self._logcat.expect(PEXPECT_LINE_RE, timeout=time_remaining)
- line = self._logcat.match.group(1)
- if error_re:
- error_match = error_re.search(line)
- if error_match:
- return None
- success_match = success_re.search(line)
- if success_match:
- return success_match
- logging.info('<<< Skipped Logcat Line:' + str(line))
- except pexpect.TIMEOUT:
- raise pexpect.TIMEOUT(
- 'Timeout (%ds) exceeded waiting for pattern "%s" (tip: use -vv '
- 'to debug)' %
- (self._logcat.timeout, success_re.pattern))
+ while True:
+ if not self._logcat:
+ self.StartMonitoringLogcat(clear)
+ try:
+ while True:
+ # Note this will block for upto the timeout _per log line_, so we need
+ # to calculate the overall timeout remaining since t0.
+ time_remaining = t0 + self._logcat.timeout - time.time()
+ if time_remaining < 0: raise pexpect.TIMEOUT(self._logcat)
+ self._logcat.expect(PEXPECT_LINE_RE, timeout=time_remaining)
+ line = self._logcat.match.group(1)
+ if error_re:
+ error_match = error_re.search(line)
+ if error_match:
+ return None
+ success_match = success_re.search(line)
+ if success_match:
+ return success_match
+ logging.info('<<< Skipped Logcat Line:' + str(line))
+ except pexpect.TIMEOUT:
+ raise pexpect.TIMEOUT(
+ 'Timeout (%ds) exceeded waiting for pattern "%s" (tip: use -vv '
+ 'to debug)' %
+ (self._logcat.timeout, success_re.pattern))
+ except pexpect.EOF:
+ # It seems that sometimes logcat can end unexpectedly. This seems
+ # to happen during Chrome startup after a reboot followed by a cache
+ # clean. I don't understand why this happens, but this code deals with
+ # getting EOF in logcat.
+ logging.critical('Found EOF in adb logcat. Restarting...')
+ # Rerun spawn with original arguments. Note that self._logcat.args[0] is
+ # the path of adb, so we don't want it in the arguments.
+ self._logcat = pexpect.spawn('adb',
+ self._logcat.args[1:],
+ timeout=self._logcat.timeout,
+ logfile=self._logcat.logfile)
def StartRecordingLogcat(self, clear=True, filters=['*:v']):
"""Starts recording logcat output to eventually be saved as a string.
@@ -1017,3 +1043,4 @@ class NewLineNormalizer(object):
def flush(self):
self._output.flush()
+
diff --git a/build/android/pylib/perf_tests_helper.py b/build/android/pylib/perf_tests_helper.py
index 19c24f3..c0a3ee4 100644
--- a/build/android/pylib/perf_tests_helper.py
+++ b/build/android/pylib/perf_tests_helper.py
@@ -5,6 +5,7 @@
import re
import android_commands
+import math
# Valid values of result type.
RESULT_TYPES = {'unimportant': 'RESULT ',
@@ -46,10 +47,14 @@ def PrintPerfResult(measurement, trace, values, units, result_type='default',
assert len(values)
assert '/' not in measurement
avg = None
+ sd = None
if len(values) > 1:
try:
value = '[%s]' % ','.join([str(v) for v in values])
avg = sum([float(v) for v in values]) / len(values)
+ sqdiffs = [(float(v) - avg) ** 2 for v in values]
+ variance = sum(sqdiffs) / (len(values) - 1)
+ sd = math.sqrt(variance)
except ValueError:
value = ", ".join(values)
else:
@@ -67,6 +72,8 @@ def PrintPerfResult(measurement, trace, values, units, result_type='default',
units)
if avg:
output += '\nAvg %s: %f%s' % (measurement, avg, units)
+ if sd:
+ output += '\nSd %s: %f%s' % (measurement, sd, units)
if print_to_stdout:
print output
return output
@@ -87,6 +94,9 @@ class PerfTestSetup(object):
def DropRamCaches(self):
"""Drops the filesystem ram caches for performance testing."""
+ if not self._adb.IsRootEnabled():
+ self._adb.EnableAdbRoot()
+ self._adb.RunShellCommand('sync')
self._adb.RunShellCommand('echo 3 > ' + PerfTestSetup._DROP_CACHES)
def SetUp(self):