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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 # because it may have race condition when multiple processes are trying to | 261 # because it may have race condition when multiple processes are trying to |
262 # launch lighttpd with same port at same time. | 262 # launch lighttpd with same port at same time. |
263 http_server_ports = self.LaunchTestHttpServer( | 263 http_server_ports = self.LaunchTestHttpServer( |
264 os.path.join(constants.CHROME_DIR), | 264 os.path.join(constants.CHROME_DIR), |
265 (constants.LIGHTTPD_RANDOM_PORT_FIRST + self.shard_index)) | 265 (constants.LIGHTTPD_RANDOM_PORT_FIRST + self.shard_index)) |
266 if self.ports_to_forward: | 266 if self.ports_to_forward: |
267 port_pairs = [(port, port) for port in self.ports_to_forward] | 267 port_pairs = [(port, port) for port in self.ports_to_forward] |
268 # We need to remember which ports the HTTP server is using, since the | 268 # We need to remember which ports the HTTP server is using, since the |
269 # forwarder will stomp on them otherwise. | 269 # forwarder will stomp on them otherwise. |
270 port_pairs.append(http_server_ports) | 270 port_pairs.append(http_server_ports) |
271 self.forwarder = Forwarder( | 271 self.forwarder = Forwarder(self.adb, self.build_type) |
272 self.adb, port_pairs, self.tool, '127.0.0.1', self.build_type) | 272 self.forwarder.Run(port_pairs, self.tool, '127.0.0.1') |
273 self.CopyTestFilesOnce() | 273 self.CopyTestFilesOnce() |
274 self.flags.AddFlags(['--enable-test-intents']) | 274 self.flags.AddFlags(['--enable-test-intents']) |
275 | 275 |
276 def TearDown(self): | 276 def TearDown(self): |
277 """Cleans up the test harness and saves outstanding data from test run.""" | 277 """Cleans up the test harness and saves outstanding data from test run.""" |
278 if self.forwarder: | 278 if self.forwarder: |
279 self.forwarder.Close() | 279 self.forwarder.Close() |
280 self.GenerateCoverageReportIfNeeded() | 280 self.GenerateCoverageReportIfNeeded() |
281 super(TestRunner, self).TearDown() | 281 super(TestRunner, self).TearDown() |
282 | 282 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 message)] | 483 message)] |
484 test_result = None | 484 test_result = None |
485 self.TestTeardown(test, test_result) | 485 self.TestTeardown(test, test_result) |
486 return self.test_results | 486 return self.test_results |
487 | 487 |
488 | 488 |
489 class TestSharder(BaseTestSharder): | 489 class TestSharder(BaseTestSharder): |
490 """Responsible for sharding the tests on the connected devices.""" | 490 """Responsible for sharding the tests on the connected devices.""" |
491 | 491 |
492 def __init__(self, attached_devices, options, tests, apks): | 492 def __init__(self, attached_devices, options, tests, apks): |
493 BaseTestSharder.__init__(self, attached_devices) | 493 BaseTestSharder.__init__(self, attached_devices, options.build_type) |
494 self.options = options | 494 self.options = options |
495 self.tests = tests | 495 self.tests = tests |
496 self.apks = apks | 496 self.apks = apks |
497 | 497 |
498 def SetupSharding(self, tests): | 498 def SetupSharding(self, tests): |
499 """Called before starting the shards.""" | 499 """Called before starting the shards.""" |
500 SetTestsContainer(sharded_tests_queue.ShardedTestsQueue( | 500 SetTestsContainer(sharded_tests_queue.ShardedTestsQueue( |
501 len(self.attached_devices), tests)) | 501 len(self.attached_devices), tests)) |
502 | 502 |
503 def CreateShardedTestRunner(self, device, index): | 503 def CreateShardedTestRunner(self, device, index): |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 | 574 |
575 logging.info('Will run: %s', str(tests)) | 575 logging.info('Will run: %s', str(tests)) |
576 | 576 |
577 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): | 577 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): |
578 logging.warning('Coverage / debugger can not be sharded, ' | 578 logging.warning('Coverage / debugger can not be sharded, ' |
579 'using first available device') | 579 'using first available device') |
580 attached_devices = attached_devices[:1] | 580 attached_devices = attached_devices[:1] |
581 sharder = TestSharder(attached_devices, options, tests, apks) | 581 sharder = TestSharder(attached_devices, options, tests, apks) |
582 test_results = sharder.RunShardedTests() | 582 test_results = sharder.RunShardedTests() |
583 return test_results | 583 return test_results |
OLD | NEW |