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

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: use sys.stdout.write instead of print 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 None:
nyquist 2016/08/11 23:09:43 If this is not the case, could we log an error? I
shenghuazhang 2016/08/12 00:24:36 Done.
180 try: 180 try:
181 port_pairs = [(port_number, port_number)] 181 port_pairs = [(port_number, port_number)]
182 forwarder.Forwarder.Map(port_pairs, device) 182 forwarder.Forwarder.Map(port_pairs, device)
183 SetCommandFlag(device, args.engine_ip, port_number) 183 SetCommandFlag(device, args.engine_ip, port_number)
184 print "Blimp engine started" 184 print "Blimp engine started"
185 return engine_process 185 return engine_process
186 186
187 finally: 187 finally:
188 with open(json_file_path, 'w') as f: 188 with open(json_file_path, 'w') as f:
189 json.dump(json_object, f, default=_JsonEncodeDefault) 189 json.dump(json_object, f, default=_JsonEncodeDefault)
190 190
191 191
192 def _Run(args, json_file_path, device): 192 def _Run(args, json_file_path, device):
193 """Start engine and forwarder and keep runnning. 193 """Start engine and forwarder and keep runnning.
194 194
195 Args: 195 Args:
196 args: parsed command line arguments. 196 args: parsed command line arguments.
197 json_file_path: json file path which keeps the script variables. 197 json_file_path: json file path which keeps the script variables.
198 device: (DeviceUtils) device to run the tests on. 198 device: (DeviceUtils) device to run the tests on.
199 """ 199 """
200 try: 200 try:
201 engine_process = _Start(args, json_file_path, device) 201 engine_process = _Start(args, json_file_path, device)
202 while True: 202 while True:
203 time.sleep(1) 203 nextline = engine_process.stdout.readline()
204 return_code = engine_process.poll() 204 if nextline == '' and engine_process.poll() is not None:
205 if return_code is not None:
206 # The engine died. 205 # The engine died.
207 sys.exit(1) 206 sys.exit(1)
207 sys.stdout.write(nextline)
208 sys.stdout.flush()
209
208 except KeyboardInterrupt: 210 except KeyboardInterrupt:
209 sys.exit(0) 211 sys.exit(0)
210 finally: 212 finally:
211 _Stop(args, json_file_path, device) 213 _Stop(args, json_file_path, device)
212 214
213 215
214 def _Load(args, json_file_path, device): # pylint: disable=unused-argument 216 def _Load(args, json_file_path, device): # pylint: disable=unused-argument
215 """Start client and load the url 217 """Start client and load the url
216 218
217 Args: 219 Args:
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 else None) 311 else None)
310 device = device_utils.DeviceUtils.HealthyDevices( 312 device = device_utils.DeviceUtils.HealthyDevices(
311 blacklist=blacklist, device_arg=serial)[0] 313 blacklist=blacklist, device_arg=serial)[0]
312 314
313 args.func(args, json_file_path, device) 315 args.func(args, json_file_path, device)
314 316
315 317
316 if __name__ == '__main__': 318 if __name__ == '__main__':
317 main() 319 main()
318 320
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