Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: tools/memory_inspector/memory_inspector/backends/android/android_backend_unittest.py

Issue 358993003: [Android] Switch to DeviceUtils versions of file functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Unittests for the backends.android modules.""" 5 """Unittests for the backends.android modules."""
6 6
7 import os 7 import os
8 import unittest 8 import unittest
9 9
10 from memory_inspector.backends import prebuilts_fetcher 10 from memory_inspector.backends import prebuilts_fetcher
(...skipping 21 matching lines...) Expand all
32 """shared_other_unevictable=0 shared_other=0 "" [AA==] 32 """shared_other_unevictable=0 shared_other=0 "" [AA==]
33 400f4000-400f5000 r--p 0 private_unevictable=4096 private=4096 shared_app=[] """ 33 400f4000-400f5000 r--p 0 private_unevictable=4096 private=4096 shared_app=[] """
34 """shared_other_unevictable=0 shared_other=0 "" [AQ==] 34 """shared_other_unevictable=0 shared_other=0 "" [AQ==]
35 40127000-40147000 rw-s 0 private_unevictable=4096 private=4096 shared_app=[] """ 35 40127000-40147000 rw-s 0 private_unevictable=4096 private=4096 shared_app=[] """
36 """shared_other_unevictable=32768 shared_other=32768 "/X" [/////w==] 36 """shared_other_unevictable=32768 shared_other=32768 "/X" [/////w==]
37 be8b7000-be8d8000 rw-p 0 private_unevictable=8192 private=8192 shared_app=[] """ 37 be8b7000-be8d8000 rw-p 0 private_unevictable=8192 private=8192 shared_app=[] """
38 """shared_other_unevictable=4096 shared_other=12288 "[stack]" [AAAA4AE=] 38 """shared_other_unevictable=4096 shared_other=12288 "[stack]" [AAAA4AE=]
39 ffff0000-ffff1000 r-xp 0 private_unevictable=0 private=0 shared_app=[] """ 39 ffff0000-ffff1000 r-xp 0 private_unevictable=0 private=0 shared_app=[] """
40 """shared_other_unevictable=0 shared_other=0 "[vectors]" [AA==]""") 40 """shared_other_unevictable=0 shared_other=0 "[vectors]" [AA==]""")
41 41
42 _MOCH_DUMPHEAP_OUT = """Android Native Heap Dump v1.0 42 _MOCK_DUMPHEAP_OUT = """Android Native Heap Dump v1.0
43 43
44 Total memory: 1608601 44 Total memory: 1608601
45 Allocation records: 2 45 Allocation records: 2
46 46
47 z 1 sz 100 num 2 bt 9dcd1000 9dcd2000 b570e100 b570e000 47 z 1 sz 100 num 2 bt 9dcd1000 9dcd2000 b570e100 b570e000
48 z 0 sz 1000 num 3 bt b570e100 00001234 b570e200 48 z 0 sz 1000 num 3 bt b570e100 00001234 b570e200
49 MAPS 49 MAPS
50 9dcd0000-9dcd6000 r-xp 00000000 103:00 815 /system/lib/libnbaio.so 50 9dcd0000-9dcd6000 r-xp 00000000 103:00 815 /system/lib/libnbaio.so
51 9dcd6000-9dcd7000 r--p 00005000 103:00 815 /system/lib/libnbaio.so 51 9dcd6000-9dcd7000 r--p 00005000 103:00 815 /system/lib/libnbaio.so
52 9dcd7000-9dcd8000 rw-p 00006000 103:00 815 /system/lib/libnbaio.so 52 9dcd7000-9dcd8000 rw-p 00006000 103:00 815 /system/lib/libnbaio.so
(...skipping 25 matching lines...) Expand all
78 def setUp(self): 78 def setUp(self):
79 prebuilts_fetcher.in_test_harness = True 79 prebuilts_fetcher.in_test_harness = True
80 self._mock_adb = mock_adb.MockAdb() 80 self._mock_adb = mock_adb.MockAdb()
81 planned_adb_responses = { 81 planned_adb_responses = {
82 'devices': _MOCK_DEVICES_OUT, 82 'devices': _MOCK_DEVICES_OUT,
83 'shell getprop ro.product.model': 'Mock device', 83 'shell getprop ro.product.model': 'Mock device',
84 'shell getprop ro.build.type': 'userdebug', 84 'shell getprop ro.build.type': 'userdebug',
85 'root': 'adbd is already running as root', 85 'root': 'adbd is already running as root',
86 'shell /data/local/tmp/ps_ext': _MOCK_PS_EXT_OUT, 86 'shell /data/local/tmp/ps_ext': _MOCK_PS_EXT_OUT,
87 'shell /data/local/tmp/memdump': _MOCK_MEMDUMP_OUT, 87 'shell /data/local/tmp/memdump': _MOCK_MEMDUMP_OUT,
88 'shell cat "/data/local/tmp/heap': _MOCH_DUMPHEAP_OUT, 88 'shell cat "/data/local/tmp/heap': _MOCK_DUMPHEAP_OUT,
89 'shell test -e "/data/local/tmp/heap': '0',
89 } 90 }
90 for (cmd, response) in planned_adb_responses.iteritems(): 91 for (cmd, response) in planned_adb_responses.iteritems():
91 self._mock_adb.PrepareResponse(cmd, response) 92 self._mock_adb.PrepareResponse(cmd, response)
92 self._mock_adb.Start() 93 self._mock_adb.Start()
93 94
94 def runTest(self): 95 def runTest(self):
95 ab = android_backend.AndroidBackend() 96 ab = android_backend.AndroidBackend()
96 97
97 # Test settings load/store logic and setup the mock adb path. 98 # Test settings load/store logic and setup the mock adb path.
98 self.assertTrue('adb_path' in ab.settings.expected_keys) 99 self.assertTrue('adb_path' in ab.settings.expected_keys)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 self.assertEqual(alloc_2.total_size, 3000) 178 self.assertEqual(alloc_2.total_size, 3000)
178 self.assertEqual(alloc_2.stack_trace.depth, 3) 179 self.assertEqual(alloc_2.stack_trace.depth, 3)
179 # 0x00001234 is not present in the maps. It should be parsed anyways but 180 # 0x00001234 is not present in the maps. It should be parsed anyways but
180 # no executable info is expected. 181 # no executable info is expected.
181 self.assertEqual(alloc_2.stack_trace[1].address, 0x00001234) 182 self.assertEqual(alloc_2.stack_trace[1].address, 0x00001234)
182 self.assertIsNone(alloc_2.stack_trace[1].exec_file_rel_path) 183 self.assertIsNone(alloc_2.stack_trace[1].exec_file_rel_path)
183 self.assertIsNone(alloc_2.stack_trace[1].offset) 184 self.assertIsNone(alloc_2.stack_trace[1].offset)
184 185
185 def tearDown(self): 186 def tearDown(self):
186 self._mock_adb.Stop() 187 self._mock_adb.Stop()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698