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 not json_string: | 238 if json_string: |
239 raise Exception('Perf file is empty') | 239 json_string = '\n'.join(json_string) |
| 240 else: |
| 241 raise Exception('Perf file does not exist or is empty') |
240 | 242 |
241 if self.options.save_perf_json: | 243 if self.options.save_perf_json: |
242 json_local_file = '/tmp/chromium-android-perf-json-' + raw_test_name | 244 json_local_file = '/tmp/chromium-android-perf-json-' + raw_test_name |
243 with open(json_local_file, 'w') as f: | 245 with open(json_local_file, 'w') as f: |
244 f.write(json_string) | 246 f.write(json_string) |
245 logging.info('Saving Perf UI JSON from test ' + | 247 logging.info('Saving Perf UI JSON from test ' + |
246 test + ' to ' + json_local_file) | 248 test + ' to ' + json_local_file) |
247 | 249 |
248 raw_perf_data = regex.group(1).split(';') | 250 raw_perf_data = regex.group(1).split(';') |
249 | 251 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 except device_errors.CommandTimeoutError as e: | 464 except device_errors.CommandTimeoutError as e: |
463 results.AddResult(test_result.InstrumentationTestResult( | 465 results.AddResult(test_result.InstrumentationTestResult( |
464 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, | 466 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, |
465 log=str(e) or 'No information')) | 467 log=str(e) or 'No information')) |
466 except device_errors.DeviceUnreachableError as e: | 468 except device_errors.DeviceUnreachableError as e: |
467 results.AddResult(test_result.InstrumentationTestResult( | 469 results.AddResult(test_result.InstrumentationTestResult( |
468 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, | 470 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, |
469 log=str(e) or 'No information')) | 471 log=str(e) or 'No information')) |
470 self.TestTeardown(test, results) | 472 self.TestTeardown(test, results) |
471 return (results, None if results.DidRunPass() else test) | 473 return (results, None if results.DidRunPass() else test) |
OLD | NEW |