| OLD | NEW |
| (Empty) |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from common import chromium_deps | |
| 6 from common.dependency import DependencyRoll | |
| 7 from crash import detect_regression_range | |
| 8 from crash import findit_for_fracas | |
| 9 from crash import fracas_parser | |
| 10 from crash import findit_for_crash | |
| 11 from crash.callstack import CallStack | |
| 12 from crash.component_classifier import ComponentClassifier | |
| 13 from crash.project_classifier import ProjectClassifier | |
| 14 from crash.results import MatchResult | |
| 15 from crash.stacktrace import Stacktrace | |
| 16 from crash.callstack import CallStack | |
| 17 from crash.test.crash_testcase import CrashTestCase | |
| 18 | |
| 19 | |
| 20 class FinditForFracasTest(CrashTestCase): | |
| 21 | |
| 22 def testFindCulpritForChromeCrashEmptyStacktrace(self): | |
| 23 def _MockGetChromeDependency(*_): | |
| 24 return {} | |
| 25 | |
| 26 def _MockParse(*_): | |
| 27 return Stacktrace() | |
| 28 | |
| 29 self.mock(chromium_deps, 'GetChromeDependency', _MockGetChromeDependency) | |
| 30 self.mock(fracas_parser.FracasParser, 'Parse', _MockParse) | |
| 31 | |
| 32 expected_results = {'found': False} | |
| 33 expected_tag = {'found_suspects': False, | |
| 34 'has_regression_range': False} | |
| 35 | |
| 36 results, tag = findit_for_fracas.FindCulpritForChromeCrash( | |
| 37 'signature', 'win', 'frame1\nframe2', '50.0.1234.0', | |
| 38 [{'chrome_version': '50.0.1234.0', 'cpm': 0.6}]) | |
| 39 | |
| 40 self.assertEqual(expected_results, results) | |
| 41 self.assertEqual(expected_tag, tag) | |
| 42 | |
| 43 def testFindCulpritForChromeCrash(self): | |
| 44 def _MockGetChromeDependency(*_): | |
| 45 return {} | |
| 46 | |
| 47 def _MockParse(*_): | |
| 48 stack = Stacktrace() | |
| 49 stack.append(CallStack(0)) | |
| 50 return stack | |
| 51 | |
| 52 def _MockDetectRegressionRange(historic): | |
| 53 if historic: | |
| 54 return '50.0.1233.0', '50.0.1234.0' | |
| 55 | |
| 56 return None | |
| 57 | |
| 58 def _MockGetDEPSRollsDict(*_): | |
| 59 return {'src/': DependencyRoll('src/', 'https://repo', '1', '2')} | |
| 60 | |
| 61 dummy_match_result = MatchResult(self.GetDummyChangeLog(), 'src/') | |
| 62 def _MockFindItForCrash(*args): | |
| 63 regression_deps_rolls = args[1] | |
| 64 if regression_deps_rolls: | |
| 65 return [dummy_match_result] | |
| 66 | |
| 67 return [] | |
| 68 | |
| 69 def _MockComponentClassify(*_): | |
| 70 return [] | |
| 71 | |
| 72 def _MockProjectClassify(*_): | |
| 73 return '' | |
| 74 | |
| 75 self.mock(chromium_deps, 'GetChromeDependency', _MockGetChromeDependency) | |
| 76 self.mock(fracas_parser.FracasParser, 'Parse', _MockParse) | |
| 77 self.mock(detect_regression_range, 'DetectRegressionRange', | |
| 78 _MockDetectRegressionRange) | |
| 79 self.mock(chromium_deps, 'GetDEPSRollsDict', _MockGetDEPSRollsDict) | |
| 80 self.mock(findit_for_crash, 'FindItForCrash', _MockFindItForCrash) | |
| 81 | |
| 82 self.mock(ComponentClassifier, 'Classify', _MockComponentClassify) | |
| 83 self.mock(ProjectClassifier, 'Classify', _MockProjectClassify) | |
| 84 | |
| 85 expected_results = {'found': False} | |
| 86 expected_tag = {'found_suspects': False} | |
| 87 | |
| 88 results, tag = findit_for_fracas.FindCulpritForChromeCrash( | |
| 89 'signature', 'win', 'frame1\nframe2', '50.0.1234.0', | |
| 90 [{'chrome_version': '50.0.1234.0', 'cpm': 0.6}]) | |
| 91 | |
| 92 expected_results = { | |
| 93 'found': True, | |
| 94 'suspected_project': '', | |
| 95 'suspected_components': [], | |
| 96 'suspected_cls': [dummy_match_result.ToDict()], | |
| 97 'regression_range': ('50.0.1233.0', '50.0.1234.0'), | |
| 98 } | |
| 99 expected_tag = { | |
| 100 'found_suspects': True, | |
| 101 'has_regression_range': True, | |
| 102 'solution': 'core_algorithm', | |
| 103 } | |
| 104 | |
| 105 self.assertEqual(expected_results, results) | |
| 106 self.assertEqual(expected_tag, tag) | |
| 107 | |
| 108 results, tag = findit_for_fracas.FindCulpritForChromeCrash( | |
| 109 'signature', 'win', 'frame1\nframe2', '50.0.1234.0', | |
| 110 []) | |
| 111 | |
| 112 expected_results = { | |
| 113 'found': False, | |
| 114 'suspected_project': '', | |
| 115 'suspected_components': [], | |
| 116 'suspected_cls': [], | |
| 117 'regression_range': None | |
| 118 } | |
| 119 expected_tag = { | |
| 120 'found_suspects': False, | |
| 121 'has_regression_range': False, | |
| 122 'solution': 'core_algorithm', | |
| 123 } | |
| 124 | |
| 125 self.assertEqual(expected_results, results) | |
| 126 self.assertEqual(expected_tag, tag) | |
| OLD | NEW |