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 """Class for running instrumentation tests on a single device.""" | 5 """Class for running instrumentation tests on a single device.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import re | 9 import re |
10 import shutil | 10 import shutil |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 else: | 144 else: |
145 if self.adb.SetJavaAssertsEnabled(enable=not self.disable_assertions): | 145 if self.adb.SetJavaAssertsEnabled(enable=not self.disable_assertions): |
146 self.adb.Reboot(full_reboot=False) | 146 self.adb.Reboot(full_reboot=False) |
147 | 147 |
148 # We give different default value to launch HTTP server based on shard index | 148 # We give different default value to launch HTTP server based on shard index |
149 # because it may have race condition when multiple processes are trying to | 149 # because it may have race condition when multiple processes are trying to |
150 # launch lighttpd with same port at same time. | 150 # launch lighttpd with same port at same time. |
151 http_server_ports = self.LaunchTestHttpServer( | 151 http_server_ports = self.LaunchTestHttpServer( |
152 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) | 152 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) |
153 if self.ports_to_forward: | 153 if self.ports_to_forward: |
154 self.StartForwarder([(port, port) for port in self.ports_to_forward]) | 154 self.ForwardPorts([(port, port) for port in self.ports_to_forward]) |
155 self.flags.AddFlags(['--enable-test-intents']) | 155 self.flags.AddFlags(['--enable-test-intents']) |
156 | 156 |
157 def TearDown(self): | 157 def TearDown(self): |
158 """Cleans up the test harness and saves outstanding data from test run.""" | 158 """Cleans up the test harness and saves outstanding data from test run.""" |
| 159 if self.ports_to_forward: |
| 160 self._UnmapPorts([(port, port) for port in self.ports_to_forward]) |
159 super(TestRunner, self).TearDown() | 161 super(TestRunner, self).TearDown() |
160 | 162 |
161 def TestSetup(self, test): | 163 def TestSetup(self, test): |
162 """Sets up the test harness for running a particular test. | 164 """Sets up the test harness for running a particular test. |
163 | 165 |
164 Args: | 166 Args: |
165 test: The name of the test that will be run. | 167 test: The name of the test that will be run. |
166 """ | 168 """ |
167 self.SetupPerfMonitoringIfNeeded(test) | 169 self.SetupPerfMonitoringIfNeeded(test) |
168 self._SetupIndividualTestTimeoutScale(test) | 170 self._SetupIndividualTestTimeoutScale(test) |
169 self.tool.SetupEnvironment() | 171 self.tool.SetupEnvironment() |
170 | 172 |
171 # Make sure the forwarder is still running. | 173 # Make sure the forwarder is still running. |
172 self.RestartHttpServerForwarderIfNecessary() | 174 self._RestartHttpServerForwarderIfNecessary() |
173 | 175 |
174 def _IsPerfTest(self, test): | 176 def _IsPerfTest(self, test): |
175 """Determines whether a test is a performance test. | 177 """Determines whether a test is a performance test. |
176 | 178 |
177 Args: | 179 Args: |
178 test: The name of the test to be checked. | 180 test: The name of the test to be checked. |
179 | 181 |
180 Returns: | 182 Returns: |
181 Whether the test is annotated as a performance test. | 183 Whether the test is annotated as a performance test. |
182 """ | 184 """ |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 duration_ms = 0 | 351 duration_ms = 0 |
350 message = str(e) | 352 message = str(e) |
351 if not message: | 353 if not message: |
352 message = 'No information.' | 354 message = 'No information.' |
353 results.AddResult(test_result.InstrumentationTestResult( | 355 results.AddResult(test_result.InstrumentationTestResult( |
354 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, | 356 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, |
355 log=message)) | 357 log=message)) |
356 raw_result = None | 358 raw_result = None |
357 self.TestTeardown(test, raw_result) | 359 self.TestTeardown(test, raw_result) |
358 return (results, None if results.DidRunPass() else test) | 360 return (results, None if results.DidRunPass() else test) |
OLD | NEW |