Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Side by Side Diff: build/android/pylib/utils/emulator.py

Issue 1281923003: [Android] Add --blacklist-file as a command-line option. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix telemetry_unittests Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/pylib/uiautomator/setup.py ('k') | build/android/pylib/utils/test_environment.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Provides an interface to start and stop Android emulator. 5 """Provides an interface to start and stop Android emulator.
6 6
7 Emulator: The class provides the methods to launch/shutdown the emulator with 7 Emulator: The class provides the methods to launch/shutdown the emulator with
8 the android virtual device named 'avd_armeabi' . 8 the android virtual device named 'avd_armeabi' .
9 """ 9 """
10 10
11 import logging 11 import logging
12 import os 12 import os
13 import signal 13 import signal
14 import subprocess 14 import subprocess
15 import time 15 import time
16 16
17 # TODO(craigdh): Move these pylib dependencies to pylib/utils/. 17 # TODO(craigdh): Move these pylib dependencies to pylib/utils/.
18 from pylib import cmd_helper 18 from pylib import cmd_helper
19 from pylib import constants 19 from pylib import constants
20 from pylib import pexpect 20 from pylib import pexpect
21 from pylib.device import adb_wrapper
21 from pylib.device import device_errors 22 from pylib.device import device_errors
22 from pylib.device import device_utils 23 from pylib.device import device_utils
23 from pylib.utils import time_profile 24 from pylib.utils import time_profile
24 25
25 import errors 26 import errors
26 import run_command 27 import run_command
27 28
28 # SD card size 29 # SD card size
29 SDCARD_SIZE = '512M' 30 SDCARD_SIZE = '512M'
30 31
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 """Emulator failed to launch.""" 83 """Emulator failed to launch."""
83 pass 84 pass
84 85
85 def _KillAllEmulators(): 86 def _KillAllEmulators():
86 """Kill all running emulators that look like ones we started. 87 """Kill all running emulators that look like ones we started.
87 88
88 There are odd 'sticky' cases where there can be no emulator process 89 There are odd 'sticky' cases where there can be no emulator process
89 running but a device slot is taken. A little bot trouble and we're out of 90 running but a device slot is taken. A little bot trouble and we're out of
90 room forever. 91 room forever.
91 """ 92 """
92 emulators = [d for d in device_utils.DeviceUtils.HealthyDevices() 93 emulators = [device_utils.DeviceUtils(a)
93 if d.adb.is_emulator] 94 for a in adb_wrapper.AdbWrapper.Devices()
95 if a.is_emulator]
94 if not emulators: 96 if not emulators:
95 return 97 return
96 for e in emulators: 98 for e in emulators:
97 e.adb.Emu(['kill']) 99 e.adb.Emu(['kill'])
98 logging.info('Emulator killing is async; give a few seconds for all to die.') 100 logging.info('Emulator killing is async; give a few seconds for all to die.')
99 for _ in range(5): 101 for _ in range(5):
100 if not any(d.adb.is_emulator for d 102 if not any(a.is_emulator for a in adb_wrapper.AdbWrapper.Devices()):
101 in device_utils.DeviceUtils.HealthyDevices()):
102 return 103 return
103 time.sleep(1) 104 time.sleep(1)
104 105
105 106
106 def DeleteAllTempAVDs(): 107 def DeleteAllTempAVDs():
107 """Delete all temporary AVDs which are created for tests. 108 """Delete all temporary AVDs which are created for tests.
108 109
109 If the test exits abnormally and some temporary AVDs created when testing may 110 If the test exits abnormally and some temporary AVDs created when testing may
110 be left in the system. Clean these AVDs. 111 be left in the system. Clean these AVDs.
111 """ 112 """
(...skipping 23 matching lines...) Expand all
135 Cycling through a port start position helps make us resilient.""" 136 Cycling through a port start position helps make us resilient."""
136 ports = range(cls._port_min, cls._port_max, 2) 137 ports = range(cls._port_min, cls._port_max, 2)
137 n = cls._port_current_index 138 n = cls._port_current_index
138 cls._port_current_index = (n + 1) % len(ports) 139 cls._port_current_index = (n + 1) % len(ports)
139 return ports[n:] + ports[:n] 140 return ports[n:] + ports[:n]
140 141
141 142
142 def _GetAvailablePort(): 143 def _GetAvailablePort():
143 """Returns an available TCP port for the console.""" 144 """Returns an available TCP port for the console."""
144 used_ports = [] 145 used_ports = []
145 emulators = [d for d in device_utils.DeviceUtils.HealthyDevices() 146 emulators = [device_utils.DeviceUtils(a)
146 if d.adb.is_emulator] 147 for a in adb_wrapper.AdbWrapper.Devices()
148 if a.is_emulator]
147 for emulator in emulators: 149 for emulator in emulators:
148 used_ports.append(emulator.adb.GetDeviceSerial().split('-')[1]) 150 used_ports.append(emulator.adb.GetDeviceSerial().split('-')[1])
149 for port in PortPool.port_range(): 151 for port in PortPool.port_range():
150 if str(port) not in used_ports: 152 if str(port) not in used_ports:
151 return port 153 return port
152 154
153 155
154 def LaunchTempEmulators(emulator_count, abi, api_level, wait_for_boot=True): 156 def LaunchTempEmulators(emulator_count, abi, api_level, wait_for_boot=True):
155 """Create and launch temporary emulators and wait for them to boot. 157 """Create and launch temporary emulators and wait for them to boot.
156 158
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 logging.critical('emulator _ShutdownOnSignal') 437 logging.critical('emulator _ShutdownOnSignal')
436 for sig in self._SIGNALS: 438 for sig in self._SIGNALS:
437 signal.signal(sig, signal.SIG_DFL) 439 signal.signal(sig, signal.SIG_DFL)
438 self.Shutdown() 440 self.Shutdown()
439 raise KeyboardInterrupt # print a stack 441 raise KeyboardInterrupt # print a stack
440 442
441 def _InstallKillHandler(self): 443 def _InstallKillHandler(self):
442 """Install a handler to kill the emulator when we exit unexpectedly.""" 444 """Install a handler to kill the emulator when we exit unexpectedly."""
443 for sig in self._SIGNALS: 445 for sig in self._SIGNALS:
444 signal.signal(sig, self._ShutdownOnSignal) 446 signal.signal(sig, self._ShutdownOnSignal)
OLDNEW
« no previous file with comments | « build/android/pylib/uiautomator/setup.py ('k') | build/android/pylib/utils/test_environment.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698