summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames.wei@intel.com <james.wei@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-16 15:22:58 +0000
committerjames.wei@intel.com <james.wei@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-16 15:22:58 +0000
commit34c3f42fe554bced1a2a0e4477d352928acd5da6 (patch)
tree31bf499437c745365b00d38e73463892dbe05da9
parent5a46a9eba656ede357dae44d8adad602a9b96109 (diff)
downloadchromium_src-34c3f42fe554bced1a2a0e4477d352928acd5da6.zip
chromium_src-34c3f42fe554bced1a2a0e4477d352928acd5da6.tar.gz
chromium_src-34c3f42fe554bced1a2a0e4477d352928acd5da6.tar.bz2
create temp avd when running tests on multiple emulators
BUG=137487 TEST=./build/android/run_tests.py -s ui_unittests -e 2 Review URL: https://chromiumcodereview.appspot.com/10784011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146804 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xbuild/android/emulator.py56
-rwxr-xr-xbuild/android/run_tests.py6
2 files changed, 55 insertions, 7 deletions
diff --git a/build/android/emulator.py b/build/android/emulator.py
index bf5dc08..d4f3caa 100755
--- a/build/android/emulator.py
+++ b/build/android/emulator.py
@@ -113,10 +113,11 @@ class Emulator(object):
# Time to wait for a "wait for boot complete" (property set on device).
_WAITFORBOOT_TIMEOUT = 300
- def __init__(self, fast_and_loose=False):
+ def __init__(self, new_avd_name, fast_and_loose):
"""Init an Emulator.
Args:
+ nwe_avd_name: If set, will create a new temporary AVD.
fast_and_loose: Loosen up the rules for reliable running for speed.
Intended for quick testing or re-testing.
@@ -128,15 +129,59 @@ class Emulator(object):
'emulator.')
raise
self.emulator = os.path.join(android_sdk_root, 'tools', 'emulator')
+ self.android = os.path.join(android_sdk_root, 'tools', 'android')
self.popen = None
self.device = None
+ self.default_avd = True
self.fast_and_loose = fast_and_loose
+ self.abi = 'armeabi-v7a'
+ self.avd = 'avd_armeabi'
+ if 'x86' in os.environ.get('TARGET_PRODUCT', ''):
+ self.abi = 'x86'
+ self.avd = 'avd_x86'
+ if new_avd_name:
+ self.default_avd = False
+ self.avd = self._CreateAVD(new_avd_name)
def _DeviceName(self):
"""Return our device name."""
port = _GetAvailablePort()
return ('emulator-%d' % port, port)
+ def _CreateAVD(self, avd_name):
+ avd_command = [
+ self.android,
+ '--silent',
+ 'create', 'avd',
+ '--name', avd_name,
+ '--abi', self.abi,
+ '--target', 'android-15',
+ '-c', '64M',
+ '--force',
+ ]
+ avd_process = subprocess.Popen(args=avd_command,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ avd_process.stdin.write('no\n')
+ avd_process.wait()
+ logging.info('Create AVD command: %s', ' '.join(avd_command))
+ return self.avd
+
+ def _DeleteAVD(self):
+ avd_command = [
+ self.android,
+ '--silent',
+ 'delete',
+ 'avd',
+ '--name', self.avd,
+ ]
+ avd_process = subprocess.Popen(args=avd_command,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ logging.info('Delete AVD command: %s', ' '.join(avd_command))
+ avd_process.wait()
+
def Launch(self, kill_all_emulators):
"""Launches the emulator asynchronously. Call ConfirmLaunch() to ensure the
emulator is ready for use.
@@ -148,9 +193,6 @@ class Emulator(object):
if not self.fast_and_loose:
self._AggressiveImageCleanup()
(self.device, port) = self._DeviceName()
- abi = 'armeabi'
- if 'x86' in os.environ.get('TARGET_PRODUCT', ''):
- abi = 'x86'
emulator_command = [
self.emulator,
# Speed up emulator launch by 40%. Really.
@@ -159,7 +201,7 @@ class Emulator(object):
# That's not enough for 8 unit test bundles and their data.
'-partition-size', '512',
# Use a familiar name and port.
- '-avd', 'avd_' + abi,
+ '-avd', self.avd,
'-port', str(port)]
if not self.fast_and_loose:
emulator_command.extend([
@@ -228,6 +270,8 @@ class Emulator(object):
def Shutdown(self):
"""Shuts down the process started by launch."""
+ if not self.default_avd:
+ self._DeleteAVD()
if self.popen:
self.popen.poll()
if self.popen.returncode == None:
@@ -247,7 +291,7 @@ class Emulator(object):
signal.signal(sig, self._ShutdownOnSignal)
def main(argv):
- Emulator(True).Launch(True)
+ Emulator(None, True).Launch(True)
if __name__ == '__main__':
diff --git a/build/android/run_tests.py b/build/android/run_tests.py
index d98bac7..d13f7e9 100755
--- a/build/android/run_tests.py
+++ b/build/android/run_tests.py
@@ -325,7 +325,11 @@ def _RunATestSuite(options):
if options.use_emulator:
for n in range(options.emulator_count):
t = TimeProfile('Emulator launch %d' % n)
- buildbot_emulator = emulator.Emulator(options.fast_and_loose)
+ avd_name = None
+ if n > 0:
+ # Creates a temporary AVD for the extra emulators.
+ avd_name = 'run_tests_avd_%d' % n
+ buildbot_emulator = emulator.Emulator(avd_name, options.fast_and_loose)
buildbot_emulator.Launch(kill_all_emulators=n == 0)
t.Stop()
buildbot_emulators.append(buildbot_emulator)