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

Side by Side Diff: components/cronet/android/test/javaperftests/run.py

Issue 1942283002: [Cronet] Resurrect Android USB reverse tethering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « components/cronet/android/test/javaperftests/android_rndis_forwarder.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 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 """This script runs an automated Cronet performance benchmark. 6 """This script runs an automated Cronet performance benchmark.
7 7
8 This script: 8 This script:
9 1. Sets up "USB reverse tethering" which allow network traffic to flow from 9 1. Sets up "USB reverse tethering" which allow network traffic to flow from
10 an Android device connected to the host machine via a USB cable. 10 an Android device connected to the host machine via a USB cable.
(...skipping 30 matching lines...) Expand all
41 import urllib 41 import urllib
42 42
43 REPOSITORY_ROOT = os.path.abspath(os.path.join( 43 REPOSITORY_ROOT = os.path.abspath(os.path.join(
44 os.path.dirname(__file__), '..', '..', '..', '..', '..')) 44 os.path.dirname(__file__), '..', '..', '..', '..', '..'))
45 45
46 sys.path.append(os.path.join(REPOSITORY_ROOT, 'tools', 'perf')) 46 sys.path.append(os.path.join(REPOSITORY_ROOT, 'tools', 'perf'))
47 from chrome_telemetry_build import chromium_config 47 from chrome_telemetry_build import chromium_config
48 sys.path.append(chromium_config.GetTelemetryDir()) 48 sys.path.append(chromium_config.GetTelemetryDir())
49 sys.path.append(os.path.join(REPOSITORY_ROOT, 'build', 'android')) 49 sys.path.append(os.path.join(REPOSITORY_ROOT, 'build', 'android'))
50 50
51 import android_rndis_forwarder
51 import lighttpd_server 52 import lighttpd_server
52 from pylib import constants 53 from pylib import constants
53 from pylib import pexpect 54 from pylib import pexpect
54 from pylib.device import device_utils 55 from pylib.device import device_utils
55 from pylib.device import intent 56 from pylib.device import intent
56 from telemetry import android 57 from telemetry import android
57 from telemetry import benchmark 58 from telemetry import benchmark
58 from telemetry import benchmark_runner 59 from telemetry import benchmark_runner
59 from telemetry import project_config 60 from telemetry import project_config
60 from telemetry import story 61 from telemetry import story
61 from telemetry.internal import forwarders
62 from telemetry.internal.forwarders import android_forwarder
63 from telemetry.value import scalar 62 from telemetry.value import scalar
64 from telemetry.web_perf import timeline_based_measurement 63 from telemetry.web_perf import timeline_based_measurement
65 64
66 BUILD_TYPE = 'Release' 65 BUILD_TYPE = 'Release'
67 BUILD_DIR = os.path.join(REPOSITORY_ROOT, 'out', BUILD_TYPE) 66 BUILD_DIR = os.path.join(REPOSITORY_ROOT, 'out', BUILD_TYPE)
68 QUIC_SERVER = os.path.join(BUILD_DIR, 'quic_server') 67 QUIC_SERVER = os.path.join(BUILD_DIR, 'quic_server')
69 QUIC_CLIENT = os.path.join(BUILD_DIR, 'quic_client') 68 QUIC_CLIENT = os.path.join(BUILD_DIR, 'quic_client')
70 CERT_PATH = os.path.join('net', 'data', 'ssl', 'certificates') 69 CERT_PATH = os.path.join('net', 'data', 'ssl', 'certificates')
71 QUIC_CERT_DIR = os.path.join(REPOSITORY_ROOT, CERT_PATH) 70 QUIC_CERT_DIR = os.path.join(REPOSITORY_ROOT, CERT_PATH)
72 QUIC_CERT_HOST = 'test.example.com' 71 QUIC_CERT_HOST = 'test.example.com'
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 # Add benchmark config to global state for easy access. 110 # Add benchmark config to global state for easy access.
112 globals().update(BENCHMARK_CONFIG) 111 globals().update(BENCHMARK_CONFIG)
113 112
114 113
115 def GetDevice(): 114 def GetDevice():
116 devices = device_utils.DeviceUtils.HealthyDevices() 115 devices = device_utils.DeviceUtils.HealthyDevices()
117 assert len(devices) == 1 116 assert len(devices) == 1
118 return devices[0] 117 return devices[0]
119 118
120 119
121 def GetForwarderFactory(device): 120 def GetAndroidRndisConfig(device):
122 return android_forwarder.AndroidForwarderFactory(device, True) 121 return android_rndis_forwarder.AndroidRndisConfigurator(device)
123 122
124 123
125 def GetServersHost(device): 124 def GetServersHost(device):
126 return GetForwarderFactory(device).host_ip 125 return GetAndroidRndisConfig(device).host_ip
127 126
128 127
129 def GetHttpServerURL(device, resource): 128 def GetHttpServerURL(device, resource):
130 return 'http://%s:%d/%s' % (GetServersHost(device), HTTP_PORT, resource) 129 return 'http://%s:%d/%s' % (GetServersHost(device), HTTP_PORT, resource)
131 130
132 131
133 class CronetPerfTestAndroidStory(android.AndroidStory): 132 class CronetPerfTestAndroidStory(android.AndroidStory):
134 # Android AppStory implementation wrapping CronetPerfTest app. 133 # Android AppStory implementation wrapping CronetPerfTest app.
135 # Launches Cronet perf test app and waits for execution to complete 134 # Launches Cronet perf test app and waits for execution to complete
136 # by waiting for presence of DONE_FILE. 135 # by waiting for presence of DONE_FILE.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 config_file.flush() 289 config_file.flush()
291 290
292 291
293 def main(): 292 def main():
294 constants.SetBuildType(BUILD_TYPE) 293 constants.SetBuildType(BUILD_TYPE)
295 # Install APK 294 # Install APK
296 device = GetDevice() 295 device = GetDevice()
297 device.EnableRoot() 296 device.EnableRoot()
298 device.Install(APP_APK) 297 device.Install(APP_APK)
299 # Start USB reverse tethering. 298 # Start USB reverse tethering.
300 # Port map is ignored for tethering; must create one to placate assertions. 299 android_rndis_forwarder.AndroidRndisForwarder(device,
301 named_port_pair_map = {'http': (forwarders.PortPair(0, 0)), 300 GetAndroidRndisConfig(device))
302 'https': None, 'dns': None}
303 port_pairs = forwarders.PortPairs(**named_port_pair_map)
304 forwarder = GetForwarderFactory(device).Create(port_pairs)
305 # Start HTTP server. 301 # Start HTTP server.
306 http_server_doc_root = GenerateHttpTestResources() 302 http_server_doc_root = GenerateHttpTestResources()
307 config_file = tempfile.NamedTemporaryFile() 303 config_file = tempfile.NamedTemporaryFile()
308 http_server = lighttpd_server.LighttpdServer(http_server_doc_root, 304 http_server = lighttpd_server.LighttpdServer(http_server_doc_root,
309 port=HTTP_PORT, base_config_path=config_file.name) 305 port=HTTP_PORT, base_config_path=config_file.name)
310 GenerateLighttpdConfig(config_file, http_server_doc_root, http_server) 306 GenerateLighttpdConfig(config_file, http_server_doc_root, http_server)
311 assert http_server.StartupHttpServer() 307 assert http_server.StartupHttpServer()
312 config_file.close() 308 config_file.close()
313 # Start QUIC server. 309 # Start QUIC server.
314 quic_server_doc_root = GenerateQuicTestResources(device) 310 quic_server_doc_root = GenerateQuicTestResources(device)
(...skipping 10 matching lines...) Expand all
325 'binary_dependencies.json') 321 'binary_dependencies.json')
326 with open(perf_config_file, "w") as config_file: 322 with open(perf_config_file, "w") as config_file:
327 config_file.write('{"config_type": "BaseConfig"}') 323 config_file.write('{"config_type": "BaseConfig"}')
328 runner_config = project_config.ProjectConfig( 324 runner_config = project_config.ProjectConfig(
329 top_level_dir=top_level_dir, 325 top_level_dir=top_level_dir,
330 benchmark_dirs=[top_level_dir], 326 benchmark_dirs=[top_level_dir],
331 client_configs=[perf_config_file], 327 client_configs=[perf_config_file],
332 default_chrome_root=REPOSITORY_ROOT) 328 default_chrome_root=REPOSITORY_ROOT)
333 sys.argv.insert(1, 'run') 329 sys.argv.insert(1, 'run')
334 sys.argv.insert(2, 'run.CronetPerfTestBenchmark') 330 sys.argv.insert(2, 'run.CronetPerfTestBenchmark')
335 sys.argv.insert(3, '--android-rndis')
336 benchmark_runner.main(runner_config) 331 benchmark_runner.main(runner_config)
337 # Shutdown. 332 # Shutdown.
338 quic_server.ShutdownQuicServer() 333 quic_server.ShutdownQuicServer()
339 shutil.rmtree(quic_server_doc_root) 334 shutil.rmtree(quic_server_doc_root)
340 http_server.ShutdownHttpServer() 335 http_server.ShutdownHttpServer()
341 shutil.rmtree(http_server_doc_root) 336 shutil.rmtree(http_server_doc_root)
342 337
343 338
344 if __name__ == '__main__': 339 if __name__ == '__main__':
345 main() 340 main()
OLDNEW
« no previous file with comments | « components/cronet/android/test/javaperftests/android_rndis_forwarder.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698