OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import logging | 5 import logging |
6 import os | 6 import os |
7 import re | 7 import re |
8 import tempfile | 8 import tempfile |
9 | 9 |
10 from devil.android import apk_helper | 10 from devil.android import apk_helper |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 'ShardNanoTimeout') | 83 'ShardNanoTimeout') |
84 _EXTRA_SHARD_SIZE_LIMIT = ( | 84 _EXTRA_SHARD_SIZE_LIMIT = ( |
85 'org.chromium.native_test.NativeTestInstrumentationTestRunner.' | 85 'org.chromium.native_test.NativeTestInstrumentationTestRunner.' |
86 'ShardSizeLimit') | 86 'ShardSizeLimit') |
87 | 87 |
88 # TODO(jbudorick): Remove these once we're no longer parsing stdout to generate | 88 # TODO(jbudorick): Remove these once we're no longer parsing stdout to generate |
89 # results. | 89 # results. |
90 _RE_TEST_STATUS = re.compile( | 90 _RE_TEST_STATUS = re.compile( |
91 r'\[ +((?:RUN)|(?:FAILED)|(?:OK)|(?:CRASHED)) +\]' | 91 r'\[ +((?:RUN)|(?:FAILED)|(?:OK)|(?:CRASHED)) +\]' |
92 r' ?([^ ]+)?(?: \((\d+) ms\))?$') | 92 r' ?([^ ]+)?(?: \((\d+) ms\))?$') |
93 _RE_TEST_RUN_STATUS = re.compile( | |
94 r'\[ +(PASSED|RUNNER_FAILED|CRASHED) \] ?[^ ]+') | |
95 # Crash detection constants. | 93 # Crash detection constants. |
96 _RE_TEST_ERROR = re.compile(r'FAILURES!!! Tests run: \d+,' | 94 _RE_TEST_ERROR = re.compile(r'FAILURES!!! Tests run: \d+,' |
97 r' Failures: \d+, Errors: 1') | 95 r' Failures: \d+, Errors: 1') |
98 _RE_TEST_CURRENTLY_RUNNING = re.compile(r'\[ERROR:.*?\]' | 96 _RE_TEST_CURRENTLY_RUNNING = re.compile(r'\[ERROR:.*?\]' |
99 r' Currently running: (.*)') | 97 r' Currently running: (.*)') |
100 | 98 |
101 def ParseGTestListTests(raw_list): | 99 def ParseGTestListTests(raw_list): |
102 """Parses a raw test list as provided by --gtest_list_tests. | 100 """Parses a raw test list as provided by --gtest_list_tests. |
103 | 101 |
104 Args: | 102 Args: |
(...skipping 27 matching lines...) Expand all Loading... |
132 | 130 |
133 | 131 |
134 def ParseGTestOutput(output): | 132 def ParseGTestOutput(output): |
135 """Parses raw gtest output and returns a list of results. | 133 """Parses raw gtest output and returns a list of results. |
136 | 134 |
137 Args: | 135 Args: |
138 output: A list of output lines. | 136 output: A list of output lines. |
139 Returns: | 137 Returns: |
140 A list of base_test_result.BaseTestResults. | 138 A list of base_test_result.BaseTestResults. |
141 """ | 139 """ |
| 140 duration = 0 |
| 141 fallback_result_type = None |
142 log = [] | 142 log = [] |
143 result_type = None | 143 result_type = None |
144 results = [] | 144 results = [] |
145 test_name = None | 145 test_name = None |
146 | 146 |
147 def handle_possibly_unknown_test(): | 147 def handle_possibly_unknown_test(): |
148 if test_name is not None: | 148 if test_name is not None: |
149 results.append(base_test_result.BaseTestResult( | 149 results.append(base_test_result.BaseTestResult( |
150 test_name, base_test_result.ResultType.UNKNOWN, 0, | 150 test_name, |
151 log=('\n'.join(log) if log else ''))) | 151 fallback_result_type or base_test_result.ResultType.UNKNOWN, |
| 152 duration, log=('\n'.join(log) if log else ''))) |
152 | 153 |
153 for l in output: | 154 for l in output: |
154 logging.info(l) | 155 logging.info(l) |
155 matcher = _RE_TEST_STATUS.match(l) | 156 matcher = _RE_TEST_STATUS.match(l) |
156 if matcher: | 157 if matcher: |
157 if matcher.group(1) == 'RUN': | 158 if matcher.group(1) == 'RUN': |
158 handle_possibly_unknown_test() | 159 handle_possibly_unknown_test() |
| 160 duration = 0 |
| 161 fallback_result_type = None |
159 log = [] | 162 log = [] |
| 163 result_type = None |
160 elif matcher.group(1) == 'OK': | 164 elif matcher.group(1) == 'OK': |
161 result_type = base_test_result.ResultType.PASS | 165 result_type = base_test_result.ResultType.PASS |
162 elif matcher.group(1) == 'FAILED': | 166 elif matcher.group(1) == 'FAILED': |
163 result_type = base_test_result.ResultType.FAIL | 167 result_type = base_test_result.ResultType.FAIL |
164 elif matcher.group(1) == 'CRASHED': | 168 elif matcher.group(1) == 'CRASHED': |
165 result_type = base_test_result.ResultType.CRASH | 169 fallback_result_type = base_test_result.ResultType.CRASH |
166 # Be aware that test name and status might not appear on same line. | 170 # Be aware that test name and status might not appear on same line. |
167 test_name = matcher.group(2) if matcher.group(2) else test_name | 171 test_name = matcher.group(2) if matcher.group(2) else test_name |
168 duration = int(matcher.group(3)) if matcher.group(3) else 0 | 172 duration = int(matcher.group(3)) if matcher.group(3) else 0 |
169 | 173 |
170 else: | 174 else: |
171 # Needs another matcher here to match crashes, like those of DCHECK. | 175 # Needs another matcher here to match crashes, like those of DCHECK. |
172 matcher = _RE_TEST_CURRENTLY_RUNNING.match(l) | 176 matcher = _RE_TEST_CURRENTLY_RUNNING.match(l) |
173 if matcher: | 177 if matcher: |
174 test_name = matcher.group(1) | 178 test_name = matcher.group(1) |
175 result_type = base_test_result.ResultType.CRASH | 179 result_type = base_test_result.ResultType.CRASH |
176 duration = 0 # Don't know. | 180 duration = 0 # Don't know. |
177 | 181 |
178 if log is not None: | 182 if log is not None: |
179 log.append(l) | 183 log.append(l) |
180 | 184 |
181 if result_type and test_name: | 185 if result_type and test_name: |
182 results.append(base_test_result.BaseTestResult( | 186 results.append(base_test_result.BaseTestResult( |
183 test_name, result_type, duration, | 187 test_name, result_type, duration, |
184 log=('\n'.join(log) if log else ''))) | 188 log=('\n'.join(log) if log else ''))) |
185 log = None | |
186 result_type = None | |
187 test_name = None | 189 test_name = None |
188 | 190 |
189 handle_possibly_unknown_test() | 191 handle_possibly_unknown_test() |
190 | 192 |
191 return results | 193 return results |
192 | 194 |
193 | 195 |
194 class GtestTestInstance(test_instance.TestInstance): | 196 class GtestTestInstance(test_instance.TestInstance): |
195 | 197 |
196 def __init__(self, args, isolate_delegate, error_func): | 198 def __init__(self, args, isolate_delegate, error_func): |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 if l and not l.startswith('#')] | 410 if l and not l.startswith('#')] |
409 | 411 |
410 return '*-%s' % ':'.join(disabled_filter_items) | 412 return '*-%s' % ':'.join(disabled_filter_items) |
411 | 413 |
412 #override | 414 #override |
413 def TearDown(self): | 415 def TearDown(self): |
414 """Clear the mappings created by SetUp.""" | 416 """Clear the mappings created by SetUp.""" |
415 if self._isolate_delegate: | 417 if self._isolate_delegate: |
416 self._isolate_delegate.Clear() | 418 self._isolate_delegate.Clear() |
417 | 419 |
OLD | NEW |