Skip to content
Snippets Groups Projects
Commit 252a6bf9 authored by pompolic's avatar pompolic
Browse files

(WIP) Explicit test for where malloc calls should add the memory use

parent d949c618
No related branches found
No related tags found
No related merge requests found
import unittest
class TestMallocParserAttribution(unittest.TestCase):
def setUp(self):
self.a = Parser("a", 128)
self.b = Parser("b", 32)
self.top_level_parse = TopLevelParse()
self.top_level_parse.parser_objs[32] = self.b
self.top_level_parse.parser_objs[128] = self.a
# TODO: the above two lines simulate a side effect of enter_h_do_parse. could be avoided if self.a and self.b was assigned after the calls below
self.top_level_parse.enter_h_packrat_parse(self.a.address)
#TODO: are we initializing from scratch for every test?
self.top_level_parse.enter_h_do_parse(400, 256, self.a.address)
self.top_level_parse.parse_virtual(self.a.address)
self.top_level_parse.enter_perform_lowlevel_parse(self.a.address)
def test_alloc_after_h_do_parse(self):
self.top_level_parse.enter_h_do_parse(400, 256, self.b.address)
self.top_level_parse.enter_h_arena_malloc_raw(150)
self.assertEqual(b.bytes_used[256], 150)
def test_alloc_after_parse_virtual(self):
self.top_level_parse.enter_h_do_parse(400, 256, self.b.address)
self.top_level_parse.parse_virtual(self.b.address)
self.top_level_parse.enter_h_arena_malloc_raw(150)
self.assertEqual(b.bytes_used[256], 150)
def test_alloc_after_enter_perform_lowlevel_parse(self):
self.top_level_parse.enter_h_do_parse(400, 256, self.b.address)
self.top_level_parse.parse_virtual(self.b.address)
self.top_level_parse.enter_perform_lowlevel_parse(self.b.address)
self.top_level_parse.enter_h_arena_malloc_raw(150)
self.assertEqual(b.bytes_used[256], 150)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment