| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 def _IsFreTest(self, test): | 202 def _IsFreTest(self, test): |
| 203 """Determines whether a test is a first run experience test. | 203 """Determines whether a test is a first run experience test. |
| 204 | 204 |
| 205 Args: | 205 Args: |
| 206 test: The name of the test to be checked. | 206 test: The name of the test to be checked. |
| 207 | 207 |
| 208 Returns: | 208 Returns: |
| 209 Whether the feature being tested is FirstRunExperience. | 209 Whether the feature being tested is FirstRunExperience. |
| 210 """ | 210 """ |
| 211 annotations = self.test_pkg.GetTestAnnotations(test) | 211 annotations = self.test_pkg.GetTestAnnotations(test) |
| 212 return ('FirstRunExperience' == annotations.get('Feature', None)) | 212 return 'FirstRunExperience' == annotations.get('Feature', None) |
| 213 | 213 |
| 214 def _IsPerfTest(self, test): | 214 def _IsPerfTest(self, test): |
| 215 """Determines whether a test is a performance test. | 215 """Determines whether a test is a performance test. |
| 216 | 216 |
| 217 Args: | 217 Args: |
| 218 test: The name of the test to be checked. | 218 test: The name of the test to be checked. |
| 219 | 219 |
| 220 Returns: | 220 Returns: |
| 221 Whether the test is annotated as a performance test. | 221 Whether the test is annotated as a performance test. |
| 222 """ | 222 """ |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 test: The name of the test that was just run. | 269 test: The name of the test that was just run. |
| 270 Raises: | 270 Raises: |
| 271 Exception: if there's anything wrong with the perf data. | 271 Exception: if there's anything wrong with the perf data. |
| 272 """ | 272 """ |
| 273 if not self._IsPerfTest(test): | 273 if not self._IsPerfTest(test): |
| 274 return | 274 return |
| 275 raw_test_name = test.split('#')[1] | 275 raw_test_name = test.split('#')[1] |
| 276 | 276 |
| 277 # Wait and grab annotation data so we can figure out which traces to parse | 277 # Wait and grab annotation data so we can figure out which traces to parse |
| 278 regex = self.device.old_interface.WaitForLogMatch( | 278 regex = self.device.old_interface.WaitForLogMatch( |
| 279 re.compile('\*\*PERFANNOTATION\(' + raw_test_name + '\)\:(.*)'), None) | 279 re.compile(r'\*\*PERFANNOTATION\(' + raw_test_name + r'\)\:(.*)'), |
| 280 None) |
| 280 | 281 |
| 281 # If the test is set to run on a specific device type only (IE: only | 282 # If the test is set to run on a specific device type only (IE: only |
| 282 # tablet or phone) and it is being run on the wrong device, the test | 283 # tablet or phone) and it is being run on the wrong device, the test |
| 283 # just quits and does not do anything. The java test harness will still | 284 # just quits and does not do anything. The java test harness will still |
| 284 # print the appropriate annotation for us, but will add --NORUN-- for | 285 # print the appropriate annotation for us, but will add --NORUN-- for |
| 285 # us so we know to ignore the results. | 286 # us so we know to ignore the results. |
| 286 # The --NORUN-- tag is managed by MainActivityTestBase.java | 287 # The --NORUN-- tag is managed by MainActivityTestBase.java |
| 287 if regex.group(1) != '--NORUN--': | 288 if regex.group(1) != '--NORUN--': |
| 288 | 289 |
| 289 # Obtain the relevant perf data. The data is dumped to a | 290 # Obtain the relevant perf data. The data is dumped to a |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 except device_errors.CommandTimeoutError as e: | 522 except device_errors.CommandTimeoutError as e: |
| 522 results.AddResult(test_result.InstrumentationTestResult( | 523 results.AddResult(test_result.InstrumentationTestResult( |
| 523 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, | 524 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, |
| 524 log=str(e) or 'No information')) | 525 log=str(e) or 'No information')) |
| 525 except device_errors.DeviceUnreachableError as e: | 526 except device_errors.DeviceUnreachableError as e: |
| 526 results.AddResult(test_result.InstrumentationTestResult( | 527 results.AddResult(test_result.InstrumentationTestResult( |
| 527 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, | 528 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, |
| 528 log=str(e) or 'No information')) | 529 log=str(e) or 'No information')) |
| 529 self.TestTeardown(test, results) | 530 self.TestTeardown(test, results) |
| 530 return (results, None if results.DidRunPass() else test) | 531 return (results, None if results.DidRunPass() else test) |
| OLD | NEW |