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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 Args: | 89 Args: |
90 options: An options object with the following required attributes: | 90 options: An options object with the following required attributes: |
91 - build_type: 'Release' or 'Debug'. | 91 - build_type: 'Release' or 'Debug'. |
92 - install_apk: Re-installs the apk if opted. | 92 - install_apk: Re-installs the apk if opted. |
93 - save_perf_json: Whether or not to save the JSON file from UI perf | 93 - save_perf_json: Whether or not to save the JSON file from UI perf |
94 tests. | 94 tests. |
95 - screenshot_failures: Take a screenshot for a test failure | 95 - screenshot_failures: Take a screenshot for a test failure |
96 - tool: Name of the Valgrind tool. | 96 - tool: Name of the Valgrind tool. |
97 - wait_for_debugger: blocks until the debugger is connected. | 97 - wait_for_debugger: blocks until the debugger is connected. |
| 98 - disable_assertions: Whether to disable java assertions on the device. |
98 device: Attached android device. | 99 device: Attached android device. |
99 tests_iter: A list of tests to be run. | 100 tests_iter: A list of tests to be run. |
100 coverage: Collects coverage information if opted. | 101 coverage: Collects coverage information if opted. |
101 shard_index: shard # for this TestRunner, used to create unique port | 102 shard_index: shard # for this TestRunner, used to create unique port |
102 numbers. | 103 numbers. |
103 apks: A list of ApkInfo objects need to be installed. The first element | 104 apks: A list of ApkInfo objects need to be installed. The first element |
104 should be the tests apk, the rests could be the apks used in test. | 105 should be the tests apk, the rests could be the apks used in test. |
105 The default is ChromeTest.apk. | 106 The default is ChromeTest.apk. |
106 ports_to_forward: A list of port numbers for which to set up forwarders. | 107 ports_to_forward: A list of port numbers for which to set up forwarders. |
107 Can be optionally requested by a test case. | 108 Can be optionally requested by a test case. |
108 Raises: | 109 Raises: |
109 FatalTestException: if coverage metadata is not available. | 110 FatalTestException: if coverage metadata is not available. |
110 """ | 111 """ |
111 BaseTestRunner.__init__( | 112 BaseTestRunner.__init__( |
112 self, device, options.tool, shard_index, options.build_type) | 113 self, device, options.tool, shard_index, options.build_type) |
113 | 114 |
114 if not apks: | 115 if not apks: |
115 apks = [apk_info.ApkInfo(options.test_apk_path, | 116 apks = [apk_info.ApkInfo(options.test_apk_path, |
116 options.test_apk_jar_path)] | 117 options.test_apk_jar_path)] |
117 | 118 |
118 self.build_type = options.build_type | 119 self.build_type = options.build_type |
119 self.install_apk = options.install_apk | 120 self.install_apk = options.install_apk |
120 self.save_perf_json = options.save_perf_json | 121 self.save_perf_json = options.save_perf_json |
121 self.screenshot_failures = options.screenshot_failures | 122 self.screenshot_failures = options.screenshot_failures |
122 self.wait_for_debugger = options.wait_for_debugger | 123 self.wait_for_debugger = options.wait_for_debugger |
| 124 self.disable_assertions = options.disable_assertions |
123 | 125 |
124 self.tests_iter = tests_iter | 126 self.tests_iter = tests_iter |
125 self.coverage = coverage | 127 self.coverage = coverage |
126 self.apks = apks | 128 self.apks = apks |
127 self.test_apk = apks[0] | 129 self.test_apk = apks[0] |
128 self.instrumentation_class_path = self.test_apk.GetPackageName() | 130 self.instrumentation_class_path = self.test_apk.GetPackageName() |
129 self.ports_to_forward = ports_to_forward | 131 self.ports_to_forward = ports_to_forward |
130 | 132 |
131 self.test_results = TestResults() | 133 self.test_results = TestResults() |
132 self.forwarder = None | 134 self.forwarder = None |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 '--serial', self.device, | 257 '--serial', self.device, |
256 '--file', screenshot_name]) | 258 '--file', screenshot_name]) |
257 | 259 |
258 def SetUp(self): | 260 def SetUp(self): |
259 """Sets up the test harness and device before all tests are run.""" | 261 """Sets up the test harness and device before all tests are run.""" |
260 super(TestRunner, self).SetUp() | 262 super(TestRunner, self).SetUp() |
261 if not self.adb.IsRootEnabled(): | 263 if not self.adb.IsRootEnabled(): |
262 logging.warning('Unable to enable java asserts for %s, non rooted device', | 264 logging.warning('Unable to enable java asserts for %s, non rooted device', |
263 self.device) | 265 self.device) |
264 else: | 266 else: |
265 if self.adb.SetJavaAssertsEnabled(enable=True): | 267 if self.adb.SetJavaAssertsEnabled(enable=not self.disable_assertions): |
266 self.adb.Reboot(full_reboot=False) | 268 self.adb.Reboot(full_reboot=False) |
267 | 269 |
268 # 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 |
269 # 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 |
270 # launch lighttpd with same port at same time. | 272 # launch lighttpd with same port at same time. |
271 http_server_ports = self.LaunchTestHttpServer( | 273 http_server_ports = self.LaunchTestHttpServer( |
272 os.path.join(constants.CHROME_DIR), | 274 os.path.join(constants.CHROME_DIR), |
273 (constants.LIGHTTPD_RANDOM_PORT_FIRST + self.shard_index)) | 275 (constants.LIGHTTPD_RANDOM_PORT_FIRST + self.shard_index)) |
274 if self.ports_to_forward: | 276 if self.ports_to_forward: |
275 port_pairs = [(port, port) for port in self.ports_to_forward] | 277 port_pairs = [(port, port) for port in self.ports_to_forward] |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 | 584 |
583 logging.info('Will run: %s', str(tests)) | 585 logging.info('Will run: %s', str(tests)) |
584 | 586 |
585 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): | 587 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): |
586 logging.warning('Coverage / debugger can not be sharded, ' | 588 logging.warning('Coverage / debugger can not be sharded, ' |
587 'using first available device') | 589 'using first available device') |
588 attached_devices = attached_devices[:1] | 590 attached_devices = attached_devices[:1] |
589 sharder = TestSharder(attached_devices, options, tests, apks) | 591 sharder = TestSharder(attached_devices, options, tests, apks) |
590 test_results = sharder.RunShardedTests() | 592 test_results = sharder.RunShardedTests() |
591 return test_results | 593 return test_results |
OLD | NEW |