Chromium Code Reviews| 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 import pexpect | 9 import pexpect |
| 10 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 ret += [current + test_name] | 122 ret += [current + test_name] |
| 123 return ret | 123 return ret |
| 124 | 124 |
| 125 def _WatchTestOutput(self, p): | 125 def _WatchTestOutput(self, p): |
| 126 """Watches the test output. | 126 """Watches the test output. |
| 127 Args: | 127 Args: |
| 128 p: the process generating output as created by pexpect.spawn. | 128 p: the process generating output as created by pexpect.spawn. |
| 129 """ | 129 """ |
| 130 ok_tests = [] | 130 ok_tests = [] |
| 131 failed_tests = [] | 131 failed_tests = [] |
| 132 crashed_tests = [] | |
| 132 timed_out = False | 133 timed_out = False |
| 133 overall_fail = False | 134 overall_fail = False |
| 134 re_run = re.compile('\[ RUN \] ?(.*)\r\n') | 135 re_run = re.compile('\[ RUN \] ?(.*)\r\n') |
| 135 # APK tests rely on the END tag. | 136 # APK tests rely on the END tag. |
| 136 re_end = re.compile('\[ END \] ?(.*)\r\n') | 137 re_end = re.compile('\[ END \] ?(.*)\r\n') |
| 138 re_crash = re.compile('\[ CRASHED \](.*)\r\n') | |
|
John Grabowski
2012/05/07 19:22:15
It seems illogical a test will announce it crashed
nilesh
2012/05/08 01:38:10
I am not sure I understand what you want here. Can
John Grabowski
2012/05/08 12:54:10
Sure.
At first glance it does not make sense that
nilesh
2012/05/08 22:18:43
Done.
| |
| 137 re_fail = re.compile('\[ FAILED \] ?(.*)\r\n') | 139 re_fail = re.compile('\[ FAILED \] ?(.*)\r\n') |
| 138 re_runner_fail = re.compile('\[ RUNNER_FAILED \] ?(.*)\r\n') | 140 re_runner_fail = re.compile('\[ RUNNER_FAILED \] ?(.*)\r\n') |
| 139 re_ok = re.compile('\[ OK \] ?(.*)\r\n') | 141 re_ok = re.compile('\[ OK \] ?(.*)\r\n') |
| 140 (io_stats_before, ready_to_continue) = self._BeginGetIOStats() | 142 (io_stats_before, ready_to_continue) = self._BeginGetIOStats() |
| 141 while ready_to_continue: | 143 while ready_to_continue: |
| 142 found = p.expect([re_run, pexpect.EOF, re_end, re_runner_fail], | 144 found = p.expect([re_run, pexpect.EOF, re_end, re_runner_fail], |
| 143 timeout=self.timeout) | 145 timeout=self.timeout) |
| 144 if found == 1: # matched pexpect.EOF | 146 if found == 1: # matched pexpect.EOF |
| 145 break | 147 break |
| 146 if found == 2: # matched END. | 148 if found == 2: # matched END. |
| 147 break | 149 break |
| 148 if found == 3: # RUNNER_FAILED | 150 if found == 3: # RUNNER_FAILED |
| 149 logging.error('RUNNER_FAILED') | 151 logging.error('RUNNER_FAILED') |
| 150 overall_fail = True | 152 overall_fail = True |
| 151 break | 153 break |
| 152 if self.dump_debug_info: | 154 if self.dump_debug_info: |
| 153 self.dump_debug_info.TakeScreenshot('_Test_Start_Run_') | 155 self.dump_debug_info.TakeScreenshot('_Test_Start_Run_') |
| 154 full_test_name = p.match.group(1) | 156 full_test_name = p.match.group(1) |
| 155 found = p.expect([re_ok, re_fail, pexpect.EOF, pexpect.TIMEOUT], | 157 found = p.expect([re_ok, re_fail, re_crash, pexpect.EOF, pexpect.TIMEOUT], |
| 156 timeout=self.timeout) | 158 timeout=self.timeout) |
| 157 if found == 0: # re_ok | 159 if found == 0: # re_ok |
| 158 ok_tests += [BaseTestResult(full_test_name.replace('\r', ''), | 160 ok_tests += [BaseTestResult(full_test_name.replace('\r', ''), |
| 159 p.before)] | 161 p.before)] |
| 160 continue | 162 continue |
| 163 if found == 2: # re_crash | |
| 164 crashed_tests += [BaseTestResult(full_test_name.replace('\r', ''), | |
| 165 p.before)] | |
| 166 overall_fail = True | |
| 167 break | |
| 168 # The test failed. | |
| 161 failed_tests += [BaseTestResult(full_test_name.replace('\r', ''), | 169 failed_tests += [BaseTestResult(full_test_name.replace('\r', ''), |
| 162 p.before)] | 170 p.before)] |
| 163 if found >= 2: | 171 if found >= 3: |
| 164 # The test crashed / bailed out (i.e., didn't print OK or FAIL). | 172 # The test bailed out (i.e., didn't print OK or FAIL). |
| 165 if found == 3: # pexpect.TIMEOUT | 173 if found == 3: # pexpect.TIMEOUT |
| 166 logging.error('Test terminated after %d second timeout.', | 174 logging.error('Test terminated after %d second timeout.', |
| 167 self.timeout) | 175 self.timeout) |
| 168 timed_out = True | 176 timed_out = True |
| 169 break | 177 break |
| 170 p.close() | 178 p.close() |
| 171 if not self.rebaseline and ready_to_continue: | 179 if not self.rebaseline and ready_to_continue: |
| 172 ok_tests += self._EndGetIOStats(io_stats_before) | 180 ok_tests += self._EndGetIOStats(io_stats_before) |
| 173 ret_code = self._GetGTestReturnCode() | 181 ret_code = self._GetGTestReturnCode() |
| 174 if ret_code: | 182 if ret_code: |
| 175 failed_tests += [BaseTestResult('gtest exit code: %d' % ret_code, | 183 failed_tests += [BaseTestResult('gtest exit code: %d' % ret_code, |
| 176 'pexpect.before: %s' | 184 'pexpect.before: %s' |
| 177 '\npexpect.after: %s' | 185 '\npexpect.after: %s' |
| 178 % (p.before, | 186 % (p.before, |
| 179 p.after))] | 187 p.after))] |
| 180 return TestResults.FromOkAndFailed(ok_tests, failed_tests, | 188 # Create TestResults and return |
| 181 timed_out, overall_fail) | 189 return TestResults.FromOkFailedAndCrashed(ok_tests, failed_tests, |
| 190 crashed_tests, timed_out, | |
| 191 overall_fail) | |
| OLD | NEW |