Commit 32760419 authored by jrg@google.com's avatar jrg@google.com

Android bot changes for robustness, profiling, and debugging.

Kill all emulators before starting a test to be more robust on error.
Print error if a file fails to copy to the device.
Speed up emulator launch by 40%.
Increase emulator partition size to fix 'out of space on device' errors.
Log emulator launch time to help profile bot costs.
Run tests in verbose mode to assist with bot debugging.

BUG=None
TEST=

Review URL: http://codereview.chromium.org/8769020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112552 0039d316-1c4b-4281-b951-d872f2087c98
parent 0a9298b6
......@@ -423,7 +423,11 @@ class AndroidCommands(object):
# 60 seconds which isn't sufficient for a lot of users of this method.
push_command = 'push %s %s' % (local_path, device_path)
logging.info('>>> $' + push_command)
self._adb.SendCommand(push_command, timeout_time=30*60)
output = self._adb.SendCommand(push_command, timeout_time=30*60)
# Success looks like this: "3035 KB/s (12512056 bytes in 4.025s)"
# Errors look like this: "failed to copy ... "
if not re.search('^[0-9]', output):
logging.critical('PUSH FAILED: ' + output)
def GetFileContents(self, filename):
"""Gets contents from the file specified by |filename|."""
......
......@@ -65,6 +65,6 @@ for target in ${EXPERIMENTAL_TARGETS} ; do
done
echo "@@@BUILD_STEP Run Tests@@@"
build/android/run_tests.py -e --xvfb
build/android/run_tests.py -e --xvfb --verbose
exit 0
......@@ -18,6 +18,11 @@ import sys
import android_commands
# adb_interface.py is under ../../third_party/android/testrunner/
sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..',
'..', 'third_party', 'android', 'testrunner'))
import adb_interface
def _GetAvailablePort():
"""Returns an available TCP port for the console."""
......@@ -58,6 +63,15 @@ class Emulator(object):
self.popen = None
self.device = None
def Reset(self):
"""Kill a running emulator.
May be needed if the test scripts stopped abnormally and an
emulator is left around."""
adb = adb_interface.AdbInterface()
logging.info('Killing any existing emulator.')
adb.SendCommand('emu kill')
def Launch(self):
"""Launches the emulator and waits for package manager to startup.
......@@ -65,8 +79,16 @@ class Emulator(object):
"""
port = _GetAvailablePort()
self.device = "emulator-%d" % port
self.popen = subprocess.Popen(args=[self.emulator, '-avd', 'buildbot',
'-port', str(port)])
self.popen = subprocess.Popen(args=[
self.emulator,
# Speed up emulator launch by 40%. Really.
'-no-boot-anim',
# The default /data size is 64M.
# That's not enough for 4 unit test bundles and their data.
'-partition-size', '256',
# Use a familiar name and port.
'-avd', 'buildbot',
'-port', str(port)])
# This will not return until device's package manager starts up or an
# exception is raised.
android_commands.AndroidCommands(self.device, True)
......
......@@ -65,6 +65,25 @@ from test_result import BaseTestResult, TestResults
_TEST_SUITES = ['base_unittests', 'sql_unittests', 'ipc_tests', 'net_unittests']
class TimeProfile(object):
"""Class for simple profiling of action, with logging of cost."""
def __init__(self, description):
self._description = description
self.Start()
def Start(self):
self._starttime = time.time()
def Stop(self):
"""Stop profiling and dump a log."""
if self._starttime:
stoptime = time.time()
logging.info('%fsec to perform %s' %
(stoptime - self._starttime, self._description))
self._starttime = None
class Xvfb(object):
"""Class to start and stop Xvfb if relevant. Nop if not Linux."""
......@@ -194,8 +213,11 @@ def Dispatch(options):
xvfb.Start()
if options.use_emulator:
t = TimeProfile('Emulator launch')
buildbot_emulator = emulator.Emulator()
buildbot_emulator.Reset()
buildbot_emulator.Launch()
t.Stop()
attached_devices.append(buildbot_emulator.device)
else:
attached_devices = android_commands.GetAttachedDevices()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment