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 17from __future__ import print_function 18 19import collections 20import sys 21 22try: 23 import idf_size 24except ImportError: 25 sys.path.append('..') 26 import idf_size 27 28 29if __name__ == '__main__': 30 # Should deliver a RuntimeError as the 'test' header doesn't exist 31 try: 32 idf_size.scan_to_header([], 'test') 33 except RuntimeError as e: 34 assert "Didn't find line" in str(e) 35 36 # Should deliver a RuntimeError as there's no content under the heading 37 try: 38 idf_size.load_memory_config(['Memory Configuration']) 39 pass 40 except RuntimeError as e: 41 assert 'End of file' in str(e) 42 43 # This used to crash with a division by zero error but now it just prints nan% due to 44 # zero lengths 45 MemRegNames = collections.namedtuple('MemRegNames', ['iram_names', 'dram_names', 'diram_names', 'used_iram_names', 46 'used_dram_names', 'used_diram_names']) 47 mem_reg = MemRegNames(set(), set(), set(), set(), set(), set()) 48 49 print(idf_size.get_summary('a.map', mem_reg, {'iram0_0_seg': {'origin':0,'length':0}, 'dram0_0_seg': 50 {'origin':0, 'length':0}}, {}), end='') 51