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

Unified Diff: tools/find_runtime_symbols/tests/proc_maps_tests.py

Issue 11299095: Add a first test for tools/find_runtime_symbols. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: tools/find_runtime_symbols/tests/proc_maps_tests.py
diff --git a/tools/find_runtime_symbols/tests/proc_maps_tests.py b/tools/find_runtime_symbols/tests/proc_maps_tests.py
new file mode 100755
index 0000000000000000000000000000000000000000..75d06bb5c1ea193a21b15b9ad0c7d56b5be14f17
--- /dev/null
+++ b/tools/find_runtime_symbols/tests/proc_maps_tests.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import cStringIO
+import logging
+import os
+import sys
+import unittest
+
+ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+sys.path.insert(0, ROOT_DIR)
+
+from proc_maps import ProcMaps
+
+
+class ProcMapsTest(unittest.TestCase):
M-A Ruel 2012/11/20 14:30:00 It is still preferable to restrict to 80 cols. Spl
Dai Mikurube (NOT FULLTIME) 2012/11/21 05:51:45 Done.
+ _TEST_PROCMAPS = """00000000-00001000 r--p 00000000 fc:00 0
+0080b000-0080c000 r--p 0020b000 fc:00 2231329 /usr/bin/some
+0237d000-02a9b000 rw-p 00000000 00:00 0 [heap]
+7fb920e6d000-7fb920e85000 r-xp 00000000 fc:00 263482 /lib/x86_64-linux-gnu/libpthread-2.15.so
+7fb920e85000-7fb921084000 ---p 00018000 fc:00 263482 /lib/x86_64-linux-gnu/libpthread-2.15.so
+7fb9225f4000-7fb922654000 rw-s 00000000 00:04 19660808 /SYSV00000000 (deleted)
+ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
+"""
+
+ def test_load(self):
+ maps = ProcMaps.load(cStringIO.StringIO(self._TEST_PROCMAPS))
+ entries = []
+ for entry in maps:
+ entries.append(entry)
+ self.assertEqual(len(entries), 7)
+ self.assertEqual(entries[0].begin, 0x0)
M-A Ruel 2012/11/20 14:30:00 If you had something like entries[0].as_dict(), it
Dai Mikurube (NOT FULLTIME) 2012/11/21 05:51:45 Thanks for the good suggestion. Done. Also added
+ self.assertEqual(entries[0].name, '')
+ self.assertEqual(entries[0].end, 0x1000)
+ self.assertEqual(entries[1].begin, 0x80b000)
+ self.assertEqual(entries[1].end, 0x80c000)
+ self.assertEqual(entries[1].readable, 'r')
+ self.assertEqual(entries[1].writable, '-')
+ self.assertEqual(entries[1].executable, '-')
+ self.assertEqual(entries[1].private, 'p')
+ self.assertEqual(entries[1].offset, 0x20b000)
+ self.assertEqual(entries[1].major, 'fc')
+ self.assertEqual(entries[1].minor, '00')
+ self.assertEqual(entries[1].inode, 2231329)
+ self.assertEqual(entries[1].name, '/usr/bin/some')
+ self.assertEqual(entries[2].begin, 0x237d000)
+ self.assertEqual(entries[2].writable, 'w')
+ self.assertEqual(entries[2].name, '[heap]')
+ self.assertEqual(entries[3].begin, 0x7fb920e6d000)
+ self.assertEqual(entries[3].executable, 'x')
+ self.assertEqual(entries[4].begin, 0x7fb920e85000)
+ self.assertEqual(entries[4].readable, '-')
+ self.assertEqual(entries[5].begin, 0x7fb9225f4000)
+ self.assertEqual(entries[5].private, 's')
+ self.assertEqual(entries[5].major, '00')
+ self.assertEqual(entries[5].minor, '04')
+ self.assertEqual(entries[5].inode, 19660808)
+ self.assertEqual(entries[5].name, '/SYSV00000000 (deleted)')
+ self.assertEqual(entries[6].begin, 0xffffffffff600000)
+ self.assertEqual(entries[6].end, 0xffffffffff601000)
+ self.assertEqual(entries[6].name, '[vsyscall]')
+
+
+if __name__ == '__main__':
+ logging.basicConfig(
+ level=logging.DEBUG if '-v' in sys.argv else logging.ERROR,
+ format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s')
+ unittest.main()
« tools/find_runtime_symbols/proc_maps.py ('K') | « tools/find_runtime_symbols/static_symbols.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698