| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 # Wait and grab annotation data so we can figure out which traces to parse | 222 # Wait and grab annotation data so we can figure out which traces to parse |
| 223 regex = self._logcat_monitor.WaitFor( | 223 regex = self._logcat_monitor.WaitFor( |
| 224 re.compile(r'\*\*PERFANNOTATION\(' + raw_test_name + r'\)\:(.*)')) | 224 re.compile(r'\*\*PERFANNOTATION\(' + raw_test_name + r'\)\:(.*)')) |
| 225 | 225 |
| 226 # If the test is set to run on a specific device type only (IE: only | 226 # If the test is set to run on a specific device type only (IE: only |
| 227 # tablet or phone) and it is being run on the wrong device, the test | 227 # tablet or phone) and it is being run on the wrong device, the test |
| 228 # just quits and does not do anything. The java test harness will still | 228 # just quits and does not do anything. The java test harness will still |
| 229 # print the appropriate annotation for us, but will add --NORUN-- for | 229 # print the appropriate annotation for us, but will add --NORUN-- for |
| 230 # us so we know to ignore the results. | 230 # us so we know to ignore the results. |
| 231 # The --NORUN-- tag is managed by MainActivityTestBase.java | 231 # The --NORUN-- tag is managed by ChromeTabbedActivityTestBase.java |
| 232 if regex.group(1) != '--NORUN--': | 232 if regex.group(1) != '--NORUN--': |
| 233 | 233 |
| 234 # Obtain the relevant perf data. The data is dumped to a | 234 # Obtain the relevant perf data. The data is dumped to a |
| 235 # JSON formatted file. | 235 # JSON formatted file. |
| 236 json_string = self.device.ReadFile( | 236 json_string = self.device.ReadFile( |
| 237 '/data/data/com.google.android.apps.chrome/files/PerfTestData.txt', | 237 '/data/data/com.google.android.apps.chrome/files/PerfTestData.txt', |
| 238 as_root=True) | 238 as_root=True) |
| 239 | 239 |
| 240 if not json_string: | 240 if not json_string: |
| 241 raise Exception('Perf file is empty') | 241 raise Exception('Perf file is empty') |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 except device_errors.CommandTimeoutError as e: | 362 except device_errors.CommandTimeoutError as e: |
| 363 results.AddResult(test_result.InstrumentationTestResult( | 363 results.AddResult(test_result.InstrumentationTestResult( |
| 364 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, | 364 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, |
| 365 log=str(e) or 'No information')) | 365 log=str(e) or 'No information')) |
| 366 except device_errors.DeviceUnreachableError as e: | 366 except device_errors.DeviceUnreachableError as e: |
| 367 results.AddResult(test_result.InstrumentationTestResult( | 367 results.AddResult(test_result.InstrumentationTestResult( |
| 368 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, | 368 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, |
| 369 log=str(e) or 'No information')) | 369 log=str(e) or 'No information')) |
| 370 self.TestTeardown(test, results) | 370 self.TestTeardown(test, results) |
| 371 return (results, None if results.DidRunPass() else test) | 371 return (results, None if results.DidRunPass() else test) |
| OLD | NEW |