Skip to content

Commit 3cf03fd

Browse files
committed
ci: add panicdump sanitizer and verification gates
1 parent 84bb1c2 commit 3cf03fd

2 files changed

Lines changed: 171 additions & 24 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 167 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ on:
66
pull_request:
77
branches: [ main, master ]
88

9+
permissions:
10+
contents: read
11+
12+
env:
13+
STRICT_C_FLAGS: >-
14+
-Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion
15+
-Wshadow -Wformat=2 -Wundef -Wmissing-prototypes -Wstrict-prototypes
16+
917
jobs:
10-
test:
11-
name: Host tests (Python)
18+
python-tests:
19+
name: Python decoder tests
1220
runs-on: ubuntu-latest
1321

1422
steps:
@@ -20,29 +28,59 @@ jobs:
2028
python-version: "3.11"
2129

2230
- name: Install pytest
23-
run: pip install pytest
31+
run: python -m pip install pytest
2432

25-
- name: Generate test vectors
26-
run: |
27-
cd tools
28-
python3 make_mock_dump.py --all
33+
- name: Run decoder tests
34+
run: python -m pytest tests/host_format_tests -v --tb=short
2935

30-
- name: Run tests
31-
run: |
32-
PYTHONPATH=tools python3 -m pytest tests/ -v --tb=short
36+
host-strict:
37+
name: Host strict build (${{ matrix.compiler }}, ${{ matrix.build_type }})
38+
runs-on: ubuntu-latest
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
compiler: [ gcc, clang ]
43+
build_type: [ Debug, Release ]
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Install Clang
49+
if: matrix.compiler == 'clang'
50+
run: sudo apt-get update && sudo apt-get install -y clang
3351

34-
native:
35-
name: Native build and package
52+
- name: Configure host build
53+
run: >
54+
cmake -S . -B build-${{ matrix.compiler }}-${{ matrix.build_type }}
55+
-DPANICDUMP_BUILD_TESTS=ON
56+
-DPANICDUMP_PORT=host
57+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
58+
-DCMAKE_C_COMPILER=${{ matrix.compiler }}
59+
-DCMAKE_C_FLAGS="${STRICT_C_FLAGS}"
60+
61+
- name: Build host targets
62+
run: cmake --build build-${{ matrix.compiler }}-${{ matrix.build_type }} --parallel
63+
64+
- name: Run CTest
65+
run: ctest --test-dir build-${{ matrix.compiler }}-${{ matrix.build_type }} --output-on-failure
66+
67+
package-consumer:
68+
name: Package install and consumer
3669
runs-on: ubuntu-latest
3770

3871
steps:
3972
- uses: actions/checkout@v4
4073

4174
- name: Configure host build
42-
run: cmake -S . -B build -DPANICDUMP_BUILD_TESTS=ON -DPANICDUMP_PORT=host
75+
run: >
76+
cmake -S . -B build
77+
-DPANICDUMP_BUILD_TESTS=ON
78+
-DPANICDUMP_PORT=host
79+
-DCMAKE_BUILD_TYPE=Release
80+
-DCMAKE_C_FLAGS="${STRICT_C_FLAGS}"
4381
4482
- name: Build host targets
45-
run: cmake --build build --config Release --target panicdump_core_test
83+
run: cmake --build build --parallel
4684

4785
- name: Run CTest
4886
run: ctest --test-dir build -C Release --output-on-failure
@@ -56,20 +94,125 @@ jobs:
5694
- name: Build external consumer
5795
run: cmake --build build-consumer --config Release
5896

59-
lint:
60-
name: Python lint
97+
- name: Run external consumer
98+
run: ./build-consumer/panicdump_consumer
99+
100+
sanitizers:
101+
name: Sanitizer build (${{ matrix.sanitizer }})
61102
runs-on: ubuntu-latest
103+
strategy:
104+
fail-fast: false
105+
matrix:
106+
include:
107+
- sanitizer: asan
108+
cflags: -fsanitize=address -fno-omit-frame-pointer
109+
ldflags: -fsanitize=address
110+
- sanitizer: ubsan
111+
cflags: -fsanitize=undefined -fno-omit-frame-pointer
112+
ldflags: -fsanitize=undefined
113+
- sanitizer: lsan
114+
cflags: -fsanitize=leak -fno-omit-frame-pointer
115+
ldflags: -fsanitize=leak
62116

63117
steps:
64118
- uses: actions/checkout@v4
65119

