12
12
sys .path .insert (0 , ROOT )
13
13
14
14
from tools .toolchains import TOOLCHAIN_CLASSES , LEGACY_TOOLCHAIN_NAMES ,\
15
- Resources , TOOLCHAIN_PATHS
15
+ Resources , TOOLCHAIN_PATHS , mbedToolchain
16
16
from tools .targets import TARGET_MAP
17
17
18
18
def test_instantiation ():
@@ -43,11 +43,15 @@ def test_toolchain_profile_c(profile, source_file):
43
43
toolchain .inc_md5 = ""
44
44
toolchain .build_dir = ""
45
45
toolchain .config = MagicMock (app_config_location = None )
46
+ for parameter in profile ['c' ] + profile ['common' ]:
47
+ assert any (parameter in cmd for cmd in toolchain .cc ), \
48
+ "Toolchain %s did not propagate arg %s" % (toolchain .name ,
49
+ parameter )
46
50
compile_command = toolchain .compile_command (to_compile ,
47
51
to_compile + ".o" , [])
48
52
for parameter in profile ['c' ] + profile ['common' ]:
49
53
assert any (parameter in cmd for cmd in compile_command ), \
50
- "Toolchain %s did not propigate arg %s" % (toolchain .name ,
54
+ "Toolchain %s did not propagate arg %s" % (toolchain .name ,
51
55
parameter )
52
56
53
57
@given (fixed_dictionaries ({
@@ -69,11 +73,15 @@ def test_toolchain_profile_cpp(profile, source_file):
69
73
toolchain .inc_md5 = ""
70
74
toolchain .build_dir = ""
71
75
toolchain .config = MagicMock (app_config_location = None )
76
+ for parameter in profile ['cxx' ] + profile ['common' ]:
77
+ assert any (parameter in cmd for cmd in toolchain .cppc ), \
78
+ "Toolchain %s did not propagate arg %s" % (toolchain .name ,
79
+ parameter )
72
80
compile_command = toolchain .compile_command (to_compile ,
73
81
to_compile + ".o" , [])
74
82
for parameter in profile ['cxx' ] + profile ['common' ]:
75
83
assert any (parameter in cmd for cmd in compile_command ), \
76
- "Toolchain %s did not propigate arg %s" % (toolchain .name ,
84
+ "Toolchain %s did not propagate arg %s" % (toolchain .name ,
77
85
parameter )
78
86
79
87
@given (fixed_dictionaries ({
@@ -94,14 +102,55 @@ def test_toolchain_profile_asm(profile, source_file):
94
102
toolchain = tc_class (TARGET_MAP ["K64F" ], build_profile = profile )
95
103
toolchain .inc_md5 = ""
96
104
toolchain .build_dir = ""
105
+ for parameter in profile ['asm' ]:
106
+ assert any (parameter in cmd for cmd in toolchain .asm ), \
107
+ "Toolchain %s did not propagate arg %s" % (toolchain .name ,
108
+ parameter )
97
109
compile_command = toolchain .compile_command (to_compile ,
98
110
to_compile + ".o" , [])
99
111
if not compile_command :
100
112
assert compile_command , to_compile
101
113
for parameter in profile ['asm' ]:
102
114
assert any (parameter in cmd for cmd in compile_command ), \
103
- "Toolchain %s did not propigate arg %s" % (toolchain .name ,
104
- parameter )
115
+ "Toolchain %s did not propagate arg %s" % (toolchain .name ,
116
+ parameter )
117
+
118
+ for name , Class in TOOLCHAIN_CLASSES .items ():
119
+ CLS = Class (TARGET_MAP ["K64F" ])
120
+ assert name == CLS .name or name == LEGACY_TOOLCHAIN_NAMES [CLS .name ]
121
+
122
+ @given (fixed_dictionaries ({
123
+ 'common' : lists (text ()),
124
+ 'c' : lists (text ()),
125
+ 'cxx' : lists (text ()),
126
+ 'asm' : lists (text ()),
127
+ 'ld' : lists (text (min_size = 1 ))}),
128
+ lists (text (min_size = 1 , alphabet = ALPHABET ), min_size = 1 ))
129
+ def test_toolchain_profile_ld (profile , source_file ):
130
+ """Test that the appropriate profile parameters are passed to the
131
+ Linker"""
132
+ filename = deepcopy (source_file )
133
+ filename [- 1 ] += ".o"
134
+ to_compile = os .path .join (* filename )
135
+ with patch ('os.mkdir' ) as _mkdir ,\
136
+ patch ('tools.toolchains.mbedToolchain.default_cmd' ) as _dflt_cmd :
137
+ for _ , tc_class in TOOLCHAIN_CLASSES .items ():
138
+ toolchain = tc_class (TARGET_MAP ["K64F" ], build_profile = profile )
139
+ toolchain .RESPONSE_FILES = False
140
+ toolchain .inc_md5 = ""
141
+ toolchain .build_dir = ""
142
+ for parameter in profile ['ld' ]:
143
+ assert any (parameter in cmd for cmd in toolchain .ld ), \
144
+ "Toolchain %s did not propagate arg %s" % (toolchain .name ,
145
+ parameter )
146
+ toolchain .link (to_compile + ".elf" , [to_compile ], [], [], None )
147
+ compile_cmd = _dflt_cmd .call_args_list
148
+ if not compile_cmd :
149
+ assert compile_cmd , to_compile
150
+ for parameter in profile ['ld' ]:
151
+ assert any (parameter in cmd [0 ][0 ] for cmd in compile_cmd ), \
152
+ "Toolchain %s did not propagate arg %s" % (toolchain .name ,
153
+ parameter )
105
154
106
155
for name , Class in TOOLCHAIN_CLASSES .items ():
107
156
CLS = Class (TARGET_MAP ["K64F" ])
0 commit comments