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

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

Issue 294113003: [Android] Convert to DeviceUtils versions of WaitUntilFullyBooted and GetExternalStoragePath. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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/utils/parallelizer.py ('k') | build/android/pylib/valgrind_tools.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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 import logging 5 import logging
6 import psutil 6 import psutil
7 import signal 7 import signal
8 8
9 from pylib import android_commands
10 from pylib.device import device_errors 9 from pylib.device import device_errors
11 from pylib.device import device_utils 10 from pylib.device import device_utils
12 11
13 12
14 def _KillWebServers(): 13 def _KillWebServers():
15 for s in [signal.SIGTERM, signal.SIGINT, signal.SIGQUIT, signal.SIGKILL]: 14 for s in [signal.SIGTERM, signal.SIGINT, signal.SIGQUIT, signal.SIGKILL]:
16 signalled = [] 15 signalled = []
17 for server in ['lighttpd', 'webpagereplay']: 16 for server in ['lighttpd', 'webpagereplay']:
18 for p in psutil.process_iter(): 17 for p in psutil.process_iter():
19 try: 18 try:
20 if not server in ' '.join(p.cmdline): 19 if not server in ' '.join(p.cmdline):
21 continue 20 continue
22 logging.info('Killing %s %s %s', s, server, p.pid) 21 logging.info('Killing %s %s %s', s, server, p.pid)
23 p.send_signal(s) 22 p.send_signal(s)
24 signalled.append(p) 23 signalled.append(p)
25 except Exception as e: 24 except Exception as e:
26 logging.warning('Failed killing %s %s %s', server, p.pid, e) 25 logging.warning('Failed killing %s %s %s', server, p.pid, e)
27 for p in signalled: 26 for p in signalled:
28 try: 27 try:
29 p.wait(1) 28 p.wait(1)
30 except Exception as e: 29 except Exception as e:
31 logging.warning('Failed waiting for %s to die. %s', p.pid, e) 30 logging.warning('Failed waiting for %s to die. %s', p.pid, e)
32 31
33 32
34
35 def CleanupLeftoverProcesses(): 33 def CleanupLeftoverProcesses():
36 """Clean up the test environment, restarting fresh adb and HTTP daemons.""" 34 """Clean up the test environment, restarting fresh adb and HTTP daemons."""
37 _KillWebServers() 35 _KillWebServers()
38 did_restart_host_adb = False 36 device_utils.RestartServer()
39 for device_serial in android_commands.GetAttachedDevices(): 37 p = device_utils.DeviceUtils.parallel()
40 device = device_utils.DeviceUtils(device_serial) 38 p.old_interface.RestartAdbdOnDevice()
41 # Make sure we restart the host adb server only once. 39 try:
42 if not did_restart_host_adb: 40 p.EnableRoot()
43 device_utils.RestartServer() 41 except device_errors.CommandFailedError as e:
44 did_restart_host_adb = True 42 # TODO(jbudorick) Handle this exception appropriately after interface
45 device.old_interface.RestartAdbdOnDevice() 43 # conversions are finished.
46 try: 44 logging.error(str(e))
47 device.EnableRoot() 45 p.WaitUntilFullyBooted()
48 except device_errors.CommandFailedError as e:
49 # TODO(jbudorick) Handle this exception appropriately after interface
50 # conversions are finished.
51 logging.error(str(e))
52 device.old_interface.WaitForDevicePm()
53 46
OLDNEW
« no previous file with comments | « build/android/pylib/utils/parallelizer.py ('k') | build/android/pylib/valgrind_tools.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698