Skip to content

Commit 7490b1c

Browse files
committed
Api tests modification and uLib related fixes
1 parent 50eb4f9 commit 7490b1c

File tree

4 files changed

+52
-17
lines changed

4 files changed

+52
-17
lines changed

platform/mbed_retarget.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ static SingletonPtr<PlatformMutex> _mutex;
5555
# define PREFIX(x) _sys##x
5656
# define OPEN_MAX _SYS_OPEN
5757
# ifdef __MICROLIB
58-
# pragma import(__use_full_stdio)
58+
# if __ARMCC_VERSION >= 6010050
59+
asm(" .global __use_full_stdio\n");
60+
# else
61+
# pragma import(__use_full_stdio)
62+
# endif
5963
# endif
6064

6165
#elif defined(__ICCARM__)

tools/build_api.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def get_toolchain_name(target, toolchain_name):
130130
if toolchain_name == "ARM":
131131
return "ARM" #note that returning ARM here means, use ARMC5 toolchain
132132
else:
133-
return None #ARMC6 explicitly specified by user, but target doesnt seem to support ARMC6, so return error.
133+
return "ARMC6" #ARMC6 explicitly specified by user, try ARMC6 anyway although the target doesnt explicitly specify ARMC6, as ARMC6 is our default ARM toolchain
134134
elif toolchain_name == "uARM":
135135
if ("ARMC5" in target.supported_toolchains):
136136
return "uARM" #use ARM_MICRO to use AC5+microlib
@@ -343,8 +343,7 @@ def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
343343
target.name, toolchain_name))
344344

345345
toolchain_name = get_toolchain_name(target, toolchain_name)
346-
notify.debug("Selected toolchain: %s" % (toolchain_name))
347-
346+
348347
try:
349348
cur_tc = TOOLCHAIN_CLASSES[toolchain_name]
350349
except KeyError:

tools/test/toolchains/api_test.py

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,28 @@
4141

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

44+
#Create a global test target
45+
test_target_map = TARGET_MAP["K64F"]
46+
#We have to add ARMC5,UARM here to supported_toolchains, otherwise the creation of ARM class would fail as it won't find ARMC5 entry in supported_toolchains
47+
#We also have to add uARM, cause, ARM_MICRO class would check for both uARM and ARMC5 in supported_toolchains(as ARM_MICRO represents ARMC5+Micro).
48+
#And do this globally here so all tests can use this
49+
test_target_map.supported_toolchains.append("ARMC5")
50+
test_target_map.supported_toolchains.append("uARM")
51+
4452

