當前位置: 首頁>>代碼示例>>Python>>正文


Python LegacyCrashProcessor._analyze_header方法代碼示例

本文整理匯總了Python中socorro.processor.legacy_processor.LegacyCrashProcessor._analyze_header方法的典型用法代碼示例。如果您正苦於以下問題:Python LegacyCrashProcessor._analyze_header方法的具體用法?Python LegacyCrashProcessor._analyze_header怎麽用?Python LegacyCrashProcessor._analyze_header使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在socorro.processor.legacy_processor.LegacyCrashProcessor的用法示例。


在下文中一共展示了LegacyCrashProcessor._analyze_header方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_analyze_header

# 需要導入模塊: from socorro.processor.legacy_processor import LegacyCrashProcessor [as 別名]
# 或者: from socorro.processor.legacy_processor.LegacyCrashProcessor import _analyze_header [as 別名]
    def test_analyze_header(self):  # verify fix for Bug 881623 in test one
        """test some of the possibilities in reading the first three lines
        from MDSW.  This does not provide comprehensive coverage."""
        config = setup_config_with_mocks()
        config.collect_addon = False
        config.collect_crash_process = True
        mocked_transform_rules_str = \
            'socorro.processor.legacy_processor.TransformRuleSystem'
        with mock.patch(mocked_transform_rules_str) as m_transform_class:
            m_transform = mock.Mock()
            m_transform_class.return_value = m_transform
            m_transform.attach_mock(mock.Mock(), 'apply_all_rules')
            utc_now_str = 'socorro.processor.legacy_processor.utc_now'
            with mock.patch(utc_now_str) as m_utc_now:
                m_utc_now.return_value = datetime(2012, 5, 4, 15, 11,
                                                  tzinfo=UTC)
                leg_proc = LegacyCrashProcessor(config, config.mock_quit_fn)

                # test one - all ok
                def dump_iter1():
                    lines = [
                        'OS|Windows NT|6.1.7601 Service Pack 1 ',
                        'CPU|x86|GenuineIntel family 6 model 42 stepping 7|8',
                        'Crash|EXCEPTION_ACCESS_VIOLATION_READ|0xffffffffdadadada|0'
                    ]
                    for a_line in lines:
                        yield a_line

                processor_notes = []

                result = leg_proc._analyze_header(
                    '1fcdec5e-face-404a-8622-babda2130605',
                    dump_iter1(),
                    m_utc_now(),
                    processor_notes
                )

                ok_(result.success)
                eq_(result.os_name, 'Windows NT')
                eq_(result.os_version, '6.1.7601 Service Pack 1')
                eq_(result.cpu_name, 'x86')
                eq_(result.cpu_info, 'GenuineIntel family 6 model 42 stepping 7 | 8')
                eq_(result.reason, 'EXCEPTION_ACCESS_VIOLATION_READ')
                eq_(result.address, '0xffffffffdadadada')
                eq_(result.crashedThread, 0)

                # test two - crashed thread missing
                def dump_iter2():
                    lines = [
                        'OS|Windows NT|6.1.7601 Service Pack 1 ',
                        'CPU|x86|GenuineIntel family 6 model 42 stepping 7|8',
                        'Crash|EXCEPTION_ACCESS_VIOLATION_READ|0xffffffffdadadada|'
                    ]
                    for a_line in lines:
                        yield a_line

                processor_notes = []

                result = leg_proc._analyze_header(
                    '1fcdec5e-face-404a-8622-babda2130605',
                    dump_iter2(),
                    m_utc_now(),
                    processor_notes
                )

                ok_(result.success)
                eq_(result.os_name, 'Windows NT')
                eq_(result.os_version, '6.1.7601 Service Pack 1')
                eq_(result.cpu_name, 'x86')
                eq_(result.cpu_info, 'GenuineIntel family 6 model 42 stepping 7 | 8')
                eq_(result.reason, 'EXCEPTION_ACCESS_VIOLATION_READ')
                eq_(result.address, '0xffffffffdadadada')
                eq_(result.crashedThread, None)
                ok_(
                    'MDSW did not identify the crashing thread' in
                    processor_notes
                )

                # test three - no lines
                def dump_iter3():
                    for a_line in []:
                        yield a_line

                processor_notes = []

                result = leg_proc._analyze_header(
                    '1fcdec5e-face-404a-8622-babda2130605',
                    dump_iter3(),
                    m_utc_now(),
                    processor_notes
                )

                ok_(result.success)
                eq_(result.os_name, None)
                eq_(result.os_version, None)
                eq_(result.cpu_name, None)
                eq_(result.cpu_info, None)
                eq_(result.reason, None)
                eq_(result.address, None)
                eq_(result.crashedThread, None)
#.........這裏部分代碼省略.........
開發者ID:Krispy2009,項目名稱:socorro,代碼行數:103,代碼來源:test_legacy_processor.py


注:本文中的socorro.processor.legacy_processor.LegacyCrashProcessor._analyze_header方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。