def test_mappings(self): map_data = """ MAPS 1000-4000 r-xp 00000000 fd:00 495 /system/lib64/libc.so 6000-8000 r-xp 00000000 fd:00 495 a000-f000 r-xp 0000b000 fd:00 495 /system/lib64/libutils.so END """ heap = self.CreateTmpFile(map_data) backtraces, mappings = native_heapdump_viewer.ParseNativeHeap( heap, True, True) self.assertTrue(mappings) self.assertEqual(2, len(mappings)) self.assertEqual(0x1000, mappings[0].start) self.assertEqual(0x4000, mappings[0].end) self.assertEqual(0, mappings[0].offset) self.assertEqual("/system/lib64/libc.so", mappings[0].name) self.assertEqual(0xa000, mappings[1].start) self.assertEqual(0xf000, mappings[1].end) self.assertEqual(0xb000, mappings[1].offset) self.assertEqual("/system/lib64/libutils.so", mappings[1].name)
def test_backtrace_reverse_field_valid(self): heap = self.CreateTmpFile(self._backtrace_data) backtraces, mapppings = native_heapdump_viewer.ParseNativeHeap( heap, True, True) self.assertTrue(backtraces) self.assertEqual(2, len(backtraces)) self.assertFalse(backtraces[0].is_zygote) self.assertEqual(1000, backtraces[0].size) self.assertEqual(4, backtraces[0].num_allocs) self.assertEqual([0x3000, 0x2000, 0x1000], backtraces[0].frames) self.assertTrue(backtraces[1].is_zygote) self.assertEqual(8300, backtraces[1].size) self.assertEqual(5, backtraces[1].num_allocs) self.assertEqual([0x3300, 0x2300, 0x1300], backtraces[1].frames)