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