OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import cStringIO | 6 import cStringIO |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 import unittest | 10 import unittest |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 'name': ProcMapsTest._EXPECTED[index][10], | 76 'name': ProcMapsTest._EXPECTED[index][10], |
77 } | 77 } |
78 | 78 |
79 def test_load(self): | 79 def test_load(self): |
80 maps = ProcMaps.load_file(cStringIO.StringIO(self._TEST_PROCMAPS)) | 80 maps = ProcMaps.load_file(cStringIO.StringIO(self._TEST_PROCMAPS)) |
81 for index, entry in enumerate(maps): | 81 for index, entry in enumerate(maps): |
82 self.assertEqual(entry.as_dict(), self._expected_as_dict(index)) | 82 self.assertEqual(entry.as_dict(), self._expected_as_dict(index)) |
83 | 83 |
84 def test_constants(self): | 84 def test_constants(self): |
85 maps = ProcMaps.load_file(cStringIO.StringIO(self._TEST_PROCMAPS)) | 85 maps = ProcMaps.load_file(cStringIO.StringIO(self._TEST_PROCMAPS)) |
86 selected = [4, 7] | 86 selected = [0, 2, 4, 7] |
87 for index, entry in enumerate(maps.iter(ProcMaps.constants)): | 87 for index, entry in enumerate(maps.iter(ProcMaps.constants)): |
88 self.assertEqual(entry.as_dict(), | 88 self.assertEqual(entry.as_dict(), |
89 self._expected_as_dict(selected[index])) | 89 self._expected_as_dict(selected[index])) |
90 | 90 |
91 def test_executable(self): | 91 def test_executable(self): |
92 maps = ProcMaps.load_file(cStringIO.StringIO(self._TEST_PROCMAPS)) | 92 maps = ProcMaps.load_file(cStringIO.StringIO(self._TEST_PROCMAPS)) |
93 selected = [3, 6] | 93 selected = [1, 3, 6, 9] |
94 for index, entry in enumerate(maps.iter(ProcMaps.executable)): | 94 for index, entry in enumerate(maps.iter(ProcMaps.executable)): |
95 self.assertEqual(entry.as_dict(), | 95 self.assertEqual(entry.as_dict(), |
96 self._expected_as_dict(selected[index])) | 96 self._expected_as_dict(selected[index])) |
97 | 97 |
98 def test_executable_and_constants(self): | 98 def test_executable_and_constants(self): |
99 maps = ProcMaps.load_file(cStringIO.StringIO(self._TEST_PROCMAPS)) | 99 maps = ProcMaps.load_file(cStringIO.StringIO(self._TEST_PROCMAPS)) |
100 selected = [3, 4, 6, 7] | 100 selected = [0, 1, 2, 3, 4, 6, 7, 9] |
101 for index, entry in enumerate(maps.iter(ProcMaps.executable_and_constants)): | 101 for index, entry in enumerate(maps.iter(ProcMaps.executable_and_constants)): |
102 self.assertEqual(entry.as_dict(), | 102 self.assertEqual(entry.as_dict(), |
103 self._expected_as_dict(selected[index])) | 103 self._expected_as_dict(selected[index])) |
104 | 104 |
105 | 105 |
106 if __name__ == '__main__': | 106 if __name__ == '__main__': |
107 logging.basicConfig( | 107 logging.basicConfig( |
108 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR, | 108 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR, |
109 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 109 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
110 unittest.main() | 110 unittest.main() |
OLD | NEW |