コード例 #1
0
 def testRedo(self):
     """Tests setting the ``redo`` property to True."""
     raw_data = TEST_DATA.copy()
     raw_data['redo'] = 'true'
     uma_data = UMASamplingProfilerData(
         raw_data, ChromeDependencyFetcher(self.GetMockRepoFactory()))
     self.assertTrue(uma_data.redo)
コード例 #2
0
 def __init__(self,
              get_repository,
              meta_feature,
              meta_weight,
              top_n_frames=7,
              top_n_suspects=3):
     """
 Args:
   get_repository (callable): a function from DEP urls to ``Repository``
     objects, so we can get changelogs and blame for each dep. Notably,
     to keep the code here generic, we make no assumptions about
     which subclass of ``Repository`` this function returns. Thus,
     it is up to the caller to decide what class to return and handle
     any other arguments that class may require (e.g., an http client
     for ``GitilesRepository``).
   meta_feature (MetaFeature): All features.
   meta_weight (MetaWeight): All weights. the weights for the features.
     The keys of the dictionary are the names of the feature that weight is
     for. We take this argument as a dict rather than as a list so that
     callers needn't worry about what order to provide the weights in.
   top_n_frames (int): how many frames of each callstack to look at.
   top_n_suspects (int): maximum number of suspects to return.
 """
     self._dependency_fetcher = ChromeDependencyFetcher(get_repository)
     self._get_repository = get_repository
     self._top_n_frames = top_n_frames
     self._top_n_suspects = top_n_suspects
     self._model = UnnormalizedLogLinearModel(meta_feature, meta_weight)
コード例 #3
0
  def testDependencyRoll(self):
    """Tests parsing ``regression_rolls`` from regression_range."""
    dep_roll = DependencyRoll('src/', 'https://repo', 'rev1', 'rev6')
    regression_rolls = {
        dep_roll.path: dep_roll,
        'src/dummy': DependencyRoll('src/dummy', 'https://r', 'rev2', 'rev4'),
        'src/add': DependencyRoll('src/add', 'https://rr', None, 'rev5')
    }

    with mock.patch(
        'libs.deps.chrome_dependency_fetcher.ChromeDependencyFetcher'
        '.GetDependencyRollsDict') as mock_get_dependency_rolls:
      mock_get_dependency_rolls.return_value = regression_rolls

      crash_data = ChromeCrashData(
          self.GetDummyChromeCrashData(),
          ChromeDependencyFetcher(self.GetMockRepoFactory()))

      crash_data._regression_range = ('rev1', 'rev6')
      chromium_dep = Dependency('src/', 'https://repo', 'rev1')
      crash_data._crashed_version_deps = {
          chromium_dep.path: chromium_dep,
          'src/dummy': Dependency('src/dummy', 'https://r', 'rev2')}
      stack = CallStack(0, frame_list=[
          StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [5])])
      stacktrace = Stacktrace([stack], stack)
      crash_data._stacktrace = stacktrace

      self.assertEqual(crash_data.dependency_rolls, {dep_roll.path: dep_roll})
コード例 #4
0
 def testDetectRegressionRangeFailed(self):
     """Tests that ``regression_range`` is None when detection failed."""
     with mock.patch(
             'analysis.detect_regression_range.DetectRegressionRange',
             lambda *_: None):
         crash_data = ChromeCrashData(
             self.GetDummyChromeCrashData(),
             ChromeDependencyFetcher(self.GetMockRepoFactory()))
         self.assertIsNone(crash_data.regression_range)
コード例 #5
0
 def testParseStacktraceFailed(self, mock_get_dependency,
                               mock_chromecrash_parser):
     """Tests that ``stacktrace`` is None when failed to parse stacktrace."""
     mock_get_dependency.return_value = {}
     mock_chromecrash_parser.return_value = None
     crash_data = CracasCrashData(
         self.GetDummyChromeCrashData(),
         ChromeDependencyFetcher(self.GetMockRepoFactory()))
     self.assertIsNone(crash_data.stacktrace)
コード例 #6
0
 def testDetectRegressionRangeSucceeded(self):
     """Tests detecting ``regression_range``."""
     regression_range = ('1', '3')
     with mock.patch(
             'analysis.detect_regression_range.DetectRegressionRange',
             lambda *_: regression_range):
         crash_data = ChromeCrashData(
             self.GetDummyChromeCrashData(),
             ChromeDependencyFetcher(self.GetMockRepoFactory()))
         self.assertEqual(crash_data.regression_range, regression_range)
