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 self.forwarder = None | 133 # List of forwarders created by this instance of TestRunner. |
| 134 self.forwarders = [] |
134 | 135 |
135 if self.coverage: | 136 if self.coverage: |
136 if os.path.exists(TestRunner._COVERAGE_MERGED_FILENAME): | 137 if os.path.exists(TestRunner._COVERAGE_MERGED_FILENAME): |
137 os.remove(TestRunner._COVERAGE_MERGED_FILENAME) | 138 os.remove(TestRunner._COVERAGE_MERGED_FILENAME) |
138 if not os.path.exists(TestRunner._COVERAGE_META_INFO_PATH): | 139 if not os.path.exists(TestRunner._COVERAGE_META_INFO_PATH): |
139 raise FatalTestException('FATAL ERROR in ' + sys.argv[0] + | 140 raise FatalTestException('FATAL ERROR in ' + sys.argv[0] + |
140 ' : Coverage meta info [' + | 141 ' : Coverage meta info [' + |
141 TestRunner._COVERAGE_META_INFO_PATH + | 142 TestRunner._COVERAGE_META_INFO_PATH + |
142 '] does not exist.') | 143 '] does not exist.') |
143 if (not TestRunner._COVERAGE_WEB_ROOT_DIR or | 144 if (not TestRunner._COVERAGE_WEB_ROOT_DIR or |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 # We give different default value to launch HTTP server based on shard index | 270 # We give different default value to launch HTTP server based on shard index |
270 # because it may have race condition when multiple processes are trying to | 271 # because it may have race condition when multiple processes are trying to |
271 # launch lighttpd with same port at same time. | 272 # launch lighttpd with same port at same time. |
272 # This line *must* come before the forwarding below, as it nukes all | 273 # This line *must* come before the forwarding below, as it nukes all |
273 # the other forwarders. A more comprehensive fix might be to pull the | 274 # the other forwarders. A more comprehensive fix might be to pull the |
274 # forwarder-killing line up to here, but that might violate assumptions | 275 # forwarder-killing line up to here, but that might violate assumptions |
275 # implicit in other places. | 276 # implicit in other places. |
276 self.LaunchTestHttpServer(os.path.join(constants.CHROME_DIR), | 277 self.LaunchTestHttpServer(os.path.join(constants.CHROME_DIR), |
277 (constants.LIGHTTPD_RANDOM_PORT_FIRST + | 278 (constants.LIGHTTPD_RANDOM_PORT_FIRST + |
278 self.shard_index)) | 279 self.shard_index)) |
| 280 |
279 if self.ports_to_forward: | 281 if self.ports_to_forward: |
280 port_pairs = [(port, port) for port in self.ports_to_forward] | 282 for port in self.ports_to_forward: |
281 self.forwarder = Forwarder( | 283 self.forwarders.append(Forwarder( |
282 self.adb, port_pairs, self.tool, '127.0.0.1', self.build_type) | 284 self.adb, [(port, port)], self.tool, '127.0.0.1', self.build_type)) |
283 self.CopyTestFilesOnce() | 285 self.CopyTestFilesOnce() |
284 self.flags.AddFlags(['--enable-test-intents']) | 286 self.flags.AddFlags(['--enable-test-intents']) |
285 | 287 |
286 def TearDown(self): | 288 def TearDown(self): |
287 """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.""" |
288 if self.forwarder: | 290 if self.forwarders: |
289 self.forwarder.Close() | 291 for forwarder in self.forwarders: |
| 292 forwarder.Close() |
290 self.GenerateCoverageReportIfNeeded() | 293 self.GenerateCoverageReportIfNeeded() |
291 super(TestRunner, self).TearDown() | 294 super(TestRunner, self).TearDown() |
292 | 295 |
293 def TestSetup(self, test): | 296 def TestSetup(self, test): |
294 """Sets up the test harness for running a particular test. | 297 """Sets up the test harness for running a particular test. |
295 | 298 |
296 Args: | 299 Args: |
297 test: The name of the test that will be run. | 300 test: The name of the test that will be run. |
298 """ | 301 """ |
299 self.SetupPerfMonitoringIfNeeded(test) | 302 self.SetupPerfMonitoringIfNeeded(test) |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 | 587 |
585 logging.info('Will run: %s', str(tests)) | 588 logging.info('Will run: %s', str(tests)) |
586 | 589 |
587 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): | 590 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): |
588 logging.warning('Coverage / debugger can not be sharded, ' | 591 logging.warning('Coverage / debugger can not be sharded, ' |
589 'using first available device') | 592 'using first available device') |
590 attached_devices = attached_devices[:1] | 593 attached_devices = attached_devices[:1] |
591 sharder = TestSharder(attached_devices, options, tests, apks) | 594 sharder = TestSharder(attached_devices, options, tests, apks) |
592 test_results = sharder.RunShardedTests() | 595 test_results = sharder.RunShardedTests() |
593 return test_results | 596 return test_results |
OLD | NEW |