| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 # us so we know to ignore the results. | 228 # us so we know to ignore the results. |
| 229 # The --NORUN-- tag is managed by MainActivityTestBase.java | 229 # The --NORUN-- tag is managed by MainActivityTestBase.java |
| 230 if regex.group(1) != '--NORUN--': | 230 if regex.group(1) != '--NORUN--': |
| 231 | 231 |
| 232 # Obtain the relevant perf data. The data is dumped to a | 232 # Obtain the relevant perf data. The data is dumped to a |
| 233 # JSON formatted file. | 233 # JSON formatted file. |
| 234 json_string = self.device.ReadFile( | 234 json_string = self.device.ReadFile( |
| 235 '/data/data/com.google.android.apps.chrome/files/PerfTestData.txt', | 235 '/data/data/com.google.android.apps.chrome/files/PerfTestData.txt', |
| 236 as_root=True) | 236 as_root=True) |
| 237 | 237 |
| 238 if json_string: | 238 if not json_string: |
| 239 json_string = '\n'.join(json_string) | 239 raise Exception('Perf file is empty') |
| 240 else: | |
| 241 raise Exception('Perf file does not exist or is empty') | |
| 242 | 240 |
| 243 if self.options.save_perf_json: | 241 if self.options.save_perf_json: |
| 244 json_local_file = '/tmp/chromium-android-perf-json-' + raw_test_name | 242 json_local_file = '/tmp/chromium-android-perf-json-' + raw_test_name |
| 245 with open(json_local_file, 'w') as f: | 243 with open(json_local_file, 'w') as f: |
| 246 f.write(json_string) | 244 f.write(json_string) |
| 247 logging.info('Saving Perf UI JSON from test ' + | 245 logging.info('Saving Perf UI JSON from test ' + |
| 248 test + ' to ' + json_local_file) | 246 test + ' to ' + json_local_file) |
| 249 | 247 |
| 250 raw_perf_data = regex.group(1).split(';') | 248 raw_perf_data = regex.group(1).split(';') |
| 251 | 249 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 except device_errors.CommandTimeoutError as e: | 462 except device_errors.CommandTimeoutError as e: |
| 465 results.AddResult(test_result.InstrumentationTestResult( | 463 results.AddResult(test_result.InstrumentationTestResult( |
| 466 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, | 464 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, |
| 467 log=str(e) or 'No information')) | 465 log=str(e) or 'No information')) |
| 468 except device_errors.DeviceUnreachableError as e: | 466 except device_errors.DeviceUnreachableError as e: |
| 469 results.AddResult(test_result.InstrumentationTestResult( | 467 results.AddResult(test_result.InstrumentationTestResult( |
| 470 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, | 468 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, |
| 471 log=str(e) or 'No information')) | 469 log=str(e) or 'No information')) |
| 472 self.TestTeardown(test, results) | 470 self.TestTeardown(test, results) |
| 473 return (results, None if results.DidRunPass() else test) | 471 return (results, None if results.DidRunPass() else test) |
| OLD | NEW |