 Chromium Code Reviews
 Chromium Code Reviews Issue 10957052:
  Adapt python scripts to use the new Forwarder2  (Closed) 
  Base URL: http://git.chromium.org/chromium/src.git@master
    
  
    Issue 10957052:
  Adapt python scripts to use the new Forwarder2  (Closed) 
  Base URL: http://git.chromium.org/chromium/src.git@master| OLD | NEW | 
|---|---|
| 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 """Runs the Java tests. See more information on run_instrumentation_tests.py.""" | 5 """Runs the Java tests. See more information on run_instrumentation_tests.py.""" | 
| 6 | 6 | 
| 7 import fnmatch | 7 import fnmatch | 
| 8 import logging | 8 import logging | 
| 9 import os | 9 import os | 
| 10 import re | 10 import re | 
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 self.wait_for_debugger = options.wait_for_debugger | 123 self.wait_for_debugger = options.wait_for_debugger | 
| 124 | 124 | 
| 125 self.tests_iter = tests_iter | 125 self.tests_iter = tests_iter | 
| 126 self.coverage = coverage | 126 self.coverage = coverage | 
| 127 self.apks = apks | 127 self.apks = apks | 
| 128 self.test_apk = apks[0] | 128 self.test_apk = apks[0] | 
| 129 self.instrumentation_class_path = self.test_apk.GetPackageName() | 129 self.instrumentation_class_path = self.test_apk.GetPackageName() | 
| 130 self.ports_to_forward = ports_to_forward | 130 self.ports_to_forward = ports_to_forward | 
| 131 | 131 | 
| 132 self.test_results = TestResults() | 132 self.test_results = TestResults() | 
| 133 # List of forwarders created by this instance of TestRunner. | 133 self.forwarder = None | 
| 134 self.forwarders = [] | |
| 135 | 134 | 
| 136 if self.coverage: | 135 if self.coverage: | 
| 137 if os.path.exists(TestRunner._COVERAGE_MERGED_FILENAME): | 136 if os.path.exists(TestRunner._COVERAGE_MERGED_FILENAME): | 
| 138 os.remove(TestRunner._COVERAGE_MERGED_FILENAME) | 137 os.remove(TestRunner._COVERAGE_MERGED_FILENAME) | 
| 139 if not os.path.exists(TestRunner._COVERAGE_META_INFO_PATH): | 138 if not os.path.exists(TestRunner._COVERAGE_META_INFO_PATH): | 
| 140 raise FatalTestException('FATAL ERROR in ' + sys.argv[0] + | 139 raise FatalTestException('FATAL ERROR in ' + sys.argv[0] + | 
| 141 ' : Coverage meta info [' + | 140 ' : Coverage meta info [' + | 
| 142 TestRunner._COVERAGE_META_INFO_PATH + | 141 TestRunner._COVERAGE_META_INFO_PATH + | 
| 143 '] does not exist.') | 142 '] does not exist.') | 
| 144 if (not TestRunner._COVERAGE_WEB_ROOT_DIR or | 143 if (not TestRunner._COVERAGE_WEB_ROOT_DIR or | 
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 # We give different default value to launch HTTP server based on shard index | 269 # We give different default value to launch HTTP server based on shard index | 
| 271 # because it may have race condition when multiple processes are trying to | 270 # because it may have race condition when multiple processes are trying to | 
| 272 # launch lighttpd with same port at same time. | 271 # launch lighttpd with same port at same time. | 
| 273 # This line *must* come before the forwarding below, as it nukes all | 272 # This line *must* come before the forwarding below, as it nukes all | 
| 274 # the other forwarders. A more comprehensive fix might be to pull the | 273 # the other forwarders. A more comprehensive fix might be to pull the | 
| 275 # forwarder-killing line up to here, but that might violate assumptions | 274 # forwarder-killing line up to here, but that might violate assumptions | 
| 276 # implicit in other places. | 275 # implicit in other places. | 
| 277 self.LaunchTestHttpServer(os.path.join(constants.CHROME_DIR), | 276 self.LaunchTestHttpServer(os.path.join(constants.CHROME_DIR), | 
| 278 (constants.LIGHTTPD_RANDOM_PORT_FIRST + | 277 (constants.LIGHTTPD_RANDOM_PORT_FIRST + | 
| 279 self.shard_index)) | 278 self.shard_index)) | 
| 280 | 279 port_pairs = [] | 
| 
bulach
2012/09/26 15:13:11
nit: can move this to 281 directly and remove the
 
felipeg
2012/09/26 18:06:03
Done.
 | |
| 281 if self.ports_to_forward: | 280 if self.ports_to_forward: | 
| 282 for port in self.ports_to_forward: | 281 for port in self.ports_to_forward: | 
| 283 self.forwarders.append(Forwarder( | 282 port_pairs.append([(port, port)]) | 
| 284 self.adb, [(port, port)], self.tool, '127.0.0.1', self.build_type)) | 283 self.forwarder = Forwarder( | 
| 284 self.adb, port_pairs, self.tool, '127.0.0.1', self.build_type) | |
| 285 self.CopyTestFilesOnce() | 285 self.CopyTestFilesOnce() | 
| 286 self.flags.AddFlags(['--enable-test-intents']) | 286 self.flags.AddFlags(['--enable-test-intents']) | 
| 287 | 287 | 
| 288 def TearDown(self): | 288 def TearDown(self): | 
| 289 """Cleans up the test harness and saves outstanding data from test run.""" | 289 """Cleans up the test harness and saves outstanding data from test run.""" | 
| 290 if self.forwarders: | 290 if self.forwarder: | 
| 291 for forwarder in self.forwarders: | 291 self.forwarder.Close() | 
| 292 forwarder.Close() | |
| 293 self.GenerateCoverageReportIfNeeded() | 292 self.GenerateCoverageReportIfNeeded() | 
| 294 super(TestRunner, self).TearDown() | 293 super(TestRunner, self).TearDown() | 
| 295 | 294 | 
| 296 def TestSetup(self, test): | 295 def TestSetup(self, test): | 
| 297 """Sets up the test harness for running a particular test. | 296 """Sets up the test harness for running a particular test. | 
| 298 | 297 | 
| 299 Args: | 298 Args: | 
| 300 test: The name of the test that will be run. | 299 test: The name of the test that will be run. | 
| 301 """ | 300 """ | 
| 302 self.SetupPerfMonitoringIfNeeded(test) | 301 self.SetupPerfMonitoringIfNeeded(test) | 
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 | 586 | 
| 588 logging.info('Will run: %s', str(tests)) | 587 logging.info('Will run: %s', str(tests)) | 
| 589 | 588 | 
| 590 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): | 589 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): | 
| 591 logging.warning('Coverage / debugger can not be sharded, ' | 590 logging.warning('Coverage / debugger can not be sharded, ' | 
| 592 'using first available device') | 591 'using first available device') | 
| 593 attached_devices = attached_devices[:1] | 592 attached_devices = attached_devices[:1] | 
| 594 sharder = TestSharder(attached_devices, options, tests, apks) | 593 sharder = TestSharder(attached_devices, options, tests, apks) | 
| 595 test_results = sharder.RunShardedTests() | 594 test_results = sharder.RunShardedTests() | 
| 596 return test_results | 595 return test_results | 
| OLD | NEW |