/chromium-webcl/src/tools/find_runtime_symbols/tests/reduce_debugline_test.py

https://bitbucket.org/peixuan/chromium_r197479_base
Python | 66 lines | 53 code | 9 blank | 4 comment | 3 complexity | bde81a4c9e7800ffe0c7c31a950286d0 MD5 | raw file
  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.
  5. import cStringIO
  6. import logging
  7. import os
  8. import sys
  9. import textwrap
  10. import unittest
  11. ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  12. sys.path.insert(0, ROOT_DIR)
  13. import reduce_debugline
  14. class ReduceDebuglineTest(unittest.TestCase):
  15. _DECODED_DEBUGLINE = textwrap.dedent("""\
  16. Decoded dump of debug contents of section .debug_line:
  17. CU: ../../chrome/service/service_main.cc:
  18. File name Line number Starting address
  19. service_main.cc 21 0xa41210
  20. service_main.cc 24 0xa4141f
  21. service_main.cc 30 0xa4142b
  22. service_main.cc 31 0xa4143e
  23. ../../base/message_loop.h:
  24. message_loop.h 550 0xa41300
  25. message_loop.h 551 0xa41310
  26. ../../base/logging.h:
  27. logging.h 246 0xa41710
  28. logging.h 247 0xa41726
  29. ../../base/logging.h:
  30. logging.h 846 0xa3fd90
  31. logging.h 846 0xa3fda0
  32. """)
  33. _EXPECTED_REDUCED_DEBUGLINE = [
  34. (0xa3fd90, '../../base/logging.h'),
  35. (0xa41210, '../../chrome/service/service_main.cc'),
  36. (0xa41300, '../../base/message_loop.h'),
  37. (0xa4141f, '../../chrome/service/service_main.cc'),
  38. (0xa41710, '../../base/logging.h'),
  39. ]
  40. def test(self):
  41. ranges_dict = reduce_debugline.reduce_decoded_debugline(
  42. cStringIO.StringIO(self._DECODED_DEBUGLINE))
  43. self.assertEqual(self._EXPECTED_REDUCED_DEBUGLINE, ranges_dict)
  44. if __name__ == '__main__':
  45. logging.basicConfig(
  46. level=logging.DEBUG if '-v' in sys.argv else logging.ERROR,
  47. format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s')
  48. unittest.main()