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

Side by Side Diff: blimp/tools/client_engine_integration.py

Issue 2236143002: Add live output for blimp integration script {run} func (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: log error when engine fails to start Created 4 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 | « no previous file | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Blimp Client + Engine integration test system 6 """Blimp Client + Engine integration test system
7 7
8 Set up Client and Engine 8 Set up Client and Engine
9 Set up Forward to connect machine host with client device. 9 Set up Forward to connect machine host with client device.
10 Start Engine and run blimp on Android Client. 10 Start Engine and run blimp on Android Client.
11 """ 11 """
12 12
13 import argparse 13 import argparse
14 import json 14 import json
15 import logging 15 import logging
16 import posixpath 16 import posixpath
17 import os 17 import os
18 import re 18 import re
19 import signal 19 import signal
20 import subprocess 20 import subprocess
21 import sys 21 import sys
22 import time
23 22
24 SRC_PATH = os.path.abspath( 23 SRC_PATH = os.path.abspath(
25 os.path.join(os.path.dirname(__file__), '..', '..')) 24 os.path.join(os.path.dirname(__file__), '..', '..'))
26 25
27 DEVIL_PATH = os.path.join(SRC_PATH, 'third_party', 'catapult', 26 DEVIL_PATH = os.path.join(SRC_PATH, 'third_party', 'catapult',
28 'devil') 27 'devil')
29 28
30 if DEVIL_PATH not in sys.path: 29 if DEVIL_PATH not in sys.path:
31 sys.path.append(DEVIL_PATH) 30 sys.path.append(DEVIL_PATH)
32 31
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 ' --android-fonts-path=' + blimp_fonts_path + 94 ' --android-fonts-path=' + blimp_fonts_path +
96 ' --blimp-client-token-path=' + token_file_path + 95 ' --blimp-client-token-path=' + token_file_path +
97 ' --enable-logging=stderr' + 96 ' --enable-logging=stderr' +
98 ' -v=0' + 97 ' -v=0' +
99 ' --vmodule="blimp*=1"'] 98 ' --vmodule="blimp*=1"']
100 p = subprocess.Popen(run_engine_cmd, shell=True, 99 p = subprocess.Popen(run_engine_cmd, shell=True,
101 stdout=subprocess.PIPE, 100 stdout=subprocess.PIPE,
102 stderr=subprocess.STDOUT) 101 stderr=subprocess.STDOUT)
103 102
104 for line in iter(p.stdout.readline, ''): 103 for line in iter(p.stdout.readline, ''):
104 sys.stdout.write(line)
105 l = line.rstrip() 105 l = line.rstrip()
106 match = re.match(PORT_PATTERN, l) 106 match = re.match(PORT_PATTERN, l)
107 if match: 107 if match:
108 port = match.group(1) 108 port = match.group(1)
109 break 109 break
110 110
111 return port, p 111 return port, p
112 112
113 113
114 def SetCommandFlag(device, engine_ip, engine_port): 114 def SetCommandFlag(device, engine_ip, engine_port):
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 setattr(json_args, k, args.__dict__[k]) 166 setattr(json_args, k, args.__dict__[k])
167 json_object = {'args': json_args} 167 json_object = {'args': json_args}
168 device.EnableRoot() 168 device.EnableRoot()
169 host_device_tuples = [(_TOKEN_FILE_PATH, _CLIENT_TOKEN_PATH)] 169 host_device_tuples = [(_TOKEN_FILE_PATH, _CLIENT_TOKEN_PATH)]
170 device.PushChangedFiles(host_device_tuples) 170 device.PushChangedFiles(host_device_tuples)
171 171
172 port_number, engine_process = RunEngine( 172 port_number, engine_process = RunEngine(
173 args.output_linux_directory, _TOKEN_FILE_PATH) 173 args.output_linux_directory, _TOKEN_FILE_PATH)
174 json_object['port_number'] = port_number 174 json_object['port_number'] = port_number
175 json_object['pid'] = engine_process.pid 175 json_object['pid'] = engine_process.pid
176 logging.info("Engine port number: %s", port_number) 176 logging.info('Engine port number: %s', port_number)
177 logging.info("Engine running PID: %d", engine_process.pid) 177 logging.info('Engine running PID: %d', engine_process.pid)
178 178
179 if engine_process.poll() is None: 179 if engine_process.poll() is not None:
180 logging.error('Engine failed to start. Return code: %d',
181 engine_process.poll())
nyquist 2016/08/12 03:45:25 Is this guaranteed to return the same result acros
182 else:
180 try: 183 try:
181 port_pairs = [(port_number, port_number)] 184 port_pairs = [(port_number, port_number)]
182 forwarder.Forwarder.Map(port_pairs, device) 185 forwarder.Forwarder.Map(port_pairs, device)
183 SetCommandFlag(device, args.engine_ip, port_number) 186 SetCommandFlag(device, args.engine_ip, port_number)
184 print "Blimp engine started" 187 print "Blimp engine started"
185 return engine_process 188 return engine_process
186 189
187 finally: 190 finally:
188 with open(json_file_path, 'w') as f: 191 with open(json_file_path, 'w') as f:
189 json.dump(json_object, f, default=_JsonEncodeDefault) 192 json.dump(json_object, f, default=_JsonEncodeDefault)
190 193
191 194
192 def _Run(args, json_file_path, device): 195 def _Run(args, json_file_path, device):
193 """Start engine and forwarder and keep runnning. 196 """Start engine and forwarder and keep runnning.
194 197
195 Args: 198 Args:
196 args: parsed command line arguments. 199 args: parsed command line arguments.
197 json_file_path: json file path which keeps the script variables. 200 json_file_path: json file path which keeps the script variables.
198 device: (DeviceUtils) device to run the tests on. 201 device: (DeviceUtils) device to run the tests on.
199 """ 202 """
200 try: 203 try:
201 engine_process = _Start(args, json_file_path, device) 204 engine_process = _Start(args, json_file_path, device)
202 while True: 205 while True:
203 time.sleep(1) 206 nextline = engine_process.stdout.readline()
204 return_code = engine_process.poll() 207 if nextline == '' and engine_process.poll() is not None:
205 if return_code is not None:
206 # The engine died. 208 # The engine died.
207 sys.exit(1) 209 sys.exit(1)
210 sys.stdout.write(nextline)
211 sys.stdout.flush()
212
208 except KeyboardInterrupt: 213 except KeyboardInterrupt:
209 sys.exit(0) 214 sys.exit(0)
210 finally: 215 finally:
211 _Stop(args, json_file_path, device) 216 _Stop(args, json_file_path, device)
212 217
213 218
214 def _Load(args, json_file_path, device): # pylint: disable=unused-argument 219 def _Load(args, json_file_path, device): # pylint: disable=unused-argument
215 """Start client and load the url 220 """Start client and load the url
216 221
217 Args: 222 Args:
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 else None) 314 else None)
310 device = device_utils.DeviceUtils.HealthyDevices( 315 device = device_utils.DeviceUtils.HealthyDevices(
311 blacklist=blacklist, device_arg=serial)[0] 316 blacklist=blacklist, device_arg=serial)[0]
312 317
313 args.func(args, json_file_path, device) 318 args.func(args, json_file_path, device)
314 319
315 320
316 if __name__ == '__main__': 321 if __name__ == '__main__':
317 main() 322 main()
318 323
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698