Chromium Code Reviews| Index: build/android/pylib/utils/emulator.py |
| diff --git a/build/android/pylib/utils/emulator.py b/build/android/pylib/utils/emulator.py |
| index 70afffb2efc2cbe011bb36b21ff3680c6f5c9f6f..1624870798b61973087e3edb084173f5a3ce0b38 100755 |
| --- a/build/android/pylib/utils/emulator.py |
| +++ b/build/android/pylib/utils/emulator.py |
| @@ -24,10 +24,6 @@ import time_profile |
| from pylib import android_commands |
| from pylib import cmd_helper |
| -# 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 |
| import errors |
| import run_command |
| @@ -101,11 +97,12 @@ def _GetAvailablePort(): |
| return port |
| -def LaunchEmulators(emulator_count, wait_for_boot=True): |
| +def LaunchEmulators(emulator_count, abi, wait_for_boot=True): |
| """Launch multiple emulators and wait for them to boot. |
| Args: |
| emulator_count: number of emulators to launch. |
|
navabi
2013/03/14 02:39:47
need to add abi to arg list.
pasko-google - do not use
2013/03/14 15:46:28
I assume you are going to do it? Or there a dedica
navabi
2013/03/20 21:40:16
Haha. Yeah, I'm still in the process of arguing wi
|
| + wait_for_boot: whether or not to wait for emulators to boot up |
| Returns: |
| List of emulators. |
| @@ -113,12 +110,10 @@ def LaunchEmulators(emulator_count, wait_for_boot=True): |
| emulators = [] |
| for n in xrange(emulator_count): |
| t = time_profile.TimeProfile('Emulator launch %d' % n) |
| - avd_name = None |
| - if n > 0: |
| - # Creates a temporary AVD for the extra emulators. |
| - avd_name = 'run_tests_avd_%d' % n |
| + # Creates a temporary AVD |
| + avd_name = 'run_tests_avd_%d' % n |
| logging.info('Emulator launch %d with avd_name=%s', n, avd_name) |
| - emulator = Emulator(avd_name) |
| + emulator = Emulator(avd_name, abi) |
| emulator.Launch(kill_all_emulators=n == 0) |
| t.Stop() |
| emulators.append(emulator) |
| @@ -159,11 +154,12 @@ class Emulator(object): |
| # Time to wait for a "wait for boot complete" (property set on device). |
| _WAITFORBOOT_TIMEOUT = 300 |
| - def __init__(self, new_avd_name): |
| + def __init__(self, avd_name, abi='armeabi-v7a'): |
| """Init an Emulator. |
| Args: |
| - nwe_avd_name: If set, will create a new temporary AVD. |
| + avd_name: name of the AVD to create |
| + abi: target platform for emulator being created |
|
navabi
2013/03/14 02:39:47
should make default abi x86, since that is the mor
navabi
2013/03/20 21:40:16
Done.
|
| """ |
| try: |
| android_sdk_root = os.environ['ANDROID_SDK_ROOT'] |
|
navabi
2013/03/20 21:40:16
While the emulator requires this to be set, I have
|
| @@ -175,33 +171,30 @@ class Emulator(object): |
| self.android = os.path.join(android_sdk_root, 'tools', 'android') |
| self.popen = None |
| self.device = None |
| - self.default_avd = True |
| - self.abi = 'armeabi-v7a' |
| - self.avd = 'avd_armeabi' |
| - if 'x86' in os.environ.get('TARGET_PRODUCT', ''): |
| + self.abi = abi |
| + if 'ia32' in os.environ.get('target_arch', ''): |
|
pasko-google - do not use
2013/03/14 15:46:28
For future CLs: I may want to override this settin
navabi
2013/03/20 21:40:16
Done. We actually don't need this here. The avd.py
|
| self.abi = 'x86' |
| - self.avd = 'avd_x86' |
| - if new_avd_name: |
| - self.default_avd = False |
| - self.avd = self._CreateAVD(new_avd_name) |
| + self.avd_name = avd_name |
| + self._CreateAVD() |
| def _DeviceName(self): |
| """Return our device name.""" |
| port = _GetAvailablePort() |
| return ('emulator-%d' % port, port) |
| - def _CreateAVD(self, avd_name): |
| + def _CreateAVD(self): |
| """Creates an AVD with the given name. |
| Return avd_name. |
| """ |
| + print 'self.android: ' + self.android |
| avd_command = [ |
| self.android, |
| '--silent', |
| 'create', 'avd', |
| - '--name', avd_name, |
| + '--name', self.avd_name, |
| '--abi', self.abi, |
| - '--target', 'android-16', |
| + '--target', 'android-17', |
| '-c', '128M', |
| '--force', |
| ] |
| @@ -212,7 +205,7 @@ class Emulator(object): |
| avd_process.stdin.write('no\n') |
| avd_process.wait() |
| logging.info('Create AVD command: %s', ' '.join(avd_command)) |
| - return avd_name |
| + return self.avd_name |
| def _DeleteAVD(self): |
| """Delete the AVD of this emulator.""" |
| @@ -246,17 +239,24 @@ class Emulator(object): |
| # The default /data size is 64M. |
| # That's not enough for 8 unit test bundles and their data. |
| '-partition-size', '512', |
| - # Enable GPU by default. |
| - '-gpu', 'on', |
| # Use a familiar name and port. |
| - '-avd', self.avd, |
| - '-port', str(port)] |
| - emulator_command.extend([ |
| - # Wipe the data. We've seen cases where an emulator |
| - # gets 'stuck' if we don't do this (every thousand runs or |
| - # so). |
| + '-avd', self.avd_name, |
| + '-port', str(port), |
| + # Wipe the data. We've seen cases where an emulator gets 'stuck' if we |
| + # don't do this (every thousand runs or so). |
| '-wipe-data', |
| - ]) |
| + # Enable GPU by default. |
| + '-gpu', 'on', |
| + '-qemu', '-m', '512', |
|
pasko-google - do not use
2013/03/14 15:46:28
1024
navabi
2013/03/20 21:40:16
Done.
|
| + ] |
| + print 'self.abi = %s' % self.abi |
| + if self.abi == 'x86': |
| + emulator_command.extend([ |
| + # For x86 emulator --enable-kvm will makes explicit as to whether or |
| + # not Intel's virtualization support is being used. |
|
pasko-google - do not use
2013/03/14 15:46:28
It is not quite clear what the word "explicit" mea
navabi
2013/03/20 21:40:16
Done.
|
| + '--enable-kvm', |
| + ]) |
| + |
| logging.info('Emulator launch command: %s', ' '.join(emulator_command)) |
| self.popen = subprocess.Popen(args=emulator_command, |
| stderr=subprocess.STDOUT) |