Пример #1
0
    def test_action_success(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        memory_report = get_example_file_data('good.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 11620}

        action_result = rule.action({}, {}, processed_crash, {})
        ok_(action_result)
        ok_('memory_measures' in processed_crash)

        expected_res = {
            'explicit': 232227872,
            'gfx_textures': 0,
            'ghost_windows': 7,
            'heap_allocated': 216793184,
            'heap_overhead': 14483360,
            'heap_unclassified': 171114283,
            'host_object_urls': 0,
            'images': 0,
            'js_main_runtime': 0,
            'private': 182346923,
            'resident': 330346496,
            'resident_unique': 253452288,
            'system_heap_allocated': 123456,
            'top_none_detached': 45678901,
            'vsize': 1481437184,
            'vsize_max_contiguous': 2834628,
        }
        eq_(processed_crash['memory_measures'], expected_res)

        # Test with a different pid.
        processed_crash['json_dump']['pid'] = 11717

        action_result = rule.action({}, {}, processed_crash, {})
        ok_(action_result)
        ok_('memory_measures' in processed_crash)

        expected_res = {
            'explicit': 20655576,
            'gfx_textures': 123456,
            'ghost_windows': 0,
            'heap_allocated': 20655576,
            'heap_overhead': 0,
            'heap_unclassified': 20593000,
            'host_object_urls': 5,
            'images': 62576,
            'js_main_runtime': 600000,
            'private': 0,
            'resident': 123518976,
            'resident_unique': 56209408,
            'system_heap_allocated': 234567,
            'top_none_detached': 0,
            'vsize': 905883648,
            'vsize_max_contiguous': 5824618,
        }
        eq_(processed_crash['memory_measures'], expected_res)
    def test_action_success(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        memory_report = get_example_file_data('good.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 11620}

        action_result = rule.action({}, {}, processed_crash, {})
        assert action_result
        assert 'memory_measures' in processed_crash

        expected_res = {
            'explicit': 232227872,
            'gfx_textures': 0,
            'ghost_windows': 7,
            'heap_allocated': 216793184,
            'heap_overhead': 14483360,
            'heap_unclassified': 171114283,
            'host_object_urls': 0,
            'images': 0,
            'js_main_runtime': 0,
            'private': 182346923,
            'resident': 330346496,
            'resident_unique': 253452288,
            'system_heap_allocated': 123456,
            'top_none_detached': 45678901,
            'vsize': 1481437184,
            'vsize_max_contiguous': 2834628,
        }
        assert processed_crash['memory_measures'] == expected_res

        # Test with a different pid.
        processed_crash['json_dump']['pid'] = 11717

        action_result = rule.action({}, {}, processed_crash, {})
        assert action_result
        assert 'memory_measures' in processed_crash

        expected_res = {
            'explicit': 20655576,
            'gfx_textures': 123456,
            'ghost_windows': 0,
            'heap_allocated': 20655576,
            'heap_overhead': 0,
            'heap_unclassified': 20593000,
            'host_object_urls': 5,
            'images': 62576,
            'js_main_runtime': 600000,
            'private': 0,
            'resident': 123518976,
            'resident_unique': 56209408,
            'system_heap_allocated': 234567,
            'top_none_detached': 0,
            'vsize': 905883648,
            'vsize_max_contiguous': 5824618,
        }
        assert processed_crash['memory_measures'] == expected_res
Пример #3
0
    def test_predicate_failure_bad_unrecognizable(self):
        rule = MemoryReportExtraction()

        memory_report = get_example_file_data("bad_unrecognizable.json")

        processed_crash = {}
        processed_crash["memory_report"] = memory_report
        processed_crash["json_dump"] = {"pid": 11620}

        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert not predicate_result
    def test_predicate_failure_bad_unrecognizable(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        memory_report = get_example_file_data('bad_unrecognizable.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 11620}

        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert not predicate_result
    def test_predicate_failure_bad_unrecognizable(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        memory_report = get_example_file_data('bad_unrecognizable.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 11620}

        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert not predicate_result
    def test_predicate_success(self):
        rule = MemoryReportExtraction()

        processed_crash = {}
        processed_crash['memory_report'] = {
            'reports': [],
            'version': '',
            'hasMozMallocUsableSize': '',
        }
        processed_crash['json_dump'] = {'pid': 42}

        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert predicate_result
Пример #7
0
    def test_predicate_success(self):
        rule = MemoryReportExtraction()

        processed_crash = {}
        processed_crash["memory_report"] = {
            "reports": [],
            "version": "",
            "hasMozMallocUsableSize": "",
        }
        processed_crash["json_dump"] = {"pid": 42}

        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert predicate_result
    def test_predicate_success(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        processed_crash = {}
        processed_crash['memory_report'] = {
            'reports': [],
            'version': '',
            'hasMozMallocUsableSize': '',
        }
        processed_crash['json_dump'] = {'pid': 42}

        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert predicate_result
Пример #9
0
    def test_predicate_no_match(self):
        rule = MemoryReportExtraction()

        processed_crash = {}

        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert not predicate_result

        processed_crash["memory_report"] = {}
        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert not predicate_result

        processed_crash["json_dump"] = {"pid": None}
        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert not predicate_result
Пример #10
0
    def test_action_failure_key_error(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        memory_report = get_example_file_data('bad_missing_key.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 11620}
        rule.action({}, {}, processed_crash, {})

        assert 'memory_measures' not in processed_crash

        config.logger.info.assert_called_with(
            'Unable to extract measurements from memory report: '
            "key 'process' is missing from a report")
Пример #11
0
    def test_action_failure_bad_pid(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        memory_report = get_example_file_data('good.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 12345}
        rule.action({}, {}, processed_crash, {})

        assert 'memory_measures' not in processed_crash

        config.logger.info.assert_called_with(
            'Unable to extract measurements from memory report: '
            'no measurements found for pid 12345')
Пример #12
0
    def test_action_failure_bad_units(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        memory_report = get_example_file_data('bad_units.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 11620}
        rule.action({}, {}, processed_crash, {})

        assert 'memory_measures' not in processed_crash

        config.logger.info.assert_called_with(
            'Unable to extract measurements from memory report: '
            'bad units for an explicit/ report: explicit/foo, 1')
Пример #13
0
    def get_ruleset(self, config):
        """Generate rule set for Mozilla crash processing.

        :arg config: configman DotDict config instance

        :returns: pipeline of rules

        """
        return [
            # fix the raw crash removing null characters
            DeNullRule(),
            # rules to change the internals of the raw crash
            ProductRewrite(),
            ESRVersionRewrite(),
            PluginContentURL(),
            PluginUserComment(),
            # rules to transform a raw crash into a processed crash
            IdentifierRule(),
            MinidumpSha256Rule(),
            BreakpadStackwalkerRule2015(
                dump_field=config.breakpad.dump_field,
                symbols_urls=config.breakpad.symbols_urls,
                command_line=config.breakpad.command_line,
                command_pathname=config.breakpad.command_pathname,
                kill_timeout=config.breakpad.kill_timeout,
                symbol_tmp_path=config.breakpad.symbol_tmp_path,
                symbol_cache_path=config.breakpad.symbol_cache_path,
                tmp_storage_path=config.breakpad.tmp_storage_path),
            ProductRule(),
            UserDataRule(),
            EnvironmentRule(),
            PluginRule(),
            AddonsRule(),
            DatesAndTimesRule(),
            OutOfMemoryBinaryRule(),
            JavaProcessRule(),
            MozCrashReasonRule(),
            # post processing of the processed crash
            CrashingThreadRule(),
            CPUInfoRule(),
            OSInfoRule(),
            BetaVersionRule(
                version_string_api=config.betaversion.version_string_api),
            ExploitablityRule(),
            FlashVersionRule(),
            OSPrettyVersionRule(),
            TopMostFilesRule(),
            ThemePrettyNameRule(),
            MemoryReportExtraction(),
            # generate signature now that we've done all the processing it depends on
            SignatureGeneratorRule(),
            # a set of classifiers to help with jit crashes--must be last since it
            # depends on signature generation
            JitCrashCategorizeRule(
                dump_field=config.jit.dump_field,
                command_line=config.jit.command_line,
                command_pathname=config.jit.command_pathname,
                kill_timeout=config.jit.kill_timeout),
        ]
    def test_predicate_no_match(self):
        rule = MemoryReportExtraction()

        processed_crash = {}

        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert not predicate_result

        processed_crash['memory_report'] = {}
        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert not predicate_result

        processed_crash['json_dump'] = {
            'pid': None,
        }
        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert not predicate_result
    def test_action_failure_key_error(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        memory_report = get_example_file_data('bad_missing_key.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 11620}

        action_result = rule.action({}, {}, processed_crash, {})
        assert not action_result
        assert 'memory_measures' not in processed_crash

        config.logger.info.assert_called_with(
            'Unable to extract measurements from memory report: '
            "key 'process' is missing from a report"
        )
Пример #16
0
    def test_action_failure_bad_pid(self, caplogpp):
        caplogpp.set_level("DEBUG")

        rule = MemoryReportExtraction()

        memory_report = get_example_file_data("good.json")

        processed_crash = {}
        processed_crash["memory_report"] = memory_report
        processed_crash["json_dump"] = {"pid": 12345}
        rule.action({}, {}, processed_crash, {})

        assert "memory_measures" not in processed_crash

        msgs = [rec.message for rec in caplogpp.records]
        assert msgs[0] == (
            "Unable to extract measurements from memory report: "
            "no measurements found for pid 12345")
    def test_action_failure_bad_units(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        memory_report = get_example_file_data('bad_units.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 11620}

        action_result = rule.action({}, {}, processed_crash, {})
        assert not action_result
        assert 'memory_measures' not in processed_crash

        config.logger.info.assert_called_with(
            'Unable to extract measurements from memory report: '
            'bad units for an explicit/ report: explicit/foo, 1'
        )
    def test_action_failure_bad_pid(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        memory_report = get_example_file_data('good.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 12345}

        action_result = rule.action({}, {}, processed_crash, {})
        assert not action_result
        assert 'memory_measures' not in processed_crash

        config.logger.info.assert_called_with(
            'Unable to extract measurements from memory report: '
            'no measurements found for pid 12345'
        )
    def test_action_failure_bad_units(self, caplogpp):
        caplogpp.set_level('DEBUG')

        rule = MemoryReportExtraction()

        memory_report = get_example_file_data('bad_units.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 11620}
        rule.action({}, {}, processed_crash, {})

        assert 'memory_measures' not in processed_crash

        msgs = [rec.message for rec in caplogpp.records]
        assert msgs[0] == (
            'Unable to extract measurements from memory report: '
            'bad units for an explicit/ report: explicit/foo, 1')
Пример #20
0
    def test_predicate_no_match(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        processed_crash = {}

        predicate_result = rule.predicate({}, {}, processed_crash, {})
        ok_(not predicate_result)

        processed_crash['memory_report'] = {}
        predicate_result = rule.predicate({}, {}, processed_crash, {})
        ok_(not predicate_result)

        processed_crash['json_dump'] = {
            'pid': None,
        }
        predicate_result = rule.predicate({}, {}, processed_crash, {})
        ok_(not predicate_result)
    def test_action_failure_bad_pid(self, caplogpp):
        caplogpp.set_level('DEBUG')

        rule = MemoryReportExtraction()

        memory_report = get_example_file_data('good.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 12345}
        rule.action({}, {}, processed_crash, {})

        assert 'memory_measures' not in processed_crash

        msgs = [rec.message for rec in caplogpp.records]
        assert msgs[0] == (
            'Unable to extract measurements from memory report: '
            'no measurements found for pid 12345')
    def test_action_failure_key_error(self, caplogpp):
        caplogpp.set_level('DEBUG')

        rule = MemoryReportExtraction()

        memory_report = get_example_file_data('bad_missing_key.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 11620}
        rule.action({}, {}, processed_crash, {})

        assert 'memory_measures' not in processed_crash

        msgs = [rec.message for rec in caplogpp.records]
        assert msgs[0] == (
            'Unable to extract measurements from memory report: '
            "key 'process' is missing from a report")
Пример #23
0
    def test_action_failure_bad_units(self, caplogpp):
        caplogpp.set_level("DEBUG")

        rule = MemoryReportExtraction()

        memory_report = get_example_file_data("bad_units.json")

        processed_crash = {}
        processed_crash["memory_report"] = memory_report
        processed_crash["json_dump"] = {"pid": 11620}
        rule.action({}, {}, processed_crash, {})

        assert "memory_measures" not in processed_crash

        msgs = [rec.message for rec in caplogpp.records]
        assert msgs[0] == (
            "Unable to extract measurements from memory report: "
            "bad units for an explicit/ report: explicit/foo, 1")
Пример #24
0
    def test_action_failure_key_error(self, caplogpp):
        caplogpp.set_level("DEBUG")

        rule = MemoryReportExtraction()

        memory_report = get_example_file_data("bad_missing_key.json")

        processed_crash = {}
        processed_crash["memory_report"] = memory_report
        processed_crash["json_dump"] = {"pid": 11620}
        rule.action({}, {}, processed_crash, {})

        assert "memory_measures" not in processed_crash

        msgs = [rec.message for rec in caplogpp.records]
        assert msgs[0] == (
            "Unable to extract measurements from memory report: "
            "key 'process' is missing from a report")
    def test_predicate_no_match(self):
        config = self.get_config()
        rule = MemoryReportExtraction(config)

        processed_crash = {}

        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert not predicate_result

        processed_crash['memory_report'] = {}
        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert not predicate_result

        processed_crash['json_dump'] = {
            'pid': None,
        }
        predicate_result = rule.predicate({}, {}, processed_crash, {})
        assert not predicate_result
    def test_action_failure_bad_pid(self, caplogpp):
        caplogpp.set_level('DEBUG')

        config = self.get_config()
        rule = MemoryReportExtraction(config)

        memory_report = get_example_file_data('good.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 12345}
        rule.action({}, {}, processed_crash, {})

        assert 'memory_measures' not in processed_crash

        msgs = [rec.message for rec in caplogpp.records]
        assert msgs[0] == (
            'Unable to extract measurements from memory report: '
            'no measurements found for pid 12345'
        )
    def test_action_failure_key_error(self, caplogpp):
        caplogpp.set_level('DEBUG')

        config = self.get_config()
        rule = MemoryReportExtraction(config)

        memory_report = get_example_file_data('bad_missing_key.json')

        processed_crash = {}
        processed_crash['memory_report'] = memory_report
        processed_crash['json_dump'] = {'pid': 11620}
        rule.action({}, {}, processed_crash, {})

        assert 'memory_measures' not in processed_crash

        msgs = [rec.message for rec in caplogpp.records]
        assert msgs[0] == (
            'Unable to extract measurements from memory report: '
            "key 'process' is missing from a report"
        )
    def test_action_success(self):
        rule = MemoryReportExtraction()

        memory_report = get_example_file_data("good.json")

        processed_crash = {
            "memory_report": memory_report,
            "json_dump": {
                "pid": 11620
            },
        }
        rule.action({}, {}, processed_crash, {})

        assert "memory_measures" in processed_crash

        expected_res = {
            "explicit": 232227872,
            "gfx_textures": 0,
            "ghost_windows": 7,
            "heap_allocated": 216793184,
            "heap_overhead": 14483360,
            "heap_unclassified": 171114283,
            "host_object_urls": 0,
            "images": 0,
            "js_main_runtime": 0,
            "private": 182346923,
            "resident": 330346496,
            "resident_unique": 253452288,
            "system_heap_allocated": 123456,
            "top_none_detached": 45678901,
            "vsize": 1481437184,
            "vsize_max_contiguous": 2834628,
        }
        assert processed_crash["memory_measures"] == expected_res

        # Test with a different pid
        processed_crash["json_dump"]["pid"] = 11717
        rule.action({}, {}, processed_crash, {})

        assert "memory_measures" in processed_crash

        expected_res = {
            "explicit": 20655576,
            "gfx_textures": 123456,
            "ghost_windows": 0,
            "heap_allocated": 20655576,
            "heap_overhead": 0,
            "heap_unclassified": 20593000,
            "host_object_urls": 5,
            "images": 62576,
            "js_main_runtime": 600000,
            "private": 0,
            "resident": 123518976,
            "resident_unique": 56209408,
            "system_heap_allocated": 234567,
            "top_none_detached": 0,
            "vsize": 905883648,
            "vsize_max_contiguous": 5824618,
        }
        assert processed_crash["memory_measures"] == expected_res