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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 MainActivityTestBase.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 json_string: | 240 if not json_string: |
241 json_string = '\n'.join(json_string) | 241 raise Exception('Perf file is empty') |
242 else: | |
243 raise Exception('Perf file does not exist or is empty') | |
244 | 242 |
245 if self.options.save_perf_json: | 243 if self.options.save_perf_json: |
246 json_local_file = '/tmp/chromium-android-perf-json-' + raw_test_name | 244 json_local_file = '/tmp/chromium-android-perf-json-' + raw_test_name |
247 with open(json_local_file, 'w') as f: | 245 with open(json_local_file, 'w') as f: |
248 f.write(json_string) | 246 f.write(json_string) |
249 logging.info('Saving Perf UI JSON from test ' + | 247 logging.info('Saving Perf UI JSON from test ' + |
250 test + ' to ' + json_local_file) | 248 test + ' to ' + json_local_file) |
251 | 249 |
252 raw_perf_data = regex.group(1).split(';') | 250 raw_perf_data = regex.group(1).split(';') |
253 | 251 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 except device_errors.CommandTimeoutError as e: | 354 except device_errors.CommandTimeoutError as e: |
357 results.AddResult(test_result.InstrumentationTestResult( | 355 results.AddResult(test_result.InstrumentationTestResult( |
358 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, | 356 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, |
359 log=str(e) or 'No information')) | 357 log=str(e) or 'No information')) |
360 except device_errors.DeviceUnreachableError as e: | 358 except device_errors.DeviceUnreachableError as e: |
361 results.AddResult(test_result.InstrumentationTestResult( | 359 results.AddResult(test_result.InstrumentationTestResult( |
362 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, | 360 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, |
363 log=str(e) or 'No information')) | 361 log=str(e) or 'No information')) |
364 self.TestTeardown(test, results) | 362 self.TestTeardown(test, results) |
365 return (results, None if results.DidRunPass() else test) | 363 return (results, None if results.DidRunPass() else test) |
OLD | NEW |