mbed-os
Dependents: cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more
tools/test/memap/parse_test.py@0:b74591d5ab33, 2017-12-11 (annotated)
- Committer:
- be_bryan
- Date:
- Mon Dec 11 17:54:04 2017 +0000
- Revision:
- 0:b74591d5ab33
motor ++
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
be_bryan | 0:b74591d5ab33 | 1 | import sys |
be_bryan | 0:b74591d5ab33 | 2 | from io import open |
be_bryan | 0:b74591d5ab33 | 3 | from os.path import isfile, join, dirname |
be_bryan | 0:b74591d5ab33 | 4 | import json |
be_bryan | 0:b74591d5ab33 | 5 | |
be_bryan | 0:b74591d5ab33 | 6 | import pytest |
be_bryan | 0:b74591d5ab33 | 7 | |
be_bryan | 0:b74591d5ab33 | 8 | from tools.memap import MemapParser |
be_bryan | 0:b74591d5ab33 | 9 | from copy import deepcopy |
be_bryan | 0:b74591d5ab33 | 10 | |
be_bryan | 0:b74591d5ab33 | 11 | |
be_bryan | 0:b74591d5ab33 | 12 | PARSED_ARM_DATA = { |
be_bryan | 0:b74591d5ab33 | 13 | "startup/startup.o": {".text": 0xc0}, |
be_bryan | 0:b74591d5ab33 | 14 | "[lib]/c_p.l/__main.o": {".text": 8}, |
be_bryan | 0:b74591d5ab33 | 15 | "irqs/irqs.o": {".text": 0x98}, |
be_bryan | 0:b74591d5ab33 | 16 | "data/data.o": {".data": 0x18, ".bss": 0x198}, |
be_bryan | 0:b74591d5ab33 | 17 | "main.o": {".text": 0x36}, |
be_bryan | 0:b74591d5ab33 | 18 | } |
be_bryan | 0:b74591d5ab33 | 19 | |
be_bryan | 0:b74591d5ab33 | 20 | def test_parse_armcc(): |
be_bryan | 0:b74591d5ab33 | 21 | memap = MemapParser() |
be_bryan | 0:b74591d5ab33 | 22 | memap.parse_map_file_armcc(open(join(dirname(__file__), "arm.map"))) |
be_bryan | 0:b74591d5ab33 | 23 | assert memap.modules == PARSED_ARM_DATA |
be_bryan | 0:b74591d5ab33 | 24 | |
be_bryan | 0:b74591d5ab33 | 25 | PARSED_IAR_GCC_DATA = { |
be_bryan | 0:b74591d5ab33 | 26 | "startup/startup.o": {".text": 0xc0}, |
be_bryan | 0:b74591d5ab33 | 27 | "[lib]/d16M_tlf.a/__main.o": {".text": 8}, |
be_bryan | 0:b74591d5ab33 | 28 | "irqs/irqs.o": {".text": 0x98}, |
be_bryan | 0:b74591d5ab33 | 29 | "data/data.o": {".data": 0x18, ".bss": 0x198}, |
be_bryan | 0:b74591d5ab33 | 30 | "main.o": {".text": 0x36}, |
be_bryan | 0:b74591d5ab33 | 31 | } |
be_bryan | 0:b74591d5ab33 | 32 | |
be_bryan | 0:b74591d5ab33 | 33 | def test_parse_iar(): |
be_bryan | 0:b74591d5ab33 | 34 | memap = MemapParser() |
be_bryan | 0:b74591d5ab33 | 35 | memap.parse_map_file_iar(open(join(dirname(__file__), "iar.map"))) |
be_bryan | 0:b74591d5ab33 | 36 | assert memap.modules == PARSED_IAR_GCC_DATA |
be_bryan | 0:b74591d5ab33 | 37 | |
be_bryan | 0:b74591d5ab33 | 38 | def test_parse_gcc(): |
be_bryan | 0:b74591d5ab33 | 39 | memap = MemapParser() |
be_bryan | 0:b74591d5ab33 | 40 | memap.parse_map_file_gcc(open(join(dirname(__file__), "gcc.map"))) |
be_bryan | 0:b74591d5ab33 | 41 | assert memap.modules == PARSED_IAR_GCC_DATA |
be_bryan | 0:b74591d5ab33 | 42 | |
be_bryan | 0:b74591d5ab33 | 43 | |
be_bryan | 0:b74591d5ab33 | 44 | def test_add_empty_module(): |
be_bryan | 0:b74591d5ab33 | 45 | memap = MemapParser() |
be_bryan | 0:b74591d5ab33 | 46 | old_modules = deepcopy(memap.modules) |
be_bryan | 0:b74591d5ab33 | 47 | memap.module_add("", 8, ".data") |
be_bryan | 0:b74591d5ab33 | 48 | assert(old_modules == memap.modules) |
be_bryan | 0:b74591d5ab33 | 49 | memap.module_add("main.o", 0, ".text") |
be_bryan | 0:b74591d5ab33 | 50 | assert(old_modules == memap.modules) |
be_bryan | 0:b74591d5ab33 | 51 | memap.module_add("main.o", 8, "") |
be_bryan | 0:b74591d5ab33 | 52 | assert(old_modules == memap.modules) |
be_bryan | 0:b74591d5ab33 | 53 | |
be_bryan | 0:b74591d5ab33 | 54 | def test_add_full_module(): |
be_bryan | 0:b74591d5ab33 | 55 | memap = MemapParser() |
be_bryan | 0:b74591d5ab33 | 56 | old_modules = deepcopy(memap.modules) |
be_bryan | 0:b74591d5ab33 | 57 | memap.module_add("main.o", 8, ".data") |
be_bryan | 0:b74591d5ab33 | 58 | assert(old_modules != memap.modules) |
be_bryan | 0:b74591d5ab33 | 59 | assert("main.o" in memap.modules) |
be_bryan | 0:b74591d5ab33 | 60 | assert(".data" in memap.modules["main.o"]) |
be_bryan | 0:b74591d5ab33 | 61 | assert(memap.modules["main.o"][".data"] == 8) |