| OLD | NEW |
| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 if not IntegrationTest.size_info: | 64 if not IntegrationTest.size_info: |
| 65 lazy_paths = paths.LazyPaths(output_directory=_TEST_DATA_DIR) | 65 lazy_paths = paths.LazyPaths(output_directory=_TEST_DATA_DIR) |
| 66 IntegrationTest.size_info = ( | 66 IntegrationTest.size_info = ( |
| 67 archive.CreateSizeInfo(_TEST_MAP_PATH, lazy_paths)) | 67 archive.CreateSizeInfo(_TEST_MAP_PATH, lazy_paths)) |
| 68 return copy.deepcopy(IntegrationTest.size_info) | 68 return copy.deepcopy(IntegrationTest.size_info) |
| 69 | 69 |
| 70 @_CompareWithGolden | 70 @_CompareWithGolden |
| 71 def test_Archive(self): | 71 def test_Archive(self): |
| 72 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file: | 72 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file: |
| 73 _RunApp('archive', temp_file.name, '--output-directory', _TEST_DATA_DIR, | 73 _RunApp('archive', temp_file.name, '--output-directory', _TEST_DATA_DIR, |
| 74 '--map-file', _TEST_MAP_PATH, '--elf-file', '') | 74 '--map-file', _TEST_MAP_PATH) |
| 75 size_info = archive.LoadAndPostProcessSizeInfo(temp_file.name) | 75 size_info = archive.LoadAndPostProcessSizeInfo(temp_file.name) |
| 76 # Check that saving & loading is the same as directly parsing the .map. | 76 # Check that saving & loading is the same as directly parsing the .map. |
| 77 expected_size_info = self._CloneSizeInfo() | 77 expected_size_info = self._CloneSizeInfo() |
| 78 self.assertEquals(expected_size_info.metadata, size_info.metadata) | 78 self.assertEquals(expected_size_info.metadata, size_info.metadata) |
| 79 expected = '\n'.join(describe.GenerateLines( | 79 expected = '\n'.join(describe.GenerateLines( |
| 80 expected_size_info, verbose=True, recursive=True)), | 80 expected_size_info, verbose=True, recursive=True)), |
| 81 actual = '\n'.join(describe.GenerateLines( | 81 actual = '\n'.join(describe.GenerateLines( |
| 82 size_info, verbose=True, recursive=True)), | 82 size_info, verbose=True, recursive=True)), |
| 83 self.assertEquals(expected, actual) | 83 self.assertEquals(expected, actual) |
| 84 | 84 |
| 85 sym_strs = (repr(sym) for sym in size_info.symbols) | 85 sym_strs = (repr(sym) for sym in size_info.symbols) |
| 86 stats = describe.DescribeSizeInfoCoverage(size_info) | 86 stats = describe.DescribeSizeInfoCoverage(size_info) |
| 87 return itertools.chain(stats, sym_strs) | 87 return itertools.chain(stats, sym_strs) |
| 88 | 88 |
| 89 def test_Archive_NoSourcePaths(self): | 89 def test_Archive_NoSourcePaths(self): |
| 90 # Just tests that it doesn't crash. | 90 # Just tests that it doesn't crash. |
| 91 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file: | 91 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file: |
| 92 _RunApp('archive', temp_file.name, '--no-source-paths', | 92 _RunApp('archive', temp_file.name, '--no-source-paths', |
| 93 '--map-file', _TEST_MAP_PATH, '--elf-file', '') | 93 '--map-file', _TEST_MAP_PATH) |
| 94 archive.LoadAndPostProcessSizeInfo(temp_file.name) | 94 archive.LoadAndPostProcessSizeInfo(temp_file.name) |
| 95 | 95 |
| 96 @_CompareWithGolden | 96 @_CompareWithGolden |
| 97 def test_ConsoleNullDiff(self): | 97 def test_ConsoleNullDiff(self): |
| 98 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file: | 98 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file: |
| 99 file_format.SaveSizeInfo(self._CloneSizeInfo(), temp_file.name) | 99 file_format.SaveSizeInfo(self._CloneSizeInfo(), temp_file.name) |
| 100 return _RunApp('console', '--query', 'Diff(size_info1, size_info2)', | 100 return _RunApp('console', '--query', 'Diff(size_info1, size_info2)', |
| 101 temp_file.name, temp_file.name) | 101 temp_file.name, temp_file.name) |
| 102 | 102 |
| 103 @_CompareWithGolden | 103 @_CompareWithGolden |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 if len(argv) > 1 and argv[1] == '--update': | 145 if len(argv) > 1 and argv[1] == '--update': |
| 146 argv.pop(0) | 146 argv.pop(0) |
| 147 global update_goldens | 147 global update_goldens |
| 148 update_goldens = True | 148 update_goldens = True |
| 149 | 149 |
| 150 unittest.main(argv=argv, verbosity=2) | 150 unittest.main(argv=argv, verbosity=2) |
| 151 | 151 |
| 152 | 152 |
| 153 if __name__ == '__main__': | 153 if __name__ == '__main__': |
| 154 main() | 154 main() |
| OLD | NEW |