Skip to content

Commit 4d07bf8

Browse files
add CI workflow to run the test suite
Runs make test on every push/PR. Kernel verifier tests need passwordless sudo and a kernel with BTF/BPF enabled, which isn't guaranteed on every runner, so the workflow probes for working sudo first and only attempts them if it's available. Also add ctypeslib2 to the test extra: make test now regenerates vmlinux.py via tools/vmlinux-gen.py, which needs clang2py.
1 parent 559d057 commit 4d07bf8

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Runs the pytest suite (IR generation + LLC compilation). Kernel verifier
2+
# tests additionally need passwordless sudo and a kernel with BTF/BPF
3+
# enabled, which isn't guaranteed on every runner, so we probe for working
4+
# sudo first and only attempt them if it's there.
5+
6+
name: Test
7+
8+
on:
9+
workflow_dispatch:
10+
push:
11+
pull_request:
12+
13+
jobs:
14+
test:
15+
name: Test
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v7
19+
20+
- uses: actions/setup-python@v7
21+
with:
22+
python-version: "3.12"
23+
24+
- name: Install system dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y clang llvm libclang-dev bpftool
28+
29+
- name: Install uv
30+
run: pip install uv
31+
32+
- name: Install project
33+
run: uv pip install --system -e ".[test]"
34+
35+
- name: Run test suite
36+
run: make test
37+
38+
- name: Check whether sudo is usable
39+
id: sudo-check
40+
run: |
41+
if sudo -n true 2>/dev/null; then
42+
echo "Passwordless sudo is available."
43+
echo "available=true" >> "$GITHUB_OUTPUT"
44+
else
45+
echo "No passwordless sudo on this runner; kernel verifier tests will be skipped."
46+
echo "available=false" >> "$GITHUB_OUTPUT"
47+
fi
48+
49+
- name: Run kernel verifier tests
50+
if: steps.sudo-check.outputs.available == 'true'
51+
run: |
52+
sudo -v
53+
make test-verifier

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ docs = [
4444
test = [
4545
"pytest>=8.0",
4646
"pytest-cov>=5.0",
47+
"ctypeslib2",
4748
]
4849

4950
[tool.setuptools.packages.find]

0 commit comments

Comments
 (0)