Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: build/android/pylib/gtest/gtest_test_instance.py

Issue 1703863003: Created separate shards for suspicious testcases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 EXTRA_SHARD_NANO_TIMEOUT = ( 79 EXTRA_SHARD_NANO_TIMEOUT = (
80 'org.chromium.native_test.NativeTestInstrumentationTestRunner.' 80 'org.chromium.native_test.NativeTestInstrumentationTestRunner.'
81 'ShardNanoTimeout') 81 'ShardNanoTimeout')
82 _EXTRA_SHARD_SIZE_LIMIT = ( 82 _EXTRA_SHARD_SIZE_LIMIT = (
83 'org.chromium.native_test.NativeTestInstrumentationTestRunner.' 83 'org.chromium.native_test.NativeTestInstrumentationTestRunner.'
84 'ShardSizeLimit') 84 'ShardSizeLimit')
85 85
86 # TODO(jbudorick): Remove these once we're no longer parsing stdout to generate 86 # TODO(jbudorick): Remove these once we're no longer parsing stdout to generate
87 # results. 87 # results.
88 _RE_TEST_STATUS = re.compile( 88 _RE_TEST_STATUS = re.compile(
89 r'\[ +((?:RUN)|(?:FAILED)|(?:OK)) +\] ?([^ ]+)(?: \((\d+) ms\))?$') 89 r'\[ +((?:RUN)|(?:FAILED)|(?:OK)|(?:CRASHED)) +\]'
90 r' ?([^ ]+)?(?: \((\d+) ms\))?$')
90 _RE_TEST_RUN_STATUS = re.compile( 91 _RE_TEST_RUN_STATUS = re.compile(
91 r'\[ +(PASSED|RUNNER_FAILED|CRASHED) \] ?[^ ]+') 92 r'\[ +(PASSED|RUNNER_FAILED|CRASHED) \] ?[^ ]+')
92 93 # Crash detection constants.
94 _RE_TEST_ERROR = re.compile(r'FAILURES!!! Tests run: \d+,'
95 r' Failures: \d+, Errors: 1')
96 _RE_TEST_CURRENTLY_RUNNING = re.compile(r'\[ERROR:.*?\]'
97 r' Currently running: (.*)')
93 98
94 # TODO(jbudorick): Make this a class method of GtestTestInstance once 99 # TODO(jbudorick): Make this a class method of GtestTestInstance once
95 # test_package_apk and test_package_exe are gone. 100 # test_package_apk and test_package_exe are gone.
96 def ParseGTestListTests(raw_list): 101 def ParseGTestListTests(raw_list):
97 """Parses a raw test list as provided by --gtest_list_tests. 102 """Parses a raw test list as provided by --gtest_list_tests.
98 103
99 Args: 104 Args:
100 raw_list: The raw test listing with the following format: 105 raw_list: The raw test listing with the following format:
101 106
102 IPCChannelTest. 107 IPCChannelTest.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 self._app_data_file_dir = args.app_data_file_dir 204 self._app_data_file_dir = args.app_data_file_dir
200 else: 205 else:
201 self._app_data_file_dir = tempfile.mkdtemp() 206 self._app_data_file_dir = tempfile.mkdtemp()
202 logging.critical('Saving app files to %s', self._app_data_file_dir) 207 logging.critical('Saving app files to %s', self._app_data_file_dir)
203 else: 208 else:
204 self._app_data_files = None 209 self._app_data_files = None
205 self._app_data_file_dir = None 210 self._app_data_file_dir = None
206 211
207 self._test_arguments = args.test_arguments 212 self._test_arguments = args.test_arguments
208 213
214
jbudorick 2016/03/01 23:19:15 nit: remove these two blank lines
215
209 @property 216 @property
210 def activity(self): 217 def activity(self):
211 return self._apk_helper and self._apk_helper.GetActivityName() 218 return self._apk_helper and self._apk_helper.GetActivityName()
212 219
213 @property 220 @property
214 def apk(self): 221 def apk(self):
215 return self._apk_helper and self._apk_helper.path 222 return self._apk_helper and self._apk_helper.path
216 223
217 @property 224 @property
218 def apk_helper(self): 225 def apk_helper(self):
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 """Parses raw gtest output and returns a list of results. 355 """Parses raw gtest output and returns a list of results.
349 356
350 Args: 357 Args:
351 output: A list of output lines. 358 output: A list of output lines.
352 Returns: 359 Returns:
353 A list of base_test_result.BaseTestResults. 360 A list of base_test_result.BaseTestResults.
354 """ 361 """
355 log = [] 362 log = []
356 result_type = None 363 result_type = None
357 results = [] 364 results = []
365 test_name = None
358 for l in output: 366 for l in output:
359 logging.info(l) 367 logging.info(l)
360 matcher = _RE_TEST_STATUS.match(l) 368 matcher = _RE_TEST_STATUS.match(l)
361 if matcher: 369 if matcher:
370 # Be aware that test name and status might not appear on same line.
371 test_name = matcher.group(2) if matcher.group(2) else test_name
372 duration = int(matcher.group(3)) if matcher.group(3) else 0
362 if matcher.group(1) == 'RUN': 373 if matcher.group(1) == 'RUN':
363 log = [] 374 log = []
364 elif matcher.group(1) == 'OK': 375 elif matcher.group(1) == 'OK':
365 result_type = base_test_result.ResultType.PASS 376 result_type = base_test_result.ResultType.PASS
366 elif matcher.group(1) == 'FAILED': 377 elif matcher.group(1) == 'FAILED':
367 result_type = base_test_result.ResultType.FAIL 378 result_type = base_test_result.ResultType.FAIL
379 elif matcher.group(1) == 'CRASHED':
380 result_type = base_test_result.ResultType.CRASH
381
382 # Needs another matcher here to match crashess, like those of DCHECK.
jbudorick 2016/03/01 23:19:15 nit: s/crashess/crashes/
383 matcher = _RE_TEST_CURRENTLY_RUNNING.match(l)
384 if matcher:
385 test_name = matcher.group(1)
386 result_type = base_test_result.ResultType.CRASH
387 duration = 0 # Don't know.
368 388
369 if log is not None: 389 if log is not None:
370 log.append(l) 390 log.append(l)
371 391
372 if result_type: 392 if result_type:
373 test_name = matcher.group(2)
374 duration = int(matcher.group(3)) if matcher.group(3) else 0
375 results.append(base_test_result.BaseTestResult( 393 results.append(base_test_result.BaseTestResult(
376 test_name, result_type, duration, 394 test_name, result_type, duration,
377 log=('\n'.join(log) if log else ''))) 395 log=('\n'.join(log) if log else '')))
378 log = None 396 log = None
379 result_type = None 397 result_type = None
380 398
381 return results 399 return results
382 400
383 #override 401 #override
384 def TearDown(self): 402 def TearDown(self):
385 """Clear the mappings created by SetUp.""" 403 """Clear the mappings created by SetUp."""
386 if self._isolate_delegate: 404 if self._isolate_delegate:
387 self._isolate_delegate.Clear() 405 self._isolate_delegate.Clear()
388 406
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698