| 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 | 5 | 
| 6 import logging | 6 import logging | 
| 7 import re | 7 import re | 
| 8 import os | 8 import os | 
| 9 | 9 | 
| 10 import constants | 10 import constants | 
| 11 from perf_tests_helper import PrintPerfResult | 11 from perf_tests_helper import PrintPerfResult | 
| 12 from pylib import pexpect | 12 from pylib import pexpect | 
| 13 from test_result import BaseTestResult, TestResults | 13 from test_result import BaseTestResult, TestResults | 
| 14 | 14 | 
|  | 15 from android_commands import errors | 
| 15 | 16 | 
| 16 # TODO(bulach): TestPackage, TestPackageExecutable and | 17 # TODO(bulach): TestPackage, TestPackageExecutable and | 
| 17 # TestPackageApk are a work in progress related to making the native tests | 18 # TestPackageApk are a work in progress related to making the native tests | 
| 18 # run as a NDK-app from an APK rather than a stand-alone executable. | 19 # run as a NDK-app from an APK rather than a stand-alone executable. | 
| 19 class TestPackage(object): | 20 class TestPackage(object): | 
| 20   """A helper base class for both APK and stand-alone executables. | 21   """A helper base class for both APK and stand-alone executables. | 
| 21 | 22 | 
| 22   Args: | 23   Args: | 
| 23     adb: ADB interface the tests are using. | 24     adb: ADB interface the tests are using. | 
| 24     device: Device to run the tests. | 25     device: Device to run the tests. | 
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 172             ok_tests += [BaseTestResult(full_test_name, p.before)] | 173             ok_tests += [BaseTestResult(full_test_name, p.before)] | 
| 173             continue | 174             continue | 
| 174         if found == 2: # re_crash | 175         if found == 2: # re_crash | 
| 175           crashed_tests += [BaseTestResult(full_test_name, p.before)] | 176           crashed_tests += [BaseTestResult(full_test_name, p.before)] | 
| 176           overall_fail = True | 177           overall_fail = True | 
| 177           break | 178           break | 
| 178         # The test failed. | 179         # The test failed. | 
| 179         failed_tests += [BaseTestResult(full_test_name, p.before)] | 180         failed_tests += [BaseTestResult(full_test_name, p.before)] | 
| 180     except pexpect.EOF: | 181     except pexpect.EOF: | 
| 181       logging.error('Test terminated - EOF') | 182       logging.error('Test terminated - EOF') | 
|  | 183       raise errors.DeviceUnresponsiveError('Device may be offline') | 
| 182     except pexpect.TIMEOUT: | 184     except pexpect.TIMEOUT: | 
| 183       logging.error('Test terminated after %d second timeout.', | 185       logging.error('Test terminated after %d second timeout.', | 
| 184                     self.timeout) | 186                     self.timeout) | 
| 185       timed_out = True | 187       timed_out = True | 
| 186     finally: | 188     finally: | 
| 187       p.close() | 189       p.close() | 
| 188     if not self.rebaseline: | 190     if not self.rebaseline: | 
| 189       ok_tests += self._EndGetIOStats(io_stats_before) | 191       ok_tests += self._EndGetIOStats(io_stats_before) | 
| 190       ret_code = self._GetGTestReturnCode() | 192       ret_code = self._GetGTestReturnCode() | 
| 191       if ret_code: | 193       if ret_code: | 
| 192         failed_tests += [BaseTestResult('gtest exit code: %d' % ret_code, | 194         failed_tests += [BaseTestResult('gtest exit code: %d' % ret_code, | 
| 193                                         'pexpect.before: %s' | 195                                         'pexpect.before: %s' | 
| 194                                         '\npexpect.after: %s' | 196                                         '\npexpect.after: %s' | 
| 195                                         % (p.before, | 197                                         % (p.before, | 
| 196                                            p.after))] | 198                                            p.after))] | 
| 197     # Create TestResults and return | 199     # Create TestResults and return | 
| 198     return TestResults.FromRun(ok=ok_tests, failed=failed_tests, | 200     return TestResults.FromRun(ok=ok_tests, failed=failed_tests, | 
| 199                                crashed=crashed_tests, timed_out=timed_out, | 201                                crashed=crashed_tests, timed_out=timed_out, | 
| 200                                overall_fail=overall_fail) | 202                                overall_fail=overall_fail) | 
| OLD | NEW | 
|---|