| Index: appengine/findit/crash/test/component_classifier_test.py
|
| diff --git a/appengine/findit/crash/test/component_classifier_test.py b/appengine/findit/crash/test/component_classifier_test.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3bc3800b03995fe2c5d86327f7a8c783b6688b61
|
| --- /dev/null
|
| +++ b/appengine/findit/crash/test/component_classifier_test.py
|
| @@ -0,0 +1,60 @@
|
| +# Copyright 2016 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +from common.pipeline_wrapper import pipeline_handlers
|
| +from crash.callstack import StackFrame, CallStack
|
| +from crash.results import Result
|
| +from crash.test.crash_testcase import CrashTestCase
|
| +from model.crash import crash_config
|
| +
|
| +
|
| +class ComponentClassifierTest(CrashTestCase):
|
| +
|
| + def setUp(self):
|
| + super(ComponentClassifierTest, self).setUp()
|
| + config = crash_config.CrashConfig.Get()
|
| +
|
| + class MockCrashConfig(object):
|
| +
|
| + @classmethod
|
| + def Get(cls):
|
| + return config
|
| +
|
| + self.mock(crash_config, 'CrashConfig', MockCrashConfig)
|
| + from crash.component_classifier import ComponentClassifier
|
| + self.classifier = ComponentClassifier
|
| +
|
| + def testGetClassFromStackFrame(self):
|
| + frame = StackFrame(0, 'src/', 'func', 'comp1.cc', 'src/comp1.cc', [2])
|
| + self.assertEqual(
|
| + self.classifier().GetClassFromStackFrame(frame),
|
| + 'Comp1>Dummy')
|
| +
|
| + frame = StackFrame(0, 'src/', 'func2', 'comp2.cc', 'src/comp2.cc', [32])
|
| + self.assertEqual(
|
| + self.classifier().GetClassFromStackFrame(frame),
|
| + 'Comp2>Dummy')
|
| +
|
| + def testGetClassFromResult(self):
|
| + result = Result(self.GetDummyChangeLog(), 'src/')
|
| + result.file_to_stack_infos = {
|
| + StackFrame(0, 'src/', 'func', 'comp1.cc', 'src/comp1.cc', [2]): None
|
| + }
|
| +
|
| + self.assertEqual(self.classifier().GetClassFromResult(result),
|
| + 'Comp1>Dummy')
|
| +
|
| + def testClassifyCrashStack(self):
|
| + crash_stack = CallStack(0)
|
| + crash_stack.extend([
|
| + StackFrame(0, 'src/', 'func', 'comp1.cc', 'src/comp1.cc', [2]),
|
| + StackFrame(1, 'src/', 'ff', 'comp1.cc', 'src/comp1.cc', [21]),
|
| + StackFrame(2, 'src/', 'func2', 'comp2.cc', 'src/comp2.cc', [8])
|
| + ])
|
| +
|
| + self.assertEqual(self.classifier().Classify([], crash_stack),
|
| + ('Comp1>Dummy', 'Comp2>Dummy'))
|
| +
|
| + def testClassifyResults(self):
|
| + pass
|
|
|