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

Side by Side Diff: tools/binary_size/integration_test.py

Issue 2791433004: //tools/binary_size: source_path information, change file format, fixes (Closed)
Patch Set: fix comment for _DetectToolPrefix Created 3 years, 8 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/binary_size/file_format.py ('k') | tools/binary_size/linker_map_parser.py » ('j') | 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/env python 1 #!/usr/bin/env python
2 # Copyright 2017 The Chromium Authors. All rights reserved. 2 # Copyright 2017 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 copy 6 import copy
7 import difflib 7 import difflib
8 import itertools 8 import itertools
9 import logging 9 import logging
10 import os 10 import os
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 argv = [os.path.join(_SCRIPT_DIR, name), '--no-pypy'] 53 argv = [os.path.join(_SCRIPT_DIR, name), '--no-pypy']
54 argv.extend(args) 54 argv.extend(args)
55 return subprocess.check_output(argv).splitlines() 55 return subprocess.check_output(argv).splitlines()
56 56
57 57
58 class IntegrationTest(unittest.TestCase): 58 class IntegrationTest(unittest.TestCase):
59 size_info = None 59 size_info = None
60 60
61 def _GetParsedMap(self): 61 def _GetParsedMap(self):
62 if not IntegrationTest.size_info: 62 if not IntegrationTest.size_info:
63 IntegrationTest.size_info = map2size.Analyze(_TEST_MAP_PATH) 63 IntegrationTest.size_info = map2size.Analyze(
64 _TEST_MAP_PATH, output_directory=_TEST_DATA_DIR)
64 return copy.deepcopy(IntegrationTest.size_info) 65 return copy.deepcopy(IntegrationTest.size_info)
65 66
66 @_CompareWithGolden 67 @_CompareWithGolden
67 def test_Map2Size(self): 68 def test_Map2Size(self):
68 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file: 69 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file:
69 _RunApp('map2size.py', _TEST_MAP_PATH, temp_file.name) 70 _RunApp('map2size.py', '--output-directory', _TEST_DATA_DIR,
71 _TEST_MAP_PATH, temp_file.name)
70 size_info = map2size.Analyze(temp_file.name) 72 size_info = map2size.Analyze(temp_file.name)
71 sym_strs = (repr(sym) for sym in size_info.symbols) 73 sym_strs = (repr(sym) for sym in size_info.symbols)
72 stats = describe.DescribeSizeInfoCoverage(size_info) 74 stats = describe.DescribeSizeInfoCoverage(size_info)
73 return itertools.chain(stats, sym_strs) 75 return itertools.chain(stats, sym_strs)
74 76
75 @_CompareWithGolden 77 @_CompareWithGolden
76 def test_ConsoleNullDiff(self): 78 def test_ConsoleNullDiff(self):
77 return _RunApp('console.py', '--query', 'Diff(size_info1, size_info2)', 79 return _RunApp('console.py', '--output-directory', _TEST_DATA_DIR,
80 '--query', 'Diff(size_info1, size_info2)',
78 _TEST_MAP_PATH, _TEST_MAP_PATH) 81 _TEST_MAP_PATH, _TEST_MAP_PATH)
79 82
80 @_CompareWithGolden 83 @_CompareWithGolden
81 def test_ActualDiff(self): 84 def test_ActualDiff(self):
82 map1 = self._GetParsedMap() 85 map1 = self._GetParsedMap()
83 map2 = self._GetParsedMap() 86 map2 = self._GetParsedMap()
84 map1.symbols.symbols.pop(-1) 87 map1.symbols.symbols.pop(-1)
85 map2.symbols.symbols.pop(0) 88 map2.symbols.symbols.pop(0)
86 map1.symbols[1].size -= 10 89 map1.symbols[1].size -= 10
87 diff = models.Diff(map1, map2) 90 diff = models.Diff(map1, map2)
88 return describe.GenerateLines(diff) 91 return describe.GenerateLines(diff)
89 92
93 @_CompareWithGolden
90 def test_SymbolGroupMethods(self): 94 def test_SymbolGroupMethods(self):
91 all_syms = self._GetParsedMap().symbols 95 all_syms = self._GetParsedMap().symbols
92 global_syms = all_syms.WhereNameMatches('GLOBAL') 96 global_syms = all_syms.WhereNameMatches('GLOBAL')
93 # Tests Filter(), Inverted(), and __sub__(). 97 # Tests Filter(), Inverted(), and __sub__().
94 non_global_syms = global_syms.Inverted() 98 non_global_syms = global_syms.Inverted()
95 self.assertEqual(non_global_syms.symbols, (all_syms - global_syms).symbols) 99 self.assertEqual(non_global_syms.symbols, (all_syms - global_syms).symbols)
96 # Tests Sorted() and __add__(). 100 # Tests Sorted() and __add__().
97 self.assertEqual(all_syms.Sorted().symbols, 101 self.assertEqual(all_syms.Sorted().symbols,
98 (global_syms + non_global_syms).Sorted().symbols) 102 (global_syms + non_global_syms).Sorted().symbols)
99 # Tests GroupByPath() and __len__(). 103 # Tests GroupByNamespace() and __len__().
100 self.assertEqual(6, len(all_syms.GroupByPath())) 104 return itertools.chain(
105 ['GroupByNamespace()'],
106 describe.GenerateLines(all_syms.GroupByNamespace()),
107 ['GroupByNamespace(depth=1)'],
108 describe.GenerateLines(all_syms.GroupByNamespace(depth=1)),
109 ['GroupByNamespace(depth=1, fallback=None)'],
110 describe.GenerateLines(all_syms.GroupByNamespace(depth=1,
111 fallback=None)),
112 ['GroupByNamespace(depth=1, min_count=2)'],
113 describe.GenerateLines(all_syms.GroupByNamespace(depth=1, min_count=2)),
114 )
101 115
102 116
103 def main(): 117 def main():
104 argv = sys.argv 118 argv = sys.argv
105 if len(argv) > 1 and argv[1] == '--update': 119 if len(argv) > 1 and argv[1] == '--update':
106 argv.pop(0) 120 argv.pop(0)
107 global update_goldens 121 global update_goldens
108 update_goldens = True 122 update_goldens = True
109 123
110 unittest.main(argv=argv, verbosity=2) 124 unittest.main(argv=argv, verbosity=2)
111 125
112 126
113 if __name__ == '__main__': 127 if __name__ == '__main__':
114 main() 128 main()
OLDNEW
« no previous file with comments | « tools/binary_size/file_format.py ('k') | tools/binary_size/linker_map_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698