4553
@patch('tools.toolchains.arm.run_cmd')
46-
def test_arm_version_check(_run_cmd):
54+
def test_armc5_version_check(_run_cmd):
4755
set_targets_json_location()
4856
_run_cmd.return_value = ("""
4957
Product: ARM Compiler 5.06
5058
Component: ARM Compiler 5.06 update 5 (build 528)
5159
Tool: armcc [4d3621]
5260
""", "", 0)
5361
notifier = MockNotifier()
54-
toolchain = TOOLCHAIN_CLASSES["ARM"](TARGET_MAP["K64F"], notify=notifier)
62+
target_map = TARGET_MAP["K64F"]
63+
#We have to add ARMC5 here to supported_toolchains, otherwise the creation of ARM class would fail as it wont find ARMC5 entry in supported_toolchains
64+
target_map.supported_toolchains.append("ARMC5")
65+
toolchain = TOOLCHAIN_CLASSES["ARM"](target_map, notify=notifier)
5566
toolchain.version_check()
5667
assert notifier.messages == []
5768
_run_cmd.return_value = ("""
@@ -69,6 +80,20 @@ def test_arm_version_check(_run_cmd):
6980
toolchain.version_check()
7081
assert len(notifier.messages) == 1
7182

83+
@patch('tools.toolchains.arm.run_cmd')
84+
def test_armc6_version_check(_run_cmd):
85+
set_targets_json_location()
86+
notifier = MockNotifier()
87+
print(TARGET_MAP["K64F"])
88+
toolchain = TOOLCHAIN_CLASSES["ARMC6"](TARGET_MAP["K64F"], notify=notifier)
89+
print(toolchain)
90+
_run_cmd.return_value = ("""
91+
Product: ARM Compiler 6.11 Professional
92+
Component: ARM Compiler 6.11
93+
Tool: armclang [5d3b4200]
94+
""", "", 0)
95+
toolchain.version_check()
96+
assert notifier.messages == []
7297

7398
@patch('tools.toolchains.iar.run_cmd')
7499
def test_iar_version_check(_run_cmd):
@@ -141,7 +166,7 @@ def test_toolchain_profile_c(profile, source_file):
141166
set_targets_json_location()
142167
with patch('os.mkdir') as _mkdir:
143168
for _, tc_class in TOOLCHAIN_CLASSES.items():
144-
toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile,
169+
toolchain = tc_class(test_target_map, build_profile=profile,
145170
notify=MockNotifier())
146171
toolchain.inc_md5 = ""
147172
toolchain.build_dir = ""
@@ -173,7 +198,7 @@ def test_toolchain_profile_cpp(profile, source_file):
173198
to_compile = os.path.join(*filename)
174199
with patch('os.mkdir') as _mkdir:
175200
for _, tc_class in TOOLCHAIN_CLASSES.items():
176-
toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile,
201+
toolchain = tc_class(test_target_map, build_profile=profile,
177202
notify=MockNotifier())
178203
toolchain.inc_md5 = ""
179204
toolchain.build_dir = ""
@@ -205,7 +230,7 @@ def test_toolchain_profile_asm(profile, source_file):
205230
to_compile = os.path.join(*filename)
206231
with patch('os.mkdir') as _mkdir:
207232
for _, tc_class in TOOLCHAIN_CLASSES.items():
208-
toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile,
233+
toolchain = tc_class(test_target_map, build_profile=profile,
209234
notify=MockNotifier())
210235
toolchain.inc_md5 = ""
211236
toolchain.build_dir = ""
@@ -225,7 +250,7 @@ def test_toolchain_profile_asm(profile, source_file):
225250
parameter)
226251

227252
for name, Class in TOOLCHAIN_CLASSES.items():
228-
CLS = Class(TARGET_MAP["K64F"], notify=MockNotifier())
253+
CLS = Class(test_target_map, notify=MockNotifier())
229254
assert name == CLS.name or name == LEGACY_TOOLCHAIN_NAMES[CLS.name]
230255

231256
@given(fixed_dictionaries({
@@ -245,7 +270,7 @@ def test_toolchain_profile_ld(profile, source_file):
245270
with patch('os.mkdir') as _mkdir,\
246271
patch('tools.toolchains.mbedToolchain.default_cmd') as _dflt_cmd:
247272
for _, tc_class in TOOLCHAIN_CLASSES.items():
248-
toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile,
273+
toolchain = tc_class(test_target_map, build_profile=profile,
249274
notify=MockNotifier())
250275
toolchain.RESPONSE_FILES = False
251276
toolchain.inc_md5 = ""
@@ -264,7 +289,7 @@ def test_toolchain_profile_ld(profile, source_file):
264289
parameter)
265290

266291
for name, Class in TOOLCHAIN_CLASSES.items():
267-
CLS = Class(TARGET_MAP["K64F"], notify=MockNotifier())
292+
CLS = Class(test_target_map, notify=MockNotifier())
268293
assert name == CLS.name or name == LEGACY_TOOLCHAIN_NAMES[CLS.name]
269294

270295

tools/toolchains/arm.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,14 @@ def __init__(self, target, *args, **kwargs):
390390
self.flags['common'].append("-DMBED_RTOS_SINGLE_THREAD")
391391
if "-D__MICROLIB" not in self.flags['common']:
392392
self.flags['common'].append("-D__MICROLIB")
393-
if "-Wl,--library_type=microlib" not in self.flags['ld']:
394-
self.flags['ld'].append("-Wl,--library_type=microlib")
395-
if "-Wl,--library_type=microlib" not in self.flags['common']:
396-
self.flags['common'].append("-Wl,--library_type=microlib")
393+
if "--library_type=microlib" not in self.flags['ld']:
394+
self.flags['ld'].append("--library_type=microlib")
395+
if "-Wl,--library_type=microlib" not in self.flags['c']:
396+
self.flags['c'].append("-Wl,--library_type=microlib")
397+
if "-Wl,--library_type=microlib" not in self.flags['cxx']:
398+
self.flags['cxx'].append("-Wl,--library_type=microlib")
399+
if "--library_type=microlib" not in self.flags['asm']:
400+
self.flags['asm'].append("--library_type=microlib")
397401

398402
core = target.core
399403
if CORE_ARCH[target.core] == 8:
@@ -470,7 +474,10 @@ def __init__(self, target, *args, **kwargs):
470474
self.elf2bin = join(TOOLCHAIN_PATHS["ARMC6"], "fromelf")
471475

472476
def _get_toolchain_labels(self):
473-
return ["ARM", "ARM_STD", "ARMC6"]
477+
if getattr(self.target, "default_toolchain", "ARM") == "uARM":
478+
return ["ARM", "ARM_MICRO"]
479+
else:
480+
return ["ARM", "ARM_STD"]
474481

475482
def parse_dependencies(self, dep_path):
476483
return mbedToolchain.parse_dependencies(self, dep_path)

0 commit comments

Comments
 (0)