66-
- name: Set up Python
67-
uses: actions/setup-python@v5
68-
with:
69-
python-version: "3.11"
120+
- name: Install Clang
121+
run: sudo apt-get update && sudo apt-get install -y clang
122+
123+
- name: Configure sanitizer build
124+
run: >
125+
cmake -S . -B build-${{ matrix.sanitizer }}
126+
-DPANICDUMP_BUILD_TESTS=ON
127+
-DPANICDUMP_PORT=host
128+
-DCMAKE_BUILD_TYPE=Debug
129+
-DCMAKE_C_COMPILER=clang
130+
-DCMAKE_C_FLAGS="${STRICT_C_FLAGS} ${{ matrix.cflags }}"
131+
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.ldflags }}"
132+
133+
- name: Build sanitizer targets
134+
run: cmake --build build-${{ matrix.sanitizer }} --parallel
135+
136+
- name: Run CTest
137+
run: ctest --test-dir build-${{ matrix.sanitizer }} --output-on-failure
138+
139+
static-analysis:
140+
name: Static analysis
141+
runs-on: ubuntu-latest
142+
143+
steps:
144+
- uses: actions/checkout@v4
70145

71-
- name: Install ruff
72-
run: pip install ruff
146+
- name: Install analysis tools
147+
run: sudo apt-get update && sudo apt-get install -y clang clang-tidy cppcheck
148+
149+
- name: clang --analyze
150+
run: >
151+
clang --analyze -std=c11
152+
-Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion
153+
-Wshadow -Wformat=2 -Wundef -Wmissing-prototypes -Wstrict-prototypes
154+
-DPANICDUMP_HOST_BUILD -I include -I src
155+
src/panicdump.c src/panicdump_port_host.c tests/panicdump_core_test.c
156+
157+
- name: clang-tidy
158+
run: >
159+
clang-tidy src/panicdump.c src/panicdump_port_host.c tests/panicdump_core_test.c
160+
--checks=clang-analyzer-*
161+
--header-filter=.*
162+
--warnings-as-errors=*
163+
--
164+
-std=c11
165+
-DPANICDUMP_HOST_BUILD -I include -I src
166+
167+
- name: cppcheck
168+
run: >
169+
cppcheck --enable=warning,style,performance,portability
170+
--error-exitcode=1 --std=c11
171+
-I include -I src -DPANICDUMP_HOST_BUILD
172+
src/panicdump.c src/panicdump_port_host.c tests/panicdump_core_test.c
173+
174+
arm-verification:
175+
name: ARM verification (${{ matrix.cpu }})
176+
runs-on: ubuntu-latest
177+
strategy:
178+
fail-fast: false
179+
matrix:
180+
include:
181+
- cpu: cortex-m3
182+
cflags: -mcpu=cortex-m3 -mthumb
183+
ldflags: -mcpu=cortex-m3 -mthumb
184+
- cpu: cortex-m4
185+
cflags: -mcpu=cortex-m4 -mthumb -mfloat-abi=soft
186+
ldflags: -mcpu=cortex-m4 -mthumb -mfloat-abi=soft
73187

74-
- name: Lint tools/
75-
run: ruff check tools/
188+
steps:
189+
- uses: actions/checkout@v4
190+
191+
- name: Install ARM toolchain
192+
run: sudo apt-get update && sudo apt-get install -y gcc-arm-none-eabi binutils-arm-none-eabi
193+
194+
- name: Compile core and Cortex-M port
195+
run: |
196+
mkdir -p build-arm-${{ matrix.cpu }}
197+
arm-none-eabi-gcc ${{ matrix.cflags }} -ffreestanding -fstack-usage -Wall -Wextra -Werror \
198+
-DPANICDUMP_RAM_BASE=0x20000000 -DPANICDUMP_RAM_END=0x20020000 \
199+
-I include -I src -c src/panicdump.c -o build-arm-${{ matrix.cpu }}/panicdump.o
200+
arm-none-eabi-gcc ${{ matrix.cflags }} -ffreestanding -fstack-usage -Wall -Wextra -Werror \
201+
-DPANICDUMP_RAM_BASE=0x20000000 -DPANICDUMP_RAM_END=0x20020000 \
202+
-I include -I src -c src/panicdump_port_cortexm.c -o build-arm-${{ matrix.cpu }}/panicdump_port_cortexm.o
203+
204+
- name: Link freestanding ELF
205+
run: >
206+
arm-none-eabi-gcc ${{ matrix.ldflags }} -ffreestanding -nostdlib
207+
-Wl,-Map=build-arm-${{ matrix.cpu }}/panicdump.map
208+
-Wl,-e,panicdump_fault_handler_c
209+
build-arm-${{ matrix.cpu }}/panicdump.o
210+
build-arm-${{ matrix.cpu }}/panicdump_port_cortexm.o
211+
-o build-arm-${{ matrix.cpu }}/panicdump.elf
212+
213+
- name: Inspect ARM link
214+
run: |
215+
arm-none-eabi-size build-arm-${{ matrix.cpu }}/panicdump.elf
216+
arm-none-eabi-objdump -t build-arm-${{ matrix.cpu }}/panicdump.elf | grep 'panicdump_port_cortexm\|panicdump_fault_handler_c\|panicdump_commit_snapshot'
217+
cat build-arm-${{ matrix.cpu }}/panicdump.o.su
218+
cat build-arm-${{ matrix.cpu }}/panicdump_port_cortexm.o.su

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/prompts
2+
/release_prompts
3+
/issue_prompts
4+
*.md

0 commit comments

Comments
 (0)