test_idf_size.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python
  2. #
  3. # Copyright 2018 Espressif Systems (Shanghai) PTE LTD
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. from __future__ import print_function
  17. import sys
  18. from typing import Dict
  19. try:
  20. import idf_size
  21. except ImportError:
  22. sys.path.append('..')
  23. import idf_size
  24. if __name__ == '__main__':
  25. # Should deliver a RuntimeError as the 'test' header doesn't exist
  26. try:
  27. idf_size.scan_to_header([], 'test')
  28. except RuntimeError as e:
  29. assert "Didn't find line" in str(e)
  30. # Should deliver a RuntimeError as there's no content under the heading
  31. try:
  32. idf_size.load_segments(['Memory Configuration'])
  33. pass
  34. except RuntimeError as e:
  35. assert 'End of file' in str(e)
  36. segments = {'iram0_0_seg': {'origin': 0, 'length': 0},
  37. 'dram0_0_seg': {'origin': 0, 'length': 0}}
  38. sections = {} # type: Dict
  39. print(idf_size.get_summary('a.map', segments, sections, 'esp32'), end='')