OLD | NEW |
(Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """Tests for the native crash dump symbolizer utility functions.""" |
| 6 |
| 7 import unittest |
| 8 import stack_utils |
| 9 |
| 10 |
| 11 class StackUtilsTest(unittest.TestCase): |
| 12 """Tests the native crash dump symbolizer utility functions.""" |
| 13 |
| 14 def test_GetSymbolMapping_no_match(self): |
| 15 """Verifies that, if no mapping is on the input, no mapping is on the |
| 16 output. |
| 17 """ |
| 18 lines = ["This is a test case\n", "Caching all mojo apps", ""] |
| 19 self.assertDictEqual({}, stack_utils.GetSymbolMapping(lines)) |
| 20 |
| 21 def test_GetSymbolMapping_simple_match(self): |
| 22 """Verifies a simple symbol mapping.""" |
| 23 lines = ["This is a test case\n", "Caching all mojo apps", |
| 24 "I/mojo(2): [INFO:somefile.cc(85)] Caching mojo app " |
| 25 "https://apps.mojo/myapp.mojo at /path/to/myapp.mojo/.lM03ws"] |
| 26 golden_dict = { |
| 27 "/path/to/myapp.mojo/.lM03ws": "libmyapp_library.so" |
| 28 } |
| 29 actual_dict = stack_utils.GetSymbolMapping(lines) |
| 30 self.assertDictEqual(golden_dict, actual_dict) |
| 31 |
| 32 def test_GetSymbolMapping_multiple_match(self): |
| 33 """Verifies mapping of multiple symbol files.""" |
| 34 lines = ["This is a test case\n", "Caching all mojo apps", |
| 35 "I/mojo(2): [INFO:somefile.cc(85)] Caching mojo app " |
| 36 "https://apps.mojo/myapp.mojo at /path/to/myapp.mojo/.lM03ws", |
| 37 "I/mojo(2): [INFO:somefile.cc(85)] Caching mojo app " |
| 38 "https://apps.mojo/otherapp.mojo at /path/to/otherapp.mojo/.kW07s"] |
| 39 golden_dict = { |
| 40 "/path/to/myapp.mojo/.lM03ws": "libmyapp_library.so", |
| 41 "/path/to/otherapp.mojo/.kW07s": "libotherapp_library.so" |
| 42 } |
| 43 actual_dict = stack_utils.GetSymbolMapping(lines) |
| 44 self.assertDictEqual(golden_dict, actual_dict) |
| 45 |
| 46 def test_GetSymbolMapping_parameter_match(self): |
| 47 """Verifies parameters are stripped from mappings.""" |
| 48 lines = ["This is a test case\n", "Caching all mojo apps", |
| 49 "I/mojo(2): [INFO:somefile.cc(85)] Caching mojo app " |
| 50 "https://apps.mojo/myapp.mojo?q=hello at /path/to/myapp.mojo/.lM03ws"] |
| 51 golden_dict = { |
| 52 "/path/to/myapp.mojo/.lM03ws": "libmyapp_library.so" |
| 53 } |
| 54 actual_dict = stack_utils.GetSymbolMapping(lines) |
| 55 self.assertDictEqual(golden_dict, actual_dict) |
| 56 |
| 57 def test_GetSymbolMapping_normalize(self): |
| 58 """Verifies paths are normalized in mappings.""" |
| 59 lines = ["This is a test case\n", "Caching all mojo apps", |
| 60 "I/mojo(2): [INFO:somefile.cc(85)] Caching mojo app " |
| 61 "https://apps.mojo/myapp.mojo at /path/to/.//myapp.mojo/.lM03ws"] |
| 62 golden_dict = { |
| 63 "/path/to/myapp.mojo/.lM03ws": "libmyapp_library.so" |
| 64 } |
| 65 actual_dict = stack_utils.GetSymbolMapping(lines) |
| 66 self.assertDictEqual(golden_dict, actual_dict) |
| 67 |
| 68 |
| 69 if __name__ == "__main__": |
| 70 unittest.main() |
OLD | NEW |