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

Side by Side Diff: build/android/pylib/forwarder.py

Issue 11421149: Ensure host_forwarder is killed when setting up/tearing down sharding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Marcus' comments Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/base_test_sharder.py ('k') | no next file » | 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 import logging 5 import logging
6 import os 6 import os
7 import re 7 import re
8 import sys 8 import sys
9 import time 9 import time
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 raise Exception('Unexpected host forwarder output "%s", ' + 98 raise Exception('Unexpected host forwarder output "%s", ' +
99 'expected "device_port:host_port"' % output) 99 'expected "device_port:host_port"' % output)
100 device_port = int(tokens[0]) 100 device_port = int(tokens[0])
101 host_port = int(tokens[1]) 101 host_port = int(tokens[1])
102 self._host_to_device_port_map[host_port] = device_port 102 self._host_to_device_port_map[host_port] = device_port
103 logging.info('Forwarding device port: %d to host port: %d.', device_port, 103 logging.info('Forwarding device port: %d to host port: %d.', device_port,
104 host_port) 104 host_port)
105 105
106 @staticmethod 106 @staticmethod
107 def KillHost(build_type): 107 def KillHost(build_type):
108 logging.info('Killing host_forwarder.')
108 host_forwarder_path = _MakeBinaryPath(build_type, 'host_forwarder') 109 host_forwarder_path = _MakeBinaryPath(build_type, 'host_forwarder')
109 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( 110 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput(
110 [host_forwarder_path, 'kill-server']) 111 [host_forwarder_path, 'kill-server'])
111 if exit_code != 0: 112 if exit_code != 0:
112 raise Exception('%s exited with %d:\n%s' % (host_forwarder_path, 113 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput(
113 exit_code, '\n'.join(output))) 114 ['pkill', 'host_forwarder'])
115 if exit_code != 0:
116 raise Exception('%s exited with %d:\n%s' % (
117 host_forwarder_path, exit_code, '\n'.join(output)))
114 118
115 @staticmethod 119 @staticmethod
116 def KillDevice(adb): 120 def KillDevice(adb):
117 logging.info('Killing device_forwarder.') 121 logging.info('Killing device_forwarder.')
118 if not adb.FileExistsOnDevice(Forwarder._DEVICE_FORWARDER_PATH): 122 if not adb.FileExistsOnDevice(Forwarder._DEVICE_FORWARDER_PATH):
119 return 123 return
120 (exit_code, output) = adb.GetShellCommandStatusAndOutput( 124 (exit_code, output) = adb.GetShellCommandStatusAndOutput(
121 '%s kill-server' % Forwarder._DEVICE_FORWARDER_PATH) 125 '%s kill-server' % Forwarder._DEVICE_FORWARDER_PATH)
122 # TODO(pliard): Remove the following call to KillAllBlocking() when we are 126 # TODO(pliard): Remove the following call to KillAllBlocking() when we are
123 # sure that the old version of device_forwarder (not supporting 127 # sure that the old version of device_forwarder (not supporting
124 # 'kill-server') is not running on the bots anymore. 128 # 'kill-server') is not running on the bots anymore.
125 timeout_sec = 5 129 timeout_sec = 5
126 processes_killed = adb.KillAllBlocking('device_forwarder', timeout_sec) 130 processes_killed = adb.KillAllBlocking('device_forwarder', timeout_sec)
127 if not processes_killed: 131 if not processes_killed:
128 pids = adb.ExtractPid('device_forwarder') 132 pids = adb.ExtractPid('device_forwarder')
129 if pids: 133 if pids:
130 raise Exception('Timed out while killing device_forwarder') 134 raise Exception('Timed out while killing device_forwarder')
131 135
132 def DevicePortForHostPort(self, host_port): 136 def DevicePortForHostPort(self, host_port):
133 """Get the device port that corresponds to a given host port.""" 137 """Get the device port that corresponds to a given host port."""
134 return self._host_to_device_port_map.get(host_port) 138 return self._host_to_device_port_map.get(host_port)
135 139
136 def Close(self): 140 def Close(self):
137 """Terminate the forwarder process.""" 141 """Terminate the forwarder process."""
138 if self._device_process: 142 if self._device_process:
139 self._device_process.close() 143 self._device_process.close()
140 self._device_process = None 144 self._device_process = None
OLDNEW
« no previous file with comments | « build/android/pylib/base_test_sharder.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698