peg Chromium to legacy Color32 math for now
[chromium-blink-merge.git] / tools / find_runtime_symbols / tests / reduce_debugline_test.py
blob1e3a21afc2ccc0a9828cfa31cfb5f74c74b97eb3
1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 import cStringIO
7 import logging
8 import os
9 import sys
10 import textwrap
11 import unittest
13 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
14 sys.path.insert(0, ROOT_DIR)
16 import reduce_debugline
19 class ReduceDebuglineTest(unittest.TestCase):
20 _DECODED_DEBUGLINE = textwrap.dedent("""\
21 Decoded dump of debug contents of section .debug_line:
23 CU: ../../chrome/service/service_main.cc:
24 File name Line number Starting address
25 service_main.cc 21 0xa41210
27 service_main.cc 24 0xa4141f
28 service_main.cc 30 0xa4142b
29 service_main.cc 31 0xa4143e
31 ../../base/message_loop.h:
32 message_loop.h 550 0xa41300
34 message_loop.h 551 0xa41310
36 ../../base/logging.h:
37 logging.h 246 0xa41710
39 logging.h 247 0xa41726
41 ../../base/logging.h:
42 logging.h 846 0xa3fd90
44 logging.h 846 0xa3fda0
46 """)
48 _EXPECTED_REDUCED_DEBUGLINE = [
49 (0xa3fd90, '../../base/logging.h'),
50 (0xa41210, '../../chrome/service/service_main.cc'),
51 (0xa41300, '../../base/message_loop.h'),
52 (0xa4141f, '../../chrome/service/service_main.cc'),
53 (0xa41710, '../../base/logging.h'),
56 def test(self):
57 ranges_dict = reduce_debugline.reduce_decoded_debugline(
58 cStringIO.StringIO(self._DECODED_DEBUGLINE))
59 self.assertEqual(self._EXPECTED_REDUCED_DEBUGLINE, ranges_dict)
62 if __name__ == '__main__':
63 logging.basicConfig(
64 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR,
65 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s')
66 unittest.main()