]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/workspace_tools/export_test.py
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / workspace_tools / export_test.py
1 """
2 mbed SDK
3 Copyright (c) 2011-2013 ARM Limited
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 """
17 import sys
18 from os.path import join, abspath, dirname, exists
19 ROOT = abspath(join(dirname(__file__), ".."))
20 sys.path.insert(0, ROOT)
21
22 from shutil import move
23
24 from workspace_tools.paths import *
25 from workspace_tools.utils import mkdir, cmd
26 from workspace_tools.export import export, setup_user_prj
27
28
29 USR_PRJ_NAME = "usr_prj"
30 USER_PRJ = join(EXPORT_WORKSPACE, USR_PRJ_NAME)
31 USER_SRC = join(USER_PRJ, "src")
32
33
34 def setup_test_user_prj():
35 if exists(USER_PRJ):
36 print 'Test user project already generated...'
37 return
38
39 setup_user_prj(USER_PRJ, join(TEST_DIR, "rtos", "mbed", "basic"), [join(LIB_DIR, "rtos")])
40
41 # FAKE BUILD URL
42 open(join(USER_SRC, "mbed.bld"), 'w').write("http://mbed.org/users/mbed_official/code/mbed/builds/976df7c37ad5\n")
43
44
45 def fake_build_url_resolver(url):
46 # FAKE BUILD URL: Ignore the URL, always return the path to the mbed library
47 return {'path':MBED_LIBRARIES, 'name':'mbed'}
48
49
50 def test_export(toolchain, target, expected_error=None):
51 if toolchain is None and target is None:
52 base_dir = join(EXPORT_TMP, "zip")
53 else:
54 base_dir = join(EXPORT_TMP, toolchain, target)
55 temp_dir = join(base_dir, "temp")
56 mkdir(temp_dir)
57
58 zip_path, report = export(USER_PRJ, USR_PRJ_NAME, toolchain, target, base_dir, temp_dir, False, None, fake_build_url_resolver)
59
60 if report['success']:
61 move(zip_path, join(EXPORT_DIR, "export_%s_%s.zip" % (toolchain, target)))
62 print "[OK]"
63 else:
64 if expected_error is None:
65 print '[ERRROR] %s' % report['errormsg']
66 else:
67 if (zip_path is None) and (expected_error in report['errormsg']):
68 print '[OK]'
69 else:
70 print '[ERROR]'
71 print ' zip:', zip_path
72 print ' msg:', report['errormsg']
73
74
75 if __name__ == '__main__':
76 setup_test_user_prj()
77
78 for toolchain, target in [
79 ('zip', 'LPC1768'),
80
81 ('emblocks', 'LPC1768'),
82 ('emblocks', 'LPC1549'),
83 ('emblocks', 'LPC1114'),
84 ('emblocks', 'LPC11U35_401'),
85 ('emblocks', 'LPC11U35_501'),
86 ('emblocks', 'LPCCAPPUCCINO'),
87 ('emblocks', 'LPC2368'),
88 ('emblocks', 'STM32F407'),
89 ('emblocks', 'DISCO_F100RB'),
90 ('emblocks', 'DISCO_F051R8'),
91 ('emblocks', 'DISCO_F407VG'),
92 ('emblocks', 'DISCO_F303VC'),
93 ('emblocks', 'NRF51822'),
94 ('emblocks', 'NUCLEO_F401RE'),
95 ('emblocks', 'NUCLEO_F411RE'),
96 ('emblocks', 'MTS_MDOT_F405RG'),
97 ('emblocks', 'MTS_MDOT_F411RE'),
98
99 ('coide', 'KL05Z'),
100 ('coide', 'KL25Z'),
101 ('coide', 'LPC1768'),
102 ('coide', 'ARCH_PRO'),
103 ('coide', 'DISCO_F407VG'),
104 ('coide', 'NUCLEO_F401RE'),
105 ('coide', 'NUCLEO_F411RE'),
106 ('coide', 'DISCO_F429ZI'),
107 ('coide', 'NUCLEO_F334R8'),
108 ('coide', 'MTS_MDOT_F405RG'),
109 ('coide', 'MTS_MDOT_F411RE'),
110
111 ('uvision', 'LPC1768'),
112 ('uvision', 'LPC11U24'),
113 ('uvision', 'KL25Z'),
114 ('uvision', 'LPC1347'),
115 ('uvision', 'LPC1114'),
116 ('uvision', 'LPC4088'),
117 ('uvision', 'LPC4088_DM'),
118 ('uvision', 'LPC4337'),
119 ('uvision', 'HRM1017'),
120
121 ('uvision', 'NUCLEO_F030R8'),
122 ('uvision', 'NUCLEO_F070RB'),
123 ('uvision', 'NUCLEO_F072RB'),
124 ('uvision', 'NUCLEO_F091RC'),
125 ('uvision', 'NUCLEO_F103RB'),
126 ('uvision', 'NUCLEO_F302R8'),
127 ('uvision', 'NUCLEO_F303RE'),
128 ('uvision', 'NUCLEO_F334R8'),
129 ('uvision', 'NUCLEO_F401RE'),
130 ('uvision', 'NUCLEO_F411RE'),
131 ('uvision', 'NUCLEO_L053R8'),
132 ('uvision', 'NUCLEO_L073RZ'),
133 ('uvision', 'NUCLEO_L152RE'),
134 ('uvision', 'MTS_MDOT_F405RG'),
135 ('uvision', 'MAXWSNENV'),
136 ('uvision', 'MAX32600MBED'),
137
138 ('lpcxpresso', 'LPC1768'),
139 ('lpcxpresso', 'LPC4088'),
140 ('lpcxpresso', 'LPC4088_DM'),
141 ('lpcxpresso', 'LPC1114'),
142 ('lpcxpresso', 'LPC11U35_401'),
143 ('lpcxpresso', 'LPC11U35_501'),
144 ('lpcxpresso', 'LPCCAPPUCCINO'),
145 ('lpcxpresso', 'LPC1549'),
146 ('lpcxpresso', 'LPC11U68'),
147 # Linux path: /home/emimon01/bin/gcc-cs/bin/
148 # Windows path: "C:/Program Files (x86)/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin/"
149 ('codesourcery', 'LPC1768'),
150
151 # Linux path: /home/emimon01/bin/gcc-arm/bin/
152 # Windows path: C:/arm-none-eabi-gcc-4_7/bin/
153 ('gcc_arm', 'LPC1768'),
154 ('gcc_arm', 'LPC4088_DM'),
155 ('gcc_arm', 'LPC1549'),
156 ('gcc_arm', 'LPC1114'),
157 ('gcc_arm', 'LPC11U35_401'),
158 ('gcc_arm', 'LPC11U35_501'),
159 ('gcc_arm', 'LPCCAPPUCCINO'),
160 ('gcc_arm', 'LPC2368'),
161 ('gcc_arm', 'LPC824'),
162 ('gcc_arm', 'SSCI824'),
163
164 ('gcc_arm', 'STM32F407'),
165 ('gcc_arm', 'DISCO_F100RB'),
166 ('gcc_arm', 'DISCO_F051R8'),
167 ('gcc_arm', 'DISCO_F407VG'),
168 ('gcc_arm', 'DISCO_F303VC'),
169 ('gcc_arm', 'NRF51822'),
170 ('gcc_arm', 'HRM1017'),
171 ('gcc_arm', 'NUCLEO_F401RE'),
172 ('gcc_arm', 'NUCLEO_F411RE'),
173 ('gcc_arm', 'DISCO_F429ZI'),
174 ('gcc_arm', 'NUCLEO_F334R8'),
175 ('gcc_arm', 'MAX32600MBED'),
176 ('gcc_arm', 'MTS_MDOT_F405RG'),
177 ('gcc_arm', 'MTS_MDOT_F411RE'),
178 ('gcc_arm', 'RZ_A1H'),
179 ('gcc_arm', 'MAXWSNENV'),
180 ('gcc_arm', 'MAX32600MBED'),
181
182 ('ds5_5', 'LPC1768'), ('ds5_5', 'LPC11U24'),
183
184 ('iar', 'LPC1768'),
185 ('iar', 'LPC4088_DM'),
186 ('iar', 'LPC1347'),
187
188 ('iar', 'NUCLEO_F030R8'),
189 ('iar', 'NUCLEO_F070RB'),
190 ('iar', 'NUCLEO_F072RB'),
191 ('iar', 'NUCLEO_F091RC'),
192 ('iar', 'NUCLEO_F302R8'),
193 ('iar', 'NUCLEO_F303RE'),
194 ('iar', 'NUCLEO_F334R8'),
195 ('iar', 'NUCLEO_F401RE'),
196 ('iar', 'NUCLEO_F411RE'),
197 ('iar', 'NUCLEO_L053R8'),
198 ('iar', 'NUCLEO_L073RZ'),
199 ('iar', 'NUCLEO_L152RE'),
200 ('iar', 'STM32F407'),
201 ('iar', 'MTS_MDOT_F405RG'),
202 ('iar', 'MTS_MDOT_F411RE'),
203 ('iar', 'MAXWSNENV'),
204 ('iar', 'MAX32600MBED'),
205
206 # Removed following item to avoid script error
207 #(None, None),
208 ]:
209 print '\n=== Exporting to "%s::%s" ===' % (toolchain, target)
210 test_export(toolchain, target)
211
212 print "\n=== Test error messages ==="
213 test_export('lpcxpresso', 'LPC11U24', expected_error='lpcxpresso')
Imprint / Impressum