5 from argparse import ArgumentParser
6 from datetime import datetime
7 from subprocess import call, Popen
9 sys.path.append('buildutils')
11 from uv4cmd import Uv4Cmd
12 from fvpcmd import FvpCmd
13 from iarcmd import IarCmd
14 from testresult import TestResult
16 DEVICE_CM0 = 'Cortex-M0'
17 DEVICE_CM0PLUS = 'Cortex-M0plus'
18 DEVICE_CM3 = 'Cortex-M3'
19 DEVICE_CM4 = 'Cortex-M4'
20 DEVICE_CM4FP = 'Cortex-M4FP'
21 DEVICE_CM7 = 'Cortex-M7'
22 DEVICE_CM7SP = 'Cortex-M7SP'
23 DEVICE_CM7DP = 'Cortex-M7DP'
24 DEVICE_CM23 = 'Cortex-M23'
25 DEVICE_CM33 = 'Cortex-M33'
26 DEVICE_CM23NS = 'Cortex-M23NS'
27 DEVICE_CM33NS = 'Cortex-M33NS'
28 DEVICE_CM23S = 'Cortex-M23S'
29 DEVICE_CM33S = 'Cortex-M33S'
30 DEVICE_CA5 = 'Cortex-A5'
31 DEVICE_CA7 = 'Cortex-A7'
32 DEVICE_CA9 = 'Cortex-A9'
33 DEVICE_CA5NEON = 'Cortex-A5neon'
34 DEVICE_CA7NEON = 'Cortex-A7neon'
35 DEVICE_CA9NEON = 'Cortex-A9neon'
43 'uVision' : [ DEVICE_CM0, DEVICE_CM0PLUS, DEVICE_CM3, DEVICE_CM4, DEVICE_CM4FP, DEVICE_CM7, DEVICE_CM7SP, DEVICE_CM7DP, DEVICE_CM23S, DEVICE_CM33S ],
44 'DS' : [ DEVICE_CA5, DEVICE_CA7, DEVICE_CA9, DEVICE_CA5NEON, DEVICE_CA7NEON, DEVICE_CA9NEON ]
51 DEVICE_CM0PLUS : 'CM0plus',
54 DEVICE_CM4FP : 'CM4FP',
56 DEVICE_CM7SP : 'CM7SP',
57 DEVICE_CM7DP : 'CM7DP',
58 DEVICE_CM23S : 'CM23S',
59 DEVICE_CM33S : 'CM33S',
63 DEVICE_CA5NEON : 'CA5neon',
64 DEVICE_CA7NEON : 'CA7neon',
65 DEVICE_CA9NEON : 'CA9neon'
68 DEVICES = [ DEVICE_CM0, DEVICE_CM0PLUS, DEVICE_CM3, DEVICE_CM4, DEVICE_CM4FP, DEVICE_CM7, DEVICE_CM7SP, DEVICE_CM7DP, DEVICE_CM23S, DEVICE_CM33S, DEVICE_CA5, DEVICE_CA7, DEVICE_CA9, DEVICE_CA5NEON, DEVICE_CA7NEON, DEVICE_CA9NEON ]
69 COMPILERS = [ CC_AC5, CC_AC6, CC_GCC, CC_IAR ]
70 TARGETS = [ TARGET_FVP ]
73 [ DEVICE_CM23, CC_AC5, None ],
74 [ DEVICE_CM33, CC_AC5, None ],
75 [ DEVICE_CM23NS, CC_AC5, None ],
76 [ DEVICE_CM33NS, CC_AC5, None ],
77 [ DEVICE_CM23S, CC_AC5, None ],
78 [ DEVICE_CM33S, CC_AC5, None ],
82 DEVICE_CM0 : { 'cmd': "FVP_MPS2_Cortex-M0_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM0_config.txt" } },
83 DEVICE_CM0PLUS : { 'cmd': "FVP_MPS2_Cortex-M0_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM0plus_config.txt" } },
84 DEVICE_CM3 : { 'cmd': "FVP_MPS2_Cortex-M3_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM3_config.txt" } },
85 DEVICE_CM4 : { 'cmd': "FVP_MPS2_Cortex-M4_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM4_config.txt" } },
86 DEVICE_CM4FP : { 'cmd': "FVP_MPS2_Cortex-M4_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM4FP_config.txt" } },
87 DEVICE_CM7 : { 'cmd': "FVP_MPS2_Cortex-M7_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM7_config.txt" } },
88 DEVICE_CM7SP : { 'cmd': "FVP_MPS2_Cortex-M7_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM7SP_config.txt" } },
89 DEVICE_CM7DP : { 'cmd': "FVP_MPS2_Cortex-M7_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM7DP_config.txt" } },
90 DEVICE_CM23 : { 'cmd': "FVP_MPS2_Cortex-M23_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM23_config.txt", 'target': "cpu0" } },
91 DEVICE_CM33 : { 'cmd': "FVP_MPS2_Cortex-M33_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM33_DSP_FP_config.txt", 'target': "cpu0" } },
92 DEVICE_CM23NS : { 'cmd': "FVP_MPS2_Cortex-M23_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM23_TZ_config.txt", 'target': "cpu0" } },
93 DEVICE_CM33NS : { 'cmd': "FVP_MPS2_Cortex-M33_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM33_DSP_FP_TZ_config.txt", 'target': "cpu0" } },
94 DEVICE_CM23S : { 'cmd': "FVP_MPS2_Cortex-M23_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM23_TZ_config.txt", 'target': "cpu0" } },
95 DEVICE_CM33S : { 'cmd': "FVP_MPS2_Cortex-M33_MDK.exe", 'args': { 'limit': "50000000", 'config': "ARMCM33_DSP_FP_TZ_config.txt", 'target': "cpu0" } },
96 DEVICE_CA5 : { 'cmd': "fvp_ve_cortex-a5x1.exe", 'args': { 'limit': "70000000", 'config': "ARMCA5_config.txt" } },
97 DEVICE_CA7 : { 'cmd': "fvp_ve_cortex-a7x1.exe", 'args': { 'limit': "170000000", 'config': "ARMCA7_config.txt" } },
98 DEVICE_CA9 : { 'cmd': "fvp_ve_cortex-a9x1.exe", 'args': { 'limit': "70000000", 'config': "ARMCA9_config.txt" } },
99 DEVICE_CA5NEON : { 'cmd': "fvp_ve_cortex-a5x1.exe", 'args': { 'limit': "70000000", 'config': "ARMCA5neon_config.txt" } },
100 DEVICE_CA7NEON : { 'cmd': "fvp_ve_cortex-a7x1.exe", 'args': { 'limit': "170000000", 'config': "ARMCA7neon_config.txt" } },
101 DEVICE_CA9NEON : { 'cmd': "fvp_ve_cortex-a9x1.exe", 'args': { 'limit': "70000000", 'config': "ARMCA9neon_config.txt" } }
104 def isSkipped(dev, cc, target):
106 skipDev = (skip[0] == None or skip[0] == dev)
107 skipCc = (skip[1] == None or skip[1] == cc)
108 skipTarget = (skip[2] == None or skip[2] == target)
109 if skipDev and skipCc and skipTarget:
113 def testProject(dev, cc, target):
114 if (cc == CC_AC5) or (cc == CC_AC6):
115 if dev in MDK_ENV['DS']:
117 "{dev}/{cc}/.project".format(dev = dev, cc = cc),
118 "{dev}/{cc}/Debug/CMSIS_CV_{adev}_{cc}.axf".format(dev = dev, adev=ADEVICES[dev], cc = cc)
122 "{dev}/{cc}/CMSIS_CV.uvprojx".format(dev = dev, cc = cc),
123 "{dev}/{cc}/Objects/CMSIS_CV.axf".format(dev = dev, cc = cc)
126 if dev in MDK_ENV['DS']:
128 "{dev}/{cc}/.project".format(dev = dev, cc = cc),
129 "{dev}/{cc}/Debug/CMSIS_CV_{adev}_{cc}.elf".format(dev = dev, adev=ADEVICES[dev], cc = cc)
133 "{dev}/{cc}/CMSIS_CV.uvprojx".format(dev = dev, cc = cc),
134 "{dev}/{cc}/Objects/CMSIS_CV.elf".format(dev = dev, cc = cc)
138 "{dev}/{cc}/CMSIS_CV.ewp".format(dev = dev, cc = cc),
139 "{dev}/{cc}/{target}/Exe/CMSIS_CV.out".format(dev = dev, cc = cc, target = target)
141 raise "Unknown compiler!"
143 def bootloaderProject(dev, cc, target):
144 if (cc == CC_AC5) or (cc == CC_AC6):
146 "{dev}/{cc}/Bootloader/Bootloader.uvprojx".format(dev = dev, cc = cc),
147 "{dev}/{cc}/Bootloader/Objects/Bootloader.axf".format(dev = dev, cc = cc)
151 "{dev}/{cc}/Bootloader/Bootloader.uvprojx".format(dev = dev, cc = cc),
152 "{dev}/{cc}/Bootloader/Objects/Bootloader.elf".format(dev = dev, cc = cc)
156 "{dev}/{cc}/Bootloader/Bootloader.ewp".format(dev = dev, cc = cc),
157 "{dev}/{cc}/Bootloader/{target}/Exe/Bootloader.out".format(dev = dev, cc = cc, target = target)
159 raise "Unknown compiler!"
161 def buildStep(dev, cc, target, project):
162 if (cc == CC_AC5) or (cc == CC_AC6):
163 return Uv4Cmd(project, target)
165 return Uv4Cmd(project, target)
167 return IarCmd(project, target)
168 raise "Unknown compiler!"
170 def prepare(steps, args):
171 for dev in args.devices:
172 for cc in args.compilers:
173 for target in args.targets:
174 if not isSkipped(dev, cc, target):
175 config = "{dev} ({cc}, {target})".format(dev = dev, cc = cc, target = target)
176 prefix = "{dev}_{cc}_{target}".format(dev = dev, cc = cc, target = target)
178 rv = testProject(dev, cc, target)
179 build = [ buildStep(dev, cc, target, rv[0]) ]
182 bl = bootloaderProject(dev, cc, target)
183 if os.path.isfile(bl[0]):
184 build = [ buildStep(dev, cc, target, bl[0]) ] + build
185 binary = [ bl[1] ] + binary
187 if target == TARGET_FVP:
188 test = FvpCmd(FVP_MODELS[dev]['cmd'], binary, **FVP_MODELS[dev]['args'])
189 steps += [ { 'name': config, 'prefix': prefix, 'build': build, 'test': test } ]
191 def execute(steps, args):
194 if step['build'] and not args.execute_only:
195 for b in step['build']:
198 print("Skipping build")
199 # step['build'].skip()
201 if step['test'] and not args.build_only:
203 step['result'] = TestResult(step['test'].getOutput())
204 step['result'].saveXml("result_{0}_{1}.xml".format(step['prefix'], datetime.now().strftime("%Y%m%d%H%M%S")))
206 print("Skipping test")
209 def printSummary(steps):
211 print("Test Summary")
212 print("============")
214 print("Test run Total Exec Pass Fail ")
215 print("-------------------------------------------------------")
218 print("{0:30} {1:>4} {2:>4} {3:>4} {4:>4}".format(step['name'], *step['result'].getSummary()))
220 print("{0:30} ------ NO RESULTS ------".format(step['name']))
223 parser = ArgumentParser()
224 parser.add_argument('--genconfig', action='store_true')
225 parser.add_argument('-b', '--build-only', action='store_true')
226 parser.add_argument('-e', '--execute-only', action='store_true')
227 parser.add_argument('-d', '--devices', nargs='*', choices=DEVICES, default=DEVICES, help = 'Devices to be considered.')
228 parser.add_argument('-c', '--compilers', nargs='*', choices=COMPILERS, default=COMPILERS, help = 'Compilers to be considered.')
229 parser.add_argument('-t', '--targets', nargs='*', choices=TARGETS, default=TARGETS, help = 'Targets to be considered.')
230 args = parser.parse_args()
233 for dev in args.devices:
234 model = FVP_MODELS[dev]
235 cmd = [ model['cmd'], '-l', '-o', model['args']['config'] ]
248 if __name__ == "__main__":