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

Unified Diff: build/android/symbolize_test.py

Issue 18473004: Android: adds stack symbolization utilities. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/symbolize.py ('k') | build/android/tests/symbolize/Makefile » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/symbolize_test.py
diff --git a/build/android/symbolize_test.py b/build/android/symbolize_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..05934b876dce6b473447118cc303c3174fc097c9
--- /dev/null
+++ b/build/android/symbolize_test.py
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2013 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.
+
+"""Unittest for symbolize.py.
+
+This test uses test libraries generated by the Android g++ toolchain.
+
+Should things break you can recreate the libraries and get the updated
+addresses and demangled names by running the following:
+ cd test/symbolize/
+ make
+ nm -gC *.so
+"""
+
+import sys
+import StringIO
+import unittest
+
+import symbolize
+
+def RunSymbolizer(text):
+ output = StringIO.StringIO()
+ s = symbolize.Symbolizer(StringIO.StringIO(text), output)
+ s.ProcessInput()
+ return output.getvalue()
+
+
+class SymbolizerUnittest(unittest.TestCase):
+ def testSingleLineNoMatch(self):
+ # Leading '#' is required.
+ expected = '00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+
+ # Whitespace should be exactly one space.
+ expected = '#00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+ expected = '#00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+ expected = '#00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+
+ # Decimal stack frame numbers are required.
+ expected = '#0a pc 00000254 /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+
+ # Lowercase 'pc' token is required.
+ expected = '#00 PC 00000254 /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+
+ # Hexadecimal addresses are required.
+ expected = '#00 pc ghijklmn /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+
+ # Addresses must be exactly 8 characters.
+ expected = '#00 pc 254 /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+ expected = '#00 pc 0254 /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+ expected = '#00 pc 00254 /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+ expected = '#00 pc 000254 /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+ expected = '#00 pc 0000254 /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+
+ # Addresses must not be prefixed with '0x'.
+ expected = '#00 pc 0x00000254 /build/android/tests/symbolize/liba.so\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+
+ # Library name is required.
+ expected = '#00 pc 00000254\n'
+ self.assertEqual(expected, RunSymbolizer(expected))
+
+ def testSingleLine(self):
+ text = '#00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
+ expected = '#00 pc 00000254 A::Bar(char const*)\n'
+ actual = RunSymbolizer(text)
+ self.assertEqual(expected, actual)
+
+ def testSingleLineWithSurroundingText(self):
+ text = 'LEFT #00 pc 00000254 /build/android/tests/symbolize/liba.so RIGHT\n'
+ expected = 'LEFT #00 pc 00000254 A::Bar(char const*) RIGHT\n'
+ actual = RunSymbolizer(text)
+ self.assertEqual(expected, actual)
+
+ def testMultipleLinesSameLibrary(self):
+ text = '#00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
+ text += '#01 pc 00000234 /build/android/tests/symbolize/liba.so\n'
+ expected = '#00 pc 00000254 A::Bar(char const*)\n'
+ expected += '#01 pc 00000234 A::Foo(int)\n'
+ actual = RunSymbolizer(text)
+ self.assertEqual(expected, actual)
+
+ def testMultipleLinesDifferentLibrary(self):
+ text = '#00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
+ text += '#01 pc 00000234 /build/android/tests/symbolize/libb.so\n'
+ expected = '#00 pc 00000254 A::Bar(char const*)\n'
+ expected += '#01 pc 00000234 B::Baz(float)\n'
+ actual = RunSymbolizer(text)
+ self.assertEqual(expected, actual)
+
+ def testMultipleLinesWithSurroundingTextEverywhere(self):
+ text = 'TOP\n'
+ text += ('LEFT #00 pc 00000254 '
+ '/build/android/tests/symbolize/liba.so RIGHT\n')
+ text += ('LEFT #01 pc 00000234 '
+ '/build/android/tests/symbolize/libb.so RIGHT\n')
+ text += 'BOTTOM\n'
+ expected = 'TOP\n'
+ expected += 'LEFT #00 pc 00000254 A::Bar(char const*) RIGHT\n'
+ expected += 'LEFT #01 pc 00000234 B::Baz(float) RIGHT\n'
+ expected += 'BOTTOM\n'
+ actual = RunSymbolizer(text)
+ self.assertEqual(expected, actual)
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « build/android/symbolize.py ('k') | build/android/tests/symbolize/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698