From 61dbaeb92705396e1c12336ae8db22b9d86a63ed Mon Sep 17 00:00:00 2001 From: pompolic <pompolic@special-circumstanc.es> Date: Tue, 21 Feb 2023 20:53:33 +0100 Subject: [PATCH] Add test to catch wrongly attributed allocations (broken) --- gdb-port/tests/unit/top-level-parse.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gdb-port/tests/unit/top-level-parse.py b/gdb-port/tests/unit/top-level-parse.py index b0a5692..cbd38f6 100644 --- a/gdb-port/tests/unit/top-level-parse.py +++ b/gdb-port/tests/unit/top-level-parse.py @@ -68,6 +68,16 @@ class TopLevelParseStateManagement(unittest.TestCase): def test_return_from_lowlevel_parse(self): pass + # TODO: This is closer to an integration test: when enter_h_arena_malloc_raw is called, the allocation + # is added to the parser on top of the stack of stacks. + # Testing here that after calling enter_h_do_parse, then enter_h_arena_malloc_raw + # the latter will attribute the allocation to the parser we just set + def test_enter_h_arena_malloc_raw_top_of_stack(self): + self.top_level_parse.parser_stacks.append(self.ps1) + self.top_level_parse.enter_h_do_parse(16, 40, self.parser1.address) + self.top_level_parse.enter_h_arena_malloc_raw(256) + self.assertEqual(self.parser1.bytes_used[40], 256) + def test_enter_h_arena_malloc_raw(self): self.top_level_parse.parser_stacks.append(self.ps1) self.top_level_parse.parser_objs[32] = self.parser1 -- GitLab