test_idf_size.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. import collections
  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_memory_config(["Memory Configuration"])
  33. pass
  34. except RuntimeError as e:
  35. assert "End of file" in str(e)
  36. # This used to crash with a division by zero error but now it just prints nan% due to
  37. # zero lengths
  38. MemRegNames = collections.namedtuple('MemRegNames', ['iram_names', 'dram_names', 'diram_names', 'used_iram_names',
  39. 'used_dram_names', 'used_diram_names'])
  40. mem_reg = MemRegNames(set(), set(), set(), set(), set(), set())
  41. print(idf_size.get_summary('a.map', mem_reg, {"iram0_0_seg": {"origin":0,"length":0}, "dram0_0_seg":
  42. {"origin":0, "length":0}}, {}), end="")