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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 _DEVICE_PERF_OUTPUT_SEARCH_PREFIX = (_DEVICE_PERF_OUTPUT_DIR + | 82 _DEVICE_PERF_OUTPUT_SEARCH_PREFIX = (_DEVICE_PERF_OUTPUT_DIR + |
83 'chrome-profile*') | 83 'chrome-profile*') |
84 _DEVICE_HAS_TEST_FILES = {} | 84 _DEVICE_HAS_TEST_FILES = {} |
85 | 85 |
86 def __init__(self, options, device, tests_iter, coverage, shard_index, apks, | 86 def __init__(self, options, device, tests_iter, coverage, shard_index, apks, |
87 ports_to_forward): | 87 ports_to_forward): |
88 """Create a new TestRunner. | 88 """Create a new TestRunner. |
89 | 89 |
90 Args: | 90 Args: |
91 options: An options object with the following required attributes: | 91 options: An options object with the following required attributes: |
| 92 - build_type: 'Release' or 'Debug'. |
92 - install_apk: Re-installs the apk if opted. | 93 - install_apk: Re-installs the apk if opted. |
93 - save_perf_json: Whether or not to save the JSON file from UI perf | 94 - save_perf_json: Whether or not to save the JSON file from UI perf |
94 tests. | 95 tests. |
95 - screenshot_failures: Take a screenshot for a test failure | 96 - screenshot_failures: Take a screenshot for a test failure |
96 - tool: Name of the Valgrind tool. | 97 - tool: Name of the Valgrind tool. |
97 - wait_for_debugger: blocks until the debugger is connected. | 98 - wait_for_debugger: blocks until the debugger is connected. |
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__(self, device, options.tool, shard_index) | 112 BaseTestRunner.__init__( |
| 113 self, device, options.tool, shard_index, options.build_type) |
112 | 114 |
113 if not apks: | 115 if not apks: |
114 apks = [apk_info.ApkInfo(options.test_apk_path, | 116 apks = [apk_info.ApkInfo(options.test_apk_path, |
115 options.test_apk_jar_path)] | 117 options.test_apk_jar_path)] |
116 | 118 |
| 119 self.build_type = options.build_type |
117 self.install_apk = options.install_apk | 120 self.install_apk = options.install_apk |
118 self.save_perf_json = options.save_perf_json | 121 self.save_perf_json = options.save_perf_json |
119 self.screenshot_failures = options.screenshot_failures | 122 self.screenshot_failures = options.screenshot_failures |
120 self.wait_for_debugger = options.wait_for_debugger | 123 self.wait_for_debugger = options.wait_for_debugger |
121 | 124 |
122 self.tests_iter = tests_iter | 125 self.tests_iter = tests_iter |
123 self.coverage = coverage | 126 self.coverage = coverage |
124 self.apks = apks | 127 self.apks = apks |
125 self.test_apk = apks[0] | 128 self.test_apk = apks[0] |
126 self.instrumentation_class_path = self.test_apk.GetPackageName() | 129 self.instrumentation_class_path = self.test_apk.GetPackageName() |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 # This line *must* come before the forwarding below, as it nukes all | 264 # This line *must* come before the forwarding below, as it nukes all |
262 # the other forwarders. A more comprehensive fix might be to pull the | 265 # the other forwarders. A more comprehensive fix might be to pull the |
263 # forwarder-killing line up to here, but that might violate assumptions | 266 # forwarder-killing line up to here, but that might violate assumptions |
264 # implicit in other places. | 267 # implicit in other places. |
265 self.LaunchTestHttpServer(os.path.join(constants.CHROME_DIR), | 268 self.LaunchTestHttpServer(os.path.join(constants.CHROME_DIR), |
266 (constants.LIGHTTPD_RANDOM_PORT_FIRST + | 269 (constants.LIGHTTPD_RANDOM_PORT_FIRST + |
267 self.shard_index)) | 270 self.shard_index)) |
268 | 271 |
269 if self.ports_to_forward: | 272 if self.ports_to_forward: |
270 for port in self.ports_to_forward: | 273 for port in self.ports_to_forward: |
271 self.forwarders.append( | 274 self.forwarders.append(Forwarder( |
272 Forwarder(self.adb, [(port, port)], self.tool, '127.0.0.1')) | 275 self.adb, [(port, port)], self.tool, '127.0.0.1', self.build_type)) |
273 self.CopyTestFilesOnce() | 276 self.CopyTestFilesOnce() |
274 self.flags.AddFlags(['--enable-test-intents']) | 277 self.flags.AddFlags(['--enable-test-intents']) |
275 | 278 |
276 def TearDown(self): | 279 def TearDown(self): |
277 """Cleans up the test harness and saves outstanding data from test run.""" | 280 """Cleans up the test harness and saves outstanding data from test run.""" |
278 if self.forwarders: | 281 if self.forwarders: |
279 for forwarder in self.forwarders: | 282 for forwarder in self.forwarders: |
280 forwarder.Close() | 283 forwarder.Close() |
281 self.GenerateCoverageReportIfNeeded() | 284 self.GenerateCoverageReportIfNeeded() |
282 super(TestRunner, self).TearDown() | 285 super(TestRunner, self).TearDown() |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 if (len(attached_devices) > 1 and | 588 if (len(attached_devices) > 1 and |
586 not coverage and | 589 not coverage and |
587 not options.wait_for_debugger): | 590 not options.wait_for_debugger): |
588 sharder = TestSharder(attached_devices, options, tests, apks) | 591 sharder = TestSharder(attached_devices, options, tests, apks) |
589 test_results = sharder.RunShardedTests() | 592 test_results = sharder.RunShardedTests() |
590 else: | 593 else: |
591 runner = TestRunner(options, attached_devices[0], tests, coverage, 0, apks, | 594 runner = TestRunner(options, attached_devices[0], tests, coverage, 0, apks, |
592 []) | 595 []) |
593 test_results = runner.Run() | 596 test_results = runner.Run() |
594 return test_results | 597 return test_results |
OLD | NEW |