Skip to content

Commit 3a2f58e

Browse files
committed
Test the supported check in the ARM toolchains
They fail right now, Cores are not checked
1 parent 4673fb6 commit 3a2f58e

File tree

1 file changed

+65
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)