def test_chunks_numbers(self): ''' Count all user allocations and free chunks''' #self.skipTest('notready') mappings = self.ssh1.mappings heaps = mappings.getHeaps() self.assertEquals(len(heaps), 1) heap = heaps[0] self.assertTrue(ctypes_alloc.is_malloc_heap(mappings, heap)) walker = libcheapwalker.LibcHeapWalker(mappings, heap, 0) # we should have 3 structures + 1 empty chunks allocs = walker.get_user_allocations() self.assertEquals(len(allocs), 2568) size = sum([size for addr, size in allocs]) self.assertEquals(size, 105616) # the empty chunk free = walker.get_free_chunks() self.assertEquals(len(free), 7) size = sum([size for addr, size in free]) self.assertEquals(size, 19252) return
def test_chunks_numbers(self): """ Count all user allocations and free chunks""" # self.skipTest('notready') mappings = self.ssh1.mappings heaps = mappings.getHeaps() self.assertEquals(len(heaps), 1) heap = heaps[0] self.assertTrue(ctypes_alloc.is_malloc_heap(mappings, heap)) walker = libcheapwalker.LibcHeapWalker(mappings, heap, 0) # we should have 3 structures + 1 empty chunks allocs = walker.get_user_allocations() self.assertEquals(len(allocs), 2568) size = sum([size for addr, size in allocs]) self.assertEquals(size, 105616) # the empty chunk free = walker.get_free_chunks() self.assertEquals(len(free), 7) size = sum([size for addr, size in free]) self.assertEquals(size, 19252) return
def test_ctypes6(self): mappings = self.context6.mappings heaps = mappings.getHeaps() self.assertEquals(len(heaps), 1) heap = heaps[0] self.assertTrue(ctypes_alloc.is_malloc_heap(mappings, heap)) walker = libcheapwalker.LibcHeapWalker(mappings, heap, 0) # we should have 3 structures + 1 empty chunks allocs = walker.get_user_allocations() self.assertEquals(len(allocs), 3) # the empty chunk free = walker.get_free_chunks() self.assertEquals(len(free), 1)
def is_heap(mappings, mapping): """test if a mapping is a heap""" if not ctypes_malloc.is_malloc_heap(mappings, mapping): return False # could implement other allocators return True