コード例 #7
0
    def testRawStactraceProperty(self):
        """Tests ``raw_stacktrace`` property turns a list to a string."""
        stacktrace_list = ['stacktrace1', 'stacktrace2']
        crash_data = CracasCrashData(
            self.GetDummyChromeCrashData(),
            ChromeDependencyFetcher(self.GetMockRepoFactory()))
        crash_data._raw_stacktrace = stacktrace_list

        self.assertEqual(crash_data.raw_stacktrace,
                         json.dumps(stacktrace_list))
コード例 #8
0
    def testSignature(self):
        """Tests generation of the signature."""
        raw_data = copy.deepcopy(TEST_DATA)
        # Preserve only the first stack.
        raw_data['subtree_stacks'] = raw_data['subtree_stacks'][0:1]
        root_frame = (raw_data['subtree_stacks'][0]['frames'][
            raw_data['subtree_root_depth']])

        # Check that the function gets truncated to the max length.
        root_frame['function_name'] = 'x' * (SIGNATURE_MAX_LENGTH + 1)
        uma_data = UMASamplingProfilerData(
            raw_data, ChromeDependencyFetcher(self.GetMockRepoFactory()))
        self.assertEqual(uma_data.signature, 'x' * SIGNATURE_MAX_LENGTH)

        # Check that unsymbolized functions are properly handled.
        del root_frame['function_name']
        uma_data = UMASamplingProfilerData(
            raw_data, ChromeDependencyFetcher(self.GetMockRepoFactory()))
        self.assertEqual(uma_data.signature, 'unsymbolized function')
コード例 #9
0
    def testIdentifiers(self):
        crash_data = ChromeCrashData(
            self.GetDummyChromeCrashData(),
            ChromeDependencyFetcher(self.GetMockRepoFactory()))

        self.assertDictEqual(
            crash_data.identifiers, {
                'signature': crash_data.signature,
                'platform': crash_data.platform,
                'channel': crash_data.channel,
                'regression_range': crash_data.regression_range
            })
コード例 #10
0
 def testParseStacktraceSucceeded(self, mock_get_dependency):
     """Tests parsing ``stacktrace``."""
     mock_get_dependency.return_value = {}
     crash_data = CracasCrashData(
         self.GetDummyChromeCrashData(),
         ChromeDependencyFetcher(self.GetMockRepoFactory()))
     stack = CallStack(0)
     stacktrace = Stacktrace([stack], stack)
     with mock.patch('analysis.chromecrash_parser.CracasCrashParser.Parse'
                     ) as mock_parse:
         mock_parse.return_value = stacktrace
         self._VerifyTwoStacktracesEqual(crash_data.stacktrace, stacktrace)
コード例 #11
0
  def HandleGet(self):
    """Update the repo_to_dep_path in config from the lastest DEPS."""
    # Update repo_to_dep_path to the latest information.
    dep_fetcher = ChromeDependencyFetcher(
      CachedGitilesRepository.Factory(HttpClientAppengine()))

    repo_to_dep_path = GetRepoToDepPath(dep_fetcher)
    if not repo_to_dep_path:  # pragma: no cover.
      return self.CreateError('Fail to update repo_to_dep_path config.', 400)

    crash_config = CrashConfig.Get()
    crash_config.Update(users.User(app_identity.get_service_account_name()),
                        True, repo_to_dep_path=repo_to_dep_path)
コード例 #12
0
 def GetCrashData(self, raw_regression_data):
     """Gets ``UMASamplingProfilerData`` from ``raw_regression_data``."""
     return UMASamplingProfilerData(
         raw_regression_data, ChromeDependencyFetcher(self._get_repository))
コード例 #13
0
 def testAlwaysRedo(self):
     """Tests that Cracas always redo analysis."""
     crash_data = CracasCrashData(
         self.GetDummyChromeCrashData(),
         ChromeDependencyFetcher(self.GetMockRepoFactory()))
     self.assertTrue(crash_data.redo)
コード例 #14
0
 def GetCrashData(self, raw_crash_data):
     """Returns parsed ``ChromeCrashData`` from raw json crash data."""
     return self.CrashDataCls()(raw_crash_data,
                                ChromeDependencyFetcher(
                                    self._get_repository),
                                top_n_frames=self.client_config['top_n'])
コード例 #15
0
 def _GetDummyUMAData(self):
     return UMASamplingProfilerData(
         TEST_DATA, ChromeDependencyFetcher(self.GetMockRepoFactory()))
コード例 #16
0
 def _GetDummyDependencyAnalyzer(self):
     return DependencyAnalyzer(
         'win', '54.0.2835.0', ('54.0.2834.0', '54.0.2835.0'),
         ChromeDependencyFetcher(self.GetMockRepoFactory()))