mbed-os
Dependents: cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more
tools/test/toolchains/arm_support_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 | """Tests for the arm toolchain supported checks""" |
be_bryan | 0:b74591d5ab33 | 2 | import sys |
be_bryan | 0:b74591d5ab33 | 3 | import os |
be_bryan | 0:b74591d5ab33 | 4 | from string import printable |
be_bryan | 0:b74591d5ab33 | 5 | from copy import deepcopy |
be_bryan | 0:b74591d5ab33 | 6 | from mock import MagicMock, patch |
be_bryan | 0:b74591d5ab33 | 7 | from hypothesis import given, settings |
be_bryan | 0:b74591d5ab33 | 8 | from hypothesis.strategies import text, lists, sampled_from |
be_bryan | 0:b74591d5ab33 | 9 | |
be_bryan | 0:b74591d5ab33 | 10 | ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", |
be_bryan | 0:b74591d5ab33 | 11 | "..")) |
be_bryan | 0:b74591d5ab33 | 12 | sys.path.insert(0, ROOT) |
be_bryan | 0:b74591d5ab33 | 13 | |
be_bryan | 0:b74591d5ab33 | 14 | from tools.toolchains.arm import ARM_STD, ARM_MICRO, ARMC6 |
be_bryan | 0:b74591d5ab33 | 15 | from tools.utils import NotSupportedException |
be_bryan | 0:b74591d5ab33 | 16 | |
be_bryan | 0:b74591d5ab33 | 17 | ARMC5_CORES = ["Cortex-M0", "Cortex-M0+", "Cortex-M3", "Cortex-M4", |
be_bryan | 0:b74591d5ab33 | 18 | "Cortex-M4F", "Cortex-M7", "Cortex-M7F", "Cortex-M7FD"] |
be_bryan | 0:b74591d5ab33 | 19 | ARMC6_CORES = ARMC5_CORES + ["Cortex-M23", "Cortex-M23-NS", |
be_bryan | 0:b74591d5ab33 | 20 | "Cortex-M33", "CortexM33-NS"] |
be_bryan | 0:b74591d5ab33 | 21 | |
be_bryan | 0:b74591d5ab33 | 22 | CORE_SUF_ALPHA = ["MDFNS02347-+"] |
be_bryan | 0:b74591d5ab33 | 23 | |
be_bryan | 0:b74591d5ab33 | 24 | @given(lists(sampled_from(["ARM", "uARM", "GCC_ARM", "ARMC6", "IAR", "GARBAGE"])), |
be_bryan | 0:b74591d5ab33 | 25 | text(alphabet=CORE_SUF_ALPHA)) |
be_bryan | 0:b74591d5ab33 | 26 | def test_arm_std(supported_toolchains, core): |
be_bryan | 0:b74591d5ab33 | 27 | mock_target = MagicMock() |
be_bryan | 0:b74591d5ab33 | 28 | mock_target.core = "Cortex-" + core |
be_bryan | 0:b74591d5ab33 | 29 | mock_target.supported_toolchains = supported_toolchains |
be_bryan | 0:b74591d5ab33 | 30 | try: |
be_bryan | 0:b74591d5ab33 | 31 | ARM_STD(mock_target) |
be_bryan | 0:b74591d5ab33 | 32 | assert "ARM" in supported_toolchains |
be_bryan | 0:b74591d5ab33 | 33 | assert mock_target.core in ARMC5_CORES |
be_bryan | 0:b74591d5ab33 | 34 | except NotSupportedException: |
be_bryan | 0:b74591d5ab33 | 35 | assert "ARM" not in supported_toolchains or mock_target.core not in ARMC5_CORES |
be_bryan | 0:b74591d5ab33 | 36 | |
be_bryan | 0:b74591d5ab33 | 37 | |
be_bryan | 0:b74591d5ab33 | 38 | @given(lists(sampled_from(["ARM", "uARM", "GCC_ARM", "ARMC6", "IAR", "GARBAGE"])), |
be_bryan | 0:b74591d5ab33 | 39 | text(alphabet=CORE_SUF_ALPHA)) |
be_bryan | 0:b74591d5ab33 | 40 | def test_arm_micro(supported_toolchains, core): |
be_bryan | 0:b74591d5ab33 | 41 | mock_target = MagicMock() |
be_bryan | 0:b74591d5ab33 | 42 | mock_target.core = "Cortex-" + core |
be_bryan | 0:b74591d5ab33 | 43 | mock_target.supported_toolchains = supported_toolchains |
be_bryan | 0:b74591d5ab33 | 44 | try: |
be_bryan | 0:b74591d5ab33 | 45 | ARM_MICRO(mock_target) |
be_bryan | 0:b74591d5ab33 | 46 | assert "ARM" in supported_toolchains or "uARM" in supported_toolchains |
be_bryan | 0:b74591d5ab33 | 47 | assert mock_target.core in ARMC5_CORES |
be_bryan | 0:b74591d5ab33 | 48 | except NotSupportedException: |
be_bryan | 0:b74591d5ab33 | 49 | assert ("ARM" not in supported_toolchains and "uARM" not in supported_toolchains)\ |
be_bryan | 0:b74591d5ab33 | 50 | or mock_target.core not in ARMC5_CORES |
be_bryan | 0:b74591d5ab33 | 51 | |
be_bryan | 0:b74591d5ab33 | 52 | |
be_bryan | 0:b74591d5ab33 | 53 | @given(lists(sampled_from(["ARM", "uARM", "GCC_ARM", "ARMC6", "IAR", "GARBAGE"])), |
be_bryan | 0:b74591d5ab33 | 54 | text(alphabet=CORE_SUF_ALPHA)) |
be_bryan | 0:b74591d5ab33 | 55 | def test_armc6(supported_toolchains, core): |
be_bryan | 0:b74591d5ab33 | 56 | mock_target = MagicMock() |
be_bryan | 0:b74591d5ab33 | 57 | mock_target.core = "Cortex-" + core |
be_bryan | 0:b74591d5ab33 | 58 | mock_target.supported_toolchains = supported_toolchains |
be_bryan | 0:b74591d5ab33 | 59 | try: |
be_bryan | 0:b74591d5ab33 | 60 | ARMC6(mock_target) |
be_bryan | 0:b74591d5ab33 | 61 | assert "ARM" in supported_toolchains or "ARMC6" in supported_toolchains |
be_bryan | 0:b74591d5ab33 | 62 | assert mock_target.core in ARMC6_CORES |
be_bryan | 0:b74591d5ab33 | 63 | except NotSupportedException: |
be_bryan | 0:b74591d5ab33 | 64 | assert ("ARM" not in supported_toolchains and "ARMC6" not in supported_toolchains)\ |
be_bryan | 0:b74591d5ab33 | 65 | or mock_target.core not in ARMC6_CORES |