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.
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
37 logging.h 246 0xa41710
39 logging.h 247 0xa41726
42 logging.h 846 0xa3fd90
44 logging.h 846 0xa3fda0
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'),
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__':
64 level
=logging
.DEBUG
if '-v' in sys
.argv
else logging
.ERROR
,
65 format
='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s')