| 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 sys | 10 import sys |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 Depending on the options of this TestRunner this might handle performance | 189 Depending on the options of this TestRunner this might handle performance |
| 190 tracking. This method will only be called if the test passed. | 190 tracking. This method will only be called if the test passed. |
| 191 | 191 |
| 192 Args: | 192 Args: |
| 193 test: The name of the test that was just run. | 193 test: The name of the test that was just run. |
| 194 result: result for this test. | 194 result: result for this test. |
| 195 """ | 195 """ |
| 196 | 196 |
| 197 self.tool.CleanUpEnvironment() | 197 self.tool.CleanUpEnvironment() |
| 198 | 198 |
| 199 # The logic below relies on the test passing. | 199 if not result: |
| 200 if not result or not result.DidRunPass(): | |
| 201 return | 200 return |
| 201 if result.DidRunPass(): |
| 202 self.TearDownPerfMonitoring(test) |
| 202 | 203 |
| 203 self.TearDownPerfMonitoring(test) | 204 if self.flags and self._IsFreTest(test): |
| 205 self.flags.AddFlags(['--disable-fre']) |
| 204 | 206 |
| 205 if self.flags and self._IsFreTest(test): | 207 if self.coverage_dir: |
| 206 self.flags.AddFlags(['--disable-fre']) | 208 self.device.PullFile( |
| 207 | 209 self.coverage_device_file, self.coverage_host_file) |
| 208 if self.coverage_dir: | 210 self.device.RunShellCommand( |
| 209 self.device.PullFile( | 211 'rm -f %s' % self.coverage_device_file) |
| 210 self.coverage_device_file, self.coverage_host_file) | 212 elif self.package_info: |
| 211 self.device.RunShellCommand( | 213 self.device.ClearApplicationState(self.package_info.package) |
| 212 'rm -f %s' % self.coverage_device_file) | |
| 213 | 214 |
| 214 def TearDownPerfMonitoring(self, test): | 215 def TearDownPerfMonitoring(self, test): |
| 215 """Cleans up performance monitoring if the specified test required it. | 216 """Cleans up performance monitoring if the specified test required it. |
| 216 | 217 |
| 217 Args: | 218 Args: |
| 218 test: The name of the test that was just run. | 219 test: The name of the test that was just run. |
| 219 Raises: | 220 Raises: |
| 220 Exception: if there's anything wrong with the perf data. | 221 Exception: if there's anything wrong with the perf data. |
| 221 """ | 222 """ |
| 222 if not self._IsPerfTest(test): | 223 if not self._IsPerfTest(test): |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 log=str(e) or 'No information')) | 374 log=str(e) or 'No information')) |
| 374 if self.package_info: | 375 if self.package_info: |
| 375 self.device.ForceStop(self.package_info.package) | 376 self.device.ForceStop(self.package_info.package) |
| 376 self.device.ForceStop(self.package_info.test_package) | 377 self.device.ForceStop(self.package_info.test_package) |
| 377 except device_errors.DeviceUnreachableError as e: | 378 except device_errors.DeviceUnreachableError as e: |
| 378 results.AddResult(test_result.InstrumentationTestResult( | 379 results.AddResult(test_result.InstrumentationTestResult( |
| 379 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, | 380 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, |
| 380 log=str(e) or 'No information')) | 381 log=str(e) or 'No information')) |
| 381 self.TestTeardown(test, results) | 382 self.TestTeardown(test, results) |
| 382 return (results, None if results.DidRunPass() else test) | 383 return (results, None if results.DidRunPass() else test) |
| OLD | NEW |