]> begriffs open source - cmsis/blob - CMSIS/Core/Test/build.py
Enhance lit Core tests for CM52
[cmsis] / CMSIS / Core / Test / build.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 import logging
5
6 from datetime import datetime
7 from enum import Enum
8
9 from matrix_runner import main, matrix_axis, matrix_action, matrix_command, matrix_filter, \
10     FileReport, JUnitReport
11
12
13 @matrix_axis("device", "d", "Device(s) to be considered.")
14 class DeviceAxis(Enum):
15     CM0 = ('Cortex-M0', 'CM0')
16     CM0plus = ('Cortex-M0plus', 'CM0plus')
17     CM3 = ('Cortex-M3', 'CM3')
18     CM4 = ('Cortex-M4', 'CM4')
19     CM4FP = ('Cortex-M4FP', 'CM4FP')
20     CM7 = ('Cortex-M7', 'CM7')
21     CM7SP = ('Cortex-M7SP', 'CM7SP')
22     CM7DP = ('Cortex-M7DP', 'CM7DP')
23     CM23 = ('Cortex-M23', 'CM23')
24     CM23S = ('Cortex-M23S', 'CM23S')
25     CM23NS = ('Cortex-M23NS', 'CM23NS')
26     CM33 = ('Cortex-M33', 'CM33')
27     CM33S = ('Cortex-M33S', 'CM33S')
28     CM33NS = ('Cortex-M33NS', 'CM33NS')
29     CM35P = ('Cortex-M35P', 'CM35P')
30     CM35PS = ('Cortex-M35PS', 'CM35PS')
31     CM35PNS = ('Cortex-M35PNS', 'CM35PNS')
32     CM52 = ('Cortex-M52', 'CM52')
33     CM52S = ('Cortex-M52S', 'CM52S')
34     CM52NS = ('Cortex-M52NS', 'CM52NS')
35     CM55 = ('Cortex-M55', 'CM55')
36     CM55S = ('Cortex-M55S', 'CM55S')
37     CM55NS = ('Cortex-M55NS', 'CM55NS')
38     CM85 = ('Cortex-M85', 'CM85')
39     CM85S = ('Cortex-M85S', 'CM85S')
40     CM85NS = ('Cortex-M85NS', 'CM85NS')
41     CA5 = ('Cortex-A5', 'CA5')
42     CA7 = ('Cortex-A7', 'CA7')
43     CA9 = ('Cortex-A9', 'CA9')
44     CA5NEON = ('Cortex-A5neon', 'CA5neon')
45     CA7NEON = ('Cortex-A7neon', 'CA7neon')
46     CA9NEON = ('Cortex-A9neon', 'CA9neon')
47
48
49 @matrix_axis("compiler", "c", "Compiler(s) to be considered.")
50 class CompilerAxis(Enum):
51     AC6 = ('AC6')
52     GCC = ('GCC')
53     IAR = ('IAR')
54     CLANG = ('Clang')
55
56
57 @matrix_axis("optimize", "o", "Optimization level(s) to be considered.")
58 class OptimizationAxis(Enum):
59     NONE = ('none')
60     BALANCED = ('balanced')
61     SPEED = ('speed')
62     SIZE = ('size')
63
64
65 def timestamp():
66     return datetime.now().strftime('%Y%m%d%H%M%S')
67
68
69 @matrix_action
70 def lit(config, results):
71     """Run tests for the selected configurations using llvm's lit."""
72     yield run_lit(config.compiler[0], config.device[1], config.optimize[0])
73     results[0].test_report.write(f"lit-{config.compiler[0]}-{config.optimize[0]}-{config.device[1]}-{timestamp()}.xunit")
74
75
76 def timestamp():
77     return datetime.now().strftime('%Y%m%d%H%M%S')
78
79
80 @matrix_command(test_report=FileReport(f"lit.xml") | JUnitReport())
81 def run_lit(toolchain, device, optimize):
82     return ["lit", "--xunit-xml-output", f"lit.xml", "-D", f"toolchain={toolchain}", "-D", f"device={device}", "-D", f"optimize={optimize}", "src" ]
83
84
85 @matrix_filter
86 def filter_iar(config):
87     return config.compiler == CompilerAxis.IAR
88
89
90 @matrix_filter
91 def filter_gcc_cm52(config):
92     device = config.device.match('CM52*')
93     compiler = config.compiler == CompilerAxis.GCC
94     return device and compiler
95
96
97 if __name__ == "__main__":
98     main()