Skip to content

Commit c174ca3

Browse files
committed
Test and correct ARMCC version check
1 parent 0e56c18 commit c174ca3

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

tools/test/toolchains/api_test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@
1818

1919
ALPHABET = [char for char in printable if char not in [u'.', u'/', u'\\']]
2020

21+
@patch('tools.toolchains.arm.run_cmd')
22+
def test_arm_version_check(_run_cmd):
23+
_run_cmd.return_value = ("""
24+
Product: ARM Compiler 5.06
25+
Component: ARM Compiler 5.06 update 5 (build 528)
26+
Tool: armcc [4d3621]
27+
""", "", 0)
28+
notifier = MockNotifier()
29+
toolchain = TOOLCHAIN_CLASSES["ARM"](TARGET_MAP["K64F"], notify=notifier)
30+
toolchain.version_check()
31+
assert notifier.messages == []
32+
_run_cmd.return_value = ("""
33+
Product: ARM Compiler
34+
Component: ARM Compiler
35+
Tool: armcc [4d3621]
36+
""", "", 0)
37+
toolchain.version_check()
38+
assert len(notifier.messages) == 1
39+
2140
@given(fixed_dictionaries({
2241
'common': lists(text()),
2342
'c': lists(text()),

tools/toolchains/arm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ def version_check(self):
9999
msg = None
100100
min_ver, max_ver = self.ARMCC_RANGE
101101
match = self.ARMCC_VERSION_RE.search(stdout)
102-
found_version = LooseVersion(match.group(0)) if match else None
103-
min_ver, max_ver = self.ARM_RANGE
102+
found_version = LooseVersion(match.group(1)) if match else None
103+
min_ver, max_ver = self.ARMCC_RANGE
104104
if found_version and (found_version < min_ver or found_version >= max_ver):
105105
msg = ("Compiler version mismatch: Have {}; "
106106
"expected version >= {} and < {}"

0 commit comments

Comments
 (0)