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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/symbolize.py ('k') | build/android/tests/symbolize/Makefile » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 """Unittest for symbolize.py.
8
9 This test uses test libraries generated by the Android g++ toolchain.
10
11 Should things break you can recreate the libraries and get the updated
12 addresses and demangled names by running the following:
13 cd test/symbolize/
14 make
15 nm -gC *.so
16 """
17
18 import sys
19 import StringIO
20 import unittest
21
22 import symbolize
23
24 def RunSymbolizer(text):
25 output = StringIO.StringIO()
26 s = symbolize.Symbolizer(StringIO.StringIO(text), output)
27 s.ProcessInput()
28 return output.getvalue()
29
30
31 class SymbolizerUnittest(unittest.TestCase):
32 def testSingleLineNoMatch(self):
33 # Leading '#' is required.
34 expected = '00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
35 self.assertEqual(expected, RunSymbolizer(expected))
36
37 # Whitespace should be exactly one space.
38 expected = '#00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
39 self.assertEqual(expected, RunSymbolizer(expected))
40 expected = '#00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
41 self.assertEqual(expected, RunSymbolizer(expected))
42 expected = '#00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
43 self.assertEqual(expected, RunSymbolizer(expected))
44
45 # Decimal stack frame numbers are required.
46 expected = '#0a pc 00000254 /build/android/tests/symbolize/liba.so\n'
47 self.assertEqual(expected, RunSymbolizer(expected))
48
49 # Lowercase 'pc' token is required.
50 expected = '#00 PC 00000254 /build/android/tests/symbolize/liba.so\n'
51 self.assertEqual(expected, RunSymbolizer(expected))
52
53 # Hexadecimal addresses are required.
54 expected = '#00 pc ghijklmn /build/android/tests/symbolize/liba.so\n'
55 self.assertEqual(expected, RunSymbolizer(expected))
56
57 # Addresses must be exactly 8 characters.
58 expected = '#00 pc 254 /build/android/tests/symbolize/liba.so\n'
59 self.assertEqual(expected, RunSymbolizer(expected))
60 expected = '#00 pc 0254 /build/android/tests/symbolize/liba.so\n'
61 self.assertEqual(expected, RunSymbolizer(expected))
62 expected = '#00 pc 00254 /build/android/tests/symbolize/liba.so\n'
63 self.assertEqual(expected, RunSymbolizer(expected))
64 expected = '#00 pc 000254 /build/android/tests/symbolize/liba.so\n'
65 self.assertEqual(expected, RunSymbolizer(expected))
66 expected = '#00 pc 0000254 /build/android/tests/symbolize/liba.so\n'
67 self.assertEqual(expected, RunSymbolizer(expected))
68
69 # Addresses must not be prefixed with '0x'.
70 expected = '#00 pc 0x00000254 /build/android/tests/symbolize/liba.so\n'
71 self.assertEqual(expected, RunSymbolizer(expected))
72
73 # Library name is required.
74 expected = '#00 pc 00000254\n'
75 self.assertEqual(expected, RunSymbolizer(expected))
76
77 def testSingleLine(self):
78 text = '#00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
79 expected = '#00 pc 00000254 A::Bar(char const*)\n'
80 actual = RunSymbolizer(text)
81 self.assertEqual(expected, actual)
82
83 def testSingleLineWithSurroundingText(self):
84 text = 'LEFT #00 pc 00000254 /build/android/tests/symbolize/liba.so RIGHT\n'
85 expected = 'LEFT #00 pc 00000254 A::Bar(char const*) RIGHT\n'
86 actual = RunSymbolizer(text)
87 self.assertEqual(expected, actual)
88
89 def testMultipleLinesSameLibrary(self):
90 text = '#00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
91 text += '#01 pc 00000234 /build/android/tests/symbolize/liba.so\n'
92 expected = '#00 pc 00000254 A::Bar(char const*)\n'
93 expected += '#01 pc 00000234 A::Foo(int)\n'
94 actual = RunSymbolizer(text)
95 self.assertEqual(expected, actual)
96
97 def testMultipleLinesDifferentLibrary(self):
98 text = '#00 pc 00000254 /build/android/tests/symbolize/liba.so\n'
99 text += '#01 pc 00000234 /build/android/tests/symbolize/libb.so\n'
100 expected = '#00 pc 00000254 A::Bar(char const*)\n'
101 expected += '#01 pc 00000234 B::Baz(float)\n'
102 actual = RunSymbolizer(text)
103 self.assertEqual(expected, actual)
104
105 def testMultipleLinesWithSurroundingTextEverywhere(self):
106 text = 'TOP\n'
107 text += ('LEFT #00 pc 00000254 '
108 '/build/android/tests/symbolize/liba.so RIGHT\n')
109 text += ('LEFT #01 pc 00000234 '
110 '/build/android/tests/symbolize/libb.so RIGHT\n')
111 text += 'BOTTOM\n'
112 expected = 'TOP\n'
113 expected += 'LEFT #00 pc 00000254 A::Bar(char const*) RIGHT\n'
114 expected += 'LEFT #01 pc 00000234 B::Baz(float) RIGHT\n'
115 expected += 'BOTTOM\n'
116 actual = RunSymbolizer(text)
117 self.assertEqual(expected, actual)
118
119
120 if __name__ == '__main__':
121 unittest.main()
OLDNEW
« 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