Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of OmniWheels by
parse_test.py
00001 import sys 00002 from io import open 00003 from os.path import isfile, join, dirname 00004 import json 00005 00006 import pytest 00007 00008 from tools.memap import MemapParser, _ArmccParser 00009 from copy import deepcopy 00010 00011 00012 PARSED_ARM_DATA = { 00013 "startup/startup.o": {".text": 0xc0}, 00014 "[lib]/c_p.l/__main.o": {".text": 8}, 00015 "irqs/irqs.o": {".text": 0x98}, 00016 "data/data.o": {".data": 0x18, ".bss": 0x198}, 00017 "main.o": {".text": 0x36}, 00018 } 00019 00020 def test_parse_armcc(): 00021 memap = MemapParser() 00022 memap.parse(join(dirname(__file__), "arm.map"), "ARM") 00023 assert memap.modules == PARSED_ARM_DATA 00024 memap.parse(join(dirname(__file__), "arm.map"), "UARM") 00025 assert memap.modules == PARSED_ARM_DATA 00026 00027 PARSED_IAR_DATA = { 00028 "startup/startup.o": {".text": 0xc0}, 00029 "[lib]/d16M_tlf.a/__main.o": {".text": 8}, 00030 "irqs/irqs.o": {".text": 0x98}, 00031 "data/data.o": {".data": 0x18, ".bss": 0x198}, 00032 "main.o": {".text": 0x36}, 00033 } 00034 00035 def test_parse_iar(): 00036 memap = MemapParser() 00037 memap.parse(join(dirname(__file__), "iar.map"), "IAR") 00038 assert memap.modules == PARSED_IAR_DATA 00039 00040 PARSED_GCC_DATA = { 00041 "startup/startup.o": {".text": 0xc0}, 00042 "[lib]/d16M_tlf.a/__main.o": {".text": 8}, 00043 "[lib]/misc/foo.o": {".text": 8}, 00044 "irqs/irqs.o": {".text": 0x98}, 00045 "data/data.o": {".data": 0x18, ".bss": 0x198}, 00046 "main.o": {".text": 0x36}, 00047 } 00048 00049 def test_parse_gcc(): 00050 memap = MemapParser() 00051 memap.parse(join(dirname(__file__), "gcc.map"), "GCC_ARM") 00052 assert memap.modules == PARSED_GCC_DATA 00053 memap.parse(join(dirname(__file__), "gcc.map"), "GCC_CR") 00054 assert memap.modules == PARSED_GCC_DATA 00055 00056 00057 def test_add_empty_module(): 00058 memap = _ArmccParser() 00059 old_modules = deepcopy(memap.modules) 00060 memap.module_add("", 8, ".data") 00061 assert(old_modules == memap.modules) 00062 memap.module_add("main.o", 0, ".text") 00063 assert(old_modules == memap.modules) 00064 memap.module_add("main.o", 8, "") 00065 assert(old_modules == memap.modules) 00066 00067 def test_add_full_module(): 00068 memap = _ArmccParser() 00069 old_modules = deepcopy(memap.modules) 00070 memap.module_add("main.o", 8, ".data") 00071 assert(old_modules != memap.modules) 00072 assert("main.o" in memap.modules) 00073 assert(".data" in memap.modules["main.o"]) 00074 assert(memap.modules["main.o"][".data"] == 8)
Generated on Fri Jul 22 2022 04:53:58 by
 1.7.2
 1.7.2 
    