Skip to content

Commit 5d06d1d

Browse files
Add LLVM LIT/FileCheck tests for Core files
1 parent c5806c4 commit 5d06d1d

53 files changed

Lines changed: 2526 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM --platform=linux/amd64 ubuntu:22.04
2+
3+
SHELL ["/bin/bash", "-c"]
4+
5+
ARG DEBIAN_FRONTEND=noninteractive
6+
7+
RUN apt-get update && \
8+
apt-get -y install \
9+
build-essential \
10+
curl \
11+
gdb \
12+
less \
13+
python3 \
14+
python3-pip \
15+
python-is-python3 \
16+
git \
17+
libtinfo5 \
18+
llvm-15-tools \
19+
unzip && \
20+
ln -s /usr/bin/FileCheck-15 /usr/bin/FileCheck
21+
22+
RUN pip install \
23+
lit \
24+
python-matrix-runner
25+
26+
RUN bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)" && \
27+
sed -i 's/OSH_THEME="font"/OSH_THEME="powerline"/' ~/.bashrc
28+
29+
ADD vcpkg-configuration.json /root/
30+
31+
RUN pushd /root && \
32+
. <(curl https://aka.ms/vcpkg-init.sh -L) && \
33+
echo "\n# Initialize vcpkg\n. /root/.vcpkg/vcpkg-init" >> .bashrc && \
34+
vcpkg x-update-registry --all && \
35+
vcpkg activate
36+
37+
CMD ["/bin/bash"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "Ubuntu-22.04",
3+
"build": { "dockerfile": "Dockerfile" },
4+
5+
"customizations": {
6+
"vscode": {
7+
"extensions": [
8+
"ms-vscode.cpptools",
9+
"ms-vscode.cpptools-extension-pack"
10+
]
11+
}
12+
}
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"registries": [
3+
{
4+
"kind": "artifact",
5+
"location": "https://aka.ms/vcpkg-ce-default",
6+
"name": "microsoft"
7+
},
8+
{
9+
"kind": "artifact",
10+
"location": "https://artifacts.keil.arm.com/vcpkg-ce-registry/registry.zip",
11+
"name": "arm"
12+
}
13+
],
14+
"requires": {
15+
"microsoft:ninja": "^1.10.2",
16+
"arm:compilers/arm/armclang":"^6.20.0",
17+
"arm:compilers/arm/arm-none-eabi-gcc": "^12.2.1-0",
18+
"arm:compilers/arm/llvm-embedded": "^17.0.1-0",
19+
"arm:tools/open-cmsis-pack/cmsis-toolbox": "^2.1.0-0",
20+
"arm:models/arm/avh": "^11.21.15"
21+
}
22+
}
23+

.github/workflows/core.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Core Checks
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
lit:
14+
runs-on: ubuntu-latest
15+
16+
env:
17+
ARM_UBL_ACTIVATION_CODE: ${{ secrets.ARM_UBL_ACTIVATION_CODE }}
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.10'
25+
cache: 'pip'
26+
27+
- name: Python requirements
28+
run: |
29+
pip install -r ./CMSIS/Core/Test/requirements.txt
30+
31+
- name: Cache vcpkg
32+
uses: actions/cache@v3
33+
with:
34+
key: vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ matrix.compiler }}
35+
restore-keys: |
36+
vcpkg-${{ runner.os }}-${{ runner.arch }}-
37+
path: /home/runner/.vcpkg
38+
39+
- name: Install LLVM dependencies and tools
40+
working-directory: /home/runner
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install libtinfo5 llvm-15-tools
44+
sudo ln -s /usr/bin/FileCheck-15 /usr/bin/FileCheck
45+
46+
- name: Prepare vcpkg env
47+
working-directory: ./CMSIS/Core/Test
48+
run: |
49+
. <(curl https://aka.ms/vcpkg-init.sh -L)
50+
vcpkg x-update-registry --all
51+
vcpkg activate
52+
53+
- name: Activate Arm tool license
54+
working-directory: ./CMSIS/Core/Test
55+
run: |
56+
. /home/runner/.vcpkg/vcpkg-init
57+
vcpkg activate
58+
if [[ -n "${{ env.ARM_UBL_ACTIVATION_CODE }}" ]]; then
59+
armlm activate --code ${{ env.ARM_UBL_ACTIVATION_CODE }}
60+
else
61+
armlm activate --server https://mdk-preview.keil.arm.com --product KEMDK-COM0
62+
fi
63+
64+
- uses: ammaraskar/gcc-problem-matcher@master
65+
66+
- name: Run LIT
67+
working-directory: ./CMSIS/Core/Test
68+
run: |
69+
. /home/runner/.vcpkg/vcpkg-init
70+
vcpkg activate
71+
72+
./build.py lit
73+
74+
- name: Deactivate Arm tool license
75+
if: always()
76+
working-directory: ./CMSIS/Core/Test
77+
run: |
78+
. /home/runner/.vcpkg/vcpkg-init
79+
vcpkg activate
80+
if [[ -n "${{ env.ARM_UBL_ACTIVATION_CODE }}" ]]; then
81+
armlm deactivate --code ${{ env.ARM_UBL_ACTIVATION_CODE }}
82+
else
83+
armlm deactivate --product KEMDK-COM0
84+
fi
85+
86+
- name: Publish Test Results
87+
if: ${{ !cancelled() && env.ARM_UBL_ACTIVATION_CODE }}
88+
uses: EnricoMi/publish-unit-test-result-action@v2
89+
with:
90+
report_individual_runs: true
91+
files: ./CMSIS/Core/Test/*.xunit

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@
22
**/__pycache__
33
CMSIS/Documentation/
44
CMSIS/DoxyGen/**/*.dxy
5+
CMSIS/Core/Test/*.o
6+
CMSIS/Core/Test/*.xunit
7+
CMSIS/Core/Test/.lit_test_times.txt
58
CMSIS/CoreValidation/Project/*.zip
69
CMSIS/CoreValidation/Project/*.junit
710
CMSIS/CoreValidation/Project/*.clangd
811
CMSIS/CoreValidation/Project/Validation.*/
912
CMSIS/CoreValidation/Project/Bootloader.*/
1013
CMSIS/CoreValidation/Project/build
1114
CMSIS/CoreValidation/Project/RTE/_**/*
15+
*.cbuild-idx.yml
1216
*.uvguix.*
1317
*.uvmpw.uvgui.*
1418
*.zip
1519
*.bak
1620
build
1721
output
1822
linkchecker-out.csv
19-
.DS_STORE
23+
.DS_STORE
24+
*.tmp

CMSIS/Core/Test/apsr.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: thumbv6m
2+
// RUN: %cc% %ccflags% %ccout% %s.o %s; llvm-objdump --mcpu=%mcpu% -d %s.o | FileCheck --allow-unused-prefixes --check-prefixes %prefixes% %s
3+
4+
#include "cmsis_compiler.h"
5+
6+
void get_apsr() {
7+
// CHECK-LABEL: <get_apsr>:
8+
// CHECK: mrs {{r[0-9]+}}, apsr
9+
volatile uint32_t result = __get_APSR();
10+
// CHECK: {{(bx lr)|(pop {.*pc})}}
11+
}

CMSIS/Core/Test/basepri.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// REQUIRES: thumb-2, thumbv7m
2+
// RUN: %cc% %ccflags% %ccout% %s.o %s; llvm-objdump --mcpu=%mcpu% -d %s.o | FileCheck --allow-unused-prefixes --check-prefixes %prefixes% %s
3+
4+
#include "cmsis_compiler.h"
5+
6+
void get_basepri() {
7+
// CHECK-LABEL: <get_basepri>:
8+
// CHECK: mrs {{r[0-9]+}}, basepri
9+
volatile uint32_t result = __get_BASEPRI();
10+
// CHECK: {{(bx lr)|(pop {.*pc})}}
11+
}
12+
13+
void get_basepri_ns() {
14+
// CHECK-LABEL: <get_basepri_ns>:
15+
#if __ARM_FEATURE_CMSE == 3
16+
// CHECK-S: mrs {{r[0-9]+}}, basepri_ns
17+
volatile uint32_t result = __TZ_get_BASEPRI_NS();
18+
#endif
19+
// CHECK: {{(bx lr)|(pop {.*pc})}}
20+
}
21+
22+
void set_basepri() {
23+
// CHECK-LABEL: <set_basepri>:
24+
// CHECK: msr basepri, {{r[0-9]+}}
25+
__set_BASEPRI(0x0815u);
26+
// CHECK: {{(bx lr)|(pop {.*pc})}}
27+
}
28+
29+
void set_basepri_ns() {
30+
// CHECK-LABEL: <set_basepri_ns>:
31+
#if __ARM_FEATURE_CMSE == 3
32+
// CHECK-S: msr basepri_ns, {{r[0-9]+}}
33+
__TZ_set_BASEPRI_NS(0x0815u);
34+
#endif
35+
// CHECK: {{(bx lr)|(pop {.*pc})}}
36+
}
37+
38+
void set_basepri_max() {
39+
// CHECK-LABEL: <set_basepri_max>:
40+
// CHECK: msr basepri_max, {{r[0-9]+}}
41+
__set_BASEPRI_MAX(0x0815u);
42+
// CHECK: {{(bx lr)|(pop {.*pc})}}
43+
}

CMSIS/Core/Test/bkpt.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %cc% %ccflags% %ccout% %s.o %s; llvm-objdump --mcpu=%mcpu% -d %s.o | FileCheck --allow-unused-prefixes --check-prefixes %prefixes% %s
2+
3+
#include "cmsis_compiler.h"
4+
5+
void bkpt() {
6+
// CHECK-LABEL: <bkpt>:
7+
// CHECK: bkpt {{#0x15|#21}}
8+
__BKPT(0x15);
9+
// CHECK: {{(bx lr)|(pop {.*pc})}}
10+
}

CMSIS/Core/Test/build.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
CM55 = ('Cortex-M55', 'CM55')
33+
CM55S = ('Cortex-M55S', 'CM55S')
34+
CM55NS = ('Cortex-M55NS', 'CM55NS')
35+
CM85 = ('Cortex-M85', 'CM85')
36+
CM85S = ('Cortex-M85S', 'CM85S')
37+
CM85NS = ('Cortex-M85NS', 'CM85NS')
38+
CA5 = ('Cortex-A5', 'CA5')
39+
CA7 = ('Cortex-A7', 'CA7')
40+
CA9 = ('Cortex-A9', 'CA9')
41+
CA5NEON = ('Cortex-A5neon', 'CA5neon')
42+
CA7NEON = ('Cortex-A7neon', 'CA7neon')
43+
CA9NEON = ('Cortex-A9neon', 'CA9neon')
44+
45+
46+
@matrix_axis("compiler", "c", "Compiler(s) to be considered.")
47+
class CompilerAxis(Enum):
48+
AC6 = ('AC6')
49+
GCC = ('GCC')
50+
IAR = ('IAR')
51+
CLANG = ('Clang')
52+
53+
@matrix_axis("optimize", "o", "Optimization level(s) to be considered.")
54+
class OptimizationAxis(Enum):
55+
NONE = ('none')
56+
BALANCED = ('balanced')
57+
SPEED = ('speed')
58+
SIZE = ('size')
59+
60+
61+
@matrix_action
62+
def lit(config):
63+
"""Run tests for the selected configurations using llvm's lit."""
64+
yield run_lit(config.compiler[0], config.device[1], config.optimize[0])
65+
66+
67+
def timestamp():
68+
return datetime.now().strftime('%Y%m%d%H%M%S')
69+
70+
@matrix_command()
71+
def run_lit(toolchain, device, optimize):
72+
return ["lit", "--xunit-xml-output", f"lit-{toolchain}-{optimize}-{device}.xunit", "-D", f"toolchain={toolchain}", "-D", f"device={device}", "-D", f"optimize={optimize}", "." ]
73+
74+
@matrix_filter
75+
def filter_iar(config):
76+
return config.compiler == CompilerAxis.IAR
77+
78+
@matrix_filter
79+
def filter_gcc_cm85(config):
80+
return config.compiler == CompilerAxis.GCC and config.device.match('CM85*')
81+
82+
#@matrix_filter
83+
#def filter_clang_cortex_a(config):
84+
# return config.compiler == CompilerAxis.CLANG and config.device.match('CA*')
85+
86+
87+
if __name__ == "__main__":
88+
main()

CMSIS/Core/Test/clrex.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// REQUIRES: ldrex
2+
// RUN: %cc% %ccflags% %ccout% %s.o %s; llvm-objdump --mcpu=%mcpu% -d %s.o | FileCheck --allow-unused-prefixes --check-prefixes %prefixes% %s
3+
4+
#include "cmsis_compiler.h"
5+
6+
void clrex() {
7+
// CHECK-LABEL: <clrex>:
8+
// CHECK: clrex
9+
__CLREX();
10+
// CHECK: {{(bx lr)|(pop {.*pc})}}
11+
}
12+

0 commit comments

Comments
 (0)