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

Side by Side Diff: tools/cygprofile/patch_orderfile_unittest.py

Issue 859303005: Only include unique lines when patching orderfile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from pasko Created 5 years, 11 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
« no previous file with comments | « tools/cygprofile/patch_orderfile.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import patch_orderfile 6 import patch_orderfile
7 import unittest 7 import unittest
8 8
9 9
10 class TestPatchOrderFile(unittest.TestCase): 10 class TestPatchOrderFile(unittest.TestCase):
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 self.assertEquals(len(offset_to_symbol_infos[test_offset]), 1) 60 self.assertEquals(len(offset_to_symbol_infos[test_offset]), 1)
61 s = offset_to_symbol_infos[test_offset][0] 61 s = offset_to_symbol_infos[test_offset][0]
62 self.assertEquals(test_offset, s.offset) 62 self.assertEquals(test_offset, s.offset)
63 self.assertEquals(-1, s.size) 63 self.assertEquals(-1, s.size)
64 self.assertEquals(test_name, s.name) 64 self.assertEquals(test_name, s.name)
65 65
66 def testGetSymbolsFromStream(self): 66 def testGetSymbolsFromStream(self):
67 lines = [".text.startup.", 67 lines = [".text.startup.",
68 ".text.with.a.prefix", 68 ".text.with.a.prefix",
69 "_ZN2v88internal33HEnvironmentLivenessAnalysisPhase3RunEv"] 69 "",
70 "_ZN2v88internal33HEnvironmentLivenessAnalysisPhase3RunEv",
71 ".text",
72 ".text.*"]
70 names = patch_orderfile._GetSymbolsFromStream(lines) 73 names = patch_orderfile._GetSymbolsFromStream(lines)
71 self.assertEquals(len(names), 2) 74 self.assertEquals(len(names), 2)
72 self.assertEquals( 75 self.assertEquals(
73 names[0], "with.a.prefix") 76 names[0], "with.a.prefix")
74 self.assertEquals( 77 self.assertEquals(
75 names[1], "_ZN2v88internal33HEnvironmentLivenessAnalysisPhase3RunEv") 78 names[1], "_ZN2v88internal33HEnvironmentLivenessAnalysisPhase3RunEv")
76 79
77 80
78 def testMatchProfiledSymbols(self): 81 def testMatchProfiledSymbols(self):
79 symbol_name = "dummySymbol" 82 symbol_name = "dummySymbol"
(...skipping 14 matching lines...) Expand all
94 patch_orderfile.SymbolInfo(0x42, 0x12, symbol_name2)]} 97 patch_orderfile.SymbolInfo(0x42, 0x12, symbol_name2)]}
95 symbol_names = patch_orderfile._ExpandSymbolsWithDupsFromSameOffset( 98 symbol_names = patch_orderfile._ExpandSymbolsWithDupsFromSameOffset(
96 symbols, offset_to_symbol_infos) 99 symbols, offset_to_symbol_infos)
97 self.assertEquals(len(symbol_names), 2) 100 self.assertEquals(len(symbol_names), 2)
98 self.assertEquals(symbol_names[0], symbol_name) 101 self.assertEquals(symbol_names[0], symbol_name)
99 self.assertEquals(symbol_names[1], symbol_name2) 102 self.assertEquals(symbol_names[1], symbol_name2)
100 103
101 def testPrintSymbolWithPrefixes(self): 104 def testPrintSymbolWithPrefixes(self):
102 class FakeOutputFile(object): 105 class FakeOutputFile(object):
103 def __init__(self): 106 def __init__(self):
104 self.output = [] 107 self.output = ''
105 def write(self, s): 108 def write(self, s):
106 self.output.append(s) 109 self.output = self.output + s
107 test_symbol = "dummySymbol" 110 test_symbol = "dummySymbol"
108 symbol_names = [test_symbol] 111 symbol_names = [test_symbol]
109 fake_output = FakeOutputFile() 112 fake_output = FakeOutputFile()
110 patch_orderfile._PrintSymbolsWithPrefixes(symbol_names, fake_output) 113 patch_orderfile._PrintSymbolsWithPrefixes(symbol_names, fake_output)
111 expected_output = """.text.startup.dummySymbol 114 expected_output = """.text.startup.dummySymbol
112 .text.hot.dummySymbol 115 .text.hot.dummySymbol
113 .text.unlikely.dummySymbol 116 .text.unlikely.dummySymbol
114 .text.dummySymbol 117 .text.dummySymbol
115 """ 118 """
116 self.assertEquals("\n".join(fake_output.output), expected_output) 119 self.assertEquals(fake_output.output, expected_output)
117 120
118 121
119 if __name__ == "__main__": 122 if __name__ == "__main__":
120 unittest.main() 123 unittest.main()
OLDNEW
« no previous file with comments | « tools/cygprofile/patch_orderfile.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698