Skip to content

Commit f72ed8b

Browse files
committed
Introduce a workflow for selftests/bpf/test_progs with ASAN
1 parent 381cbb2 commit f72ed8b

File tree

4 files changed

+186
-2
lines changed

4 files changed

+186
-2
lines changed

.github/workflows/kernel-build-test.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ jobs:
108108
test: ${{ matrix.test }}
109109
continue_on_error: ${{ toJSON(matrix.continue_on_error) }}
110110
timeout_minutes: ${{ matrix.timeout_minutes }}
111+
llvm_version: ${{ inputs.llvm_version }}
112+
113+
test-progs-asan:
114+
name: 'test_progs with ASAN'
115+
if: ${{ inputs.arch != 's390x' }}
116+
uses: ./.github/workflows/test-progs-asan.yml
117+
needs: [build]
118+
with:
119+
runs_on: ${{ inputs.runs_on }}
120+
arch: ${{ inputs.arch }}
121+
gcc_version: ${{ inputs.gcc_version }}
122+
llvm_version: ${{ inputs.llvm_version }}
123+
toolchain: ${{ inputs.toolchain }}
124+
toolchain_full: ${{ inputs.toolchain_full }}
111125

112126
veristat-kernel:
113127
if: ${{ inputs.run_veristat }}
@@ -176,4 +190,3 @@ jobs:
176190
toolchain: ${{ inputs.toolchain }}
177191
toolchain_full: ${{ inputs.toolchain_full }}
178192
download_sources: ${{ inputs.download_sources }}
179-

.github/workflows/kernel-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ on:
3131
required: true
3232
type: number
3333
description: In case a test runs for too long, after how many seconds shall we timeout and error.
34+
llvm_version:
35+
required: true
36+
type: string
3437

3538
jobs:
3639
test:
@@ -74,6 +77,7 @@ jobs:
7477
ARCH: ${{ inputs.arch }}
7578
DEPLOYMENT: ${{ env.DEPLOYMENT }}
7679
KERNEL_TEST: ${{ inputs.test }}
80+
LLVM_VERSION: ${{ inputs.llvm_version }}
7781
SELFTESTS_BPF: ${{ github.workspace }}/selftests/bpf
7882
VMTEST_CONFIGS: ${{ github.workspace }}/ci/vmtest/configs
7983
VMTEST_MEMORY: 5G
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: test_progs with ASAN
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
arch:
7+
required: true
8+
type: string
9+
description: The architecture to build against, e.g x86_64, aarch64, s390x...
10+
toolchain_full:
11+
required: true
12+
type: string
13+
description: The toolchain and for llvm, its version, e.g gcc, llvm-15
14+
toolchain:
15+
required: true
16+
type: string
17+
description: The toolchain, e.g gcc, llvm
18+
runs_on:
19+
required: true
20+
type: string
21+
description: The runners to run the test on. This is a json string representing an array of labels.
22+
gcc_version:
23+
required: true
24+
type: string
25+
description: GCC version to install
26+
llvm_version:
27+
required: true
28+
type: string
29+
description: LLVM version to install
30+
31+
jobs:
32+
build:
33+
name: build test_progs with ASAN
34+
runs-on:
35+
- ${{ format('codebuild-bpf-ci-{0}-{1}', github.run_id, github.run_attempt) }}
36+
- image:${{ inputs.arch == 'aarch64' && 'custom-arm-ghcr.io/kernel-patches/runner:kbuilder-debian-aarch64'
37+
|| 'custom-linux-ghcr.io/kernel-patches/runner:kbuilder-debian-x86_64' }}
38+
env:
39+
ARCH: ${{ inputs.arch }}
40+
ARTIFACTS_ARCHIVE: ${{ github.workspace }}/selftests-bpf-asan-${{ inputs.arch }}-${{ inputs.toolchain_full }}.tar.zst
41+
KERNEL_ORIGIN: ${{ github.repository == 'kernel-patches/bpf-rc' && 'https://github.com/kernel-patches/bpf-rc.git'
42+
|| 'https://github.com/kernel-patches/bpf.git'
43+
}}
44+
KERNEL_REVISION: ${{ inputs.download_sources && 'bpf-next' || github.sha }}
45+
REPO_ROOT: ${{ github.workspace }}/src
46+
steps:
47+
48+
- uses: actions/checkout@v6
49+
with:
50+
sparse-checkout: |
51+
.github
52+
ci
53+
54+
- name: Download bpf-next tree @ ${{ env.KERNEL_REVISION }}
55+
uses: libbpf/ci/get-linux-source@v4
56+
with:
57+
dest: ${{ env.REPO_ROOT }}
58+
repo: ${{ env.KERNEL_ORIGIN }}
59+
rev: ${{ env.KERNEL_REVISION }}
60+
61+
- uses: libbpf/ci/patch-kernel@v4
62+
with:
63+
patches-root: '${{ github.workspace }}/ci/diffs'
64+
repo-root: ${{ env.REPO_ROOT }}
65+
66+
- name: Setup build environment
67+
uses: libbpf/ci/setup-build-env@v4
68+
with:
69+
arch: ${{ inputs.arch }}
70+
gcc-version: ${{ inputs.gcc_version }}
71+
llvm-version: ${{ inputs.llvm_version }}
72+
73+
- uses: actions/download-artifact@v4
74+
with:
75+
name: vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}
76+
path: ${{ env.REPO_ROOT }}
77+
78+
- name: Untar artifacts
79+
working-directory: ${{ env.REPO_ROOT }}
80+
run: zstd -d -T0 vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}.tar.zst --stdout | tar -xf -
81+
82+
- name: Build selftests/bpf/test_progs with ASAN
83+
uses: libbpf/ci/build-selftests@v4
84+
env:
85+
KBUILD_OUTPUT: ${{ env.REPO_ROOT }}/kbuild-output
86+
SELFTESTS_BPF_ASAN: 'true'
87+
SELFTESTS_BPF_TARGETS: 'test_progs'
88+
with:
89+
arch: ${{ inputs.arch }}
90+
kernel-root: ${{ env.REPO_ROOT }}
91+
llvm-version: ${{ inputs.llvm_version }}
92+
toolchain: ${{ inputs.toolchain }}
93+
94+
- name: Tar artifacts
95+
id: tar-artifacts
96+
uses: libbpf/ci/tar-artifacts@v4
97+
env:
98+
ARCHIVE_BPF_SELFTESTS: 'true'
99+
ARCHIVE_KBUILD_OUTPUT: '' # emptystring means false
100+
with:
101+
arch: ${{ inputs.arch }}
102+
archive: ${{ env.ARTIFACTS_ARCHIVE }}
103+
kbuild-output: ${{ env.REPO_ROOT }}/kbuild-output
104+
repo-root: ${{ env.REPO_ROOT }}
105+
106+
- uses: actions/upload-artifact@v4
107+
with:
108+
name: selftests-bpf-asan-${{ inputs.arch }}-${{ inputs.toolchain_full }}
109+
if-no-files-found: error
110+
path: ${{ env.ARTIFACTS_ARCHIVE }}
111+
112+
test:
113+
name: test_progs ASAN
114+
runs-on: ${{ fromJSON(inputs.runs_on) }}
115+
needs: [build]
116+
timeout-minutes: 100
117+
env:
118+
ARCH: ${{ inputs.arch }}
119+
REPO_ROOT: ${{ github.workspace }}
120+
REPO_PATH: ""
121+
DEPLOYMENT: ${{ github.repository == 'kernel-patches/bpf' && 'prod' || 'rc' }}
122+
ALLOWLIST_FILE: /tmp/allowlist
123+
DENYLIST_FILE: /tmp/denylist
124+
steps:
125+
- uses: actions/checkout@v4
126+
with:
127+
sparse-checkout: |
128+
.github
129+
ci
130+
131+
- uses: actions/download-artifact@v4
132+
with:
133+
name: vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}
134+
path: ${{ env.REPO_ROOT }}
135+
136+
- name: Untar vmlinux
137+
working-directory: ${{ env.REPO_ROOT }}
138+
run: zstd -d -T0 vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}.tar.zst --stdout | tar -xf -
139+
140+
- uses: actions/download-artifact@v4
141+
with:
142+
name: selftests-bpf-asan-${{ inputs.arch }}-${{ inputs.toolchain_full }}
143+
path: ${{ env.REPO_ROOT }}
144+
145+
- name: Untar test_progs ASAN
146+
working-directory: ${{ env.REPO_ROOT }}
147+
run: zstd -d -T0 selftests-bpf-asan-${{ inputs.arch }}-${{ inputs.toolchain_full }}.tar.zst --stdout | tar -xf -
148+
149+
- name: Run selftests
150+
uses: libbpf/ci/run-vmtest@v4
151+
env:
152+
ARCH: ${{ inputs.arch }}
153+
DEPLOYMENT: ${{ env.DEPLOYMENT }}
154+
LLVM_VERSION: ${{ inputs.llvm_version }}
155+
SELFTESTS_BPF: ${{ github.workspace }}/selftests/bpf
156+
SELFTESTS_BPF_ASAN: 'true'
157+
VMTEST_CONFIGS: ${{ github.workspace }}/ci/vmtest/configs
158+
VMTEST_MEMORY: 5G
159+
VMTEST_NUM_CPUS: 4
160+
TEST_PROGS_WATCHDOG_TIMEOUT: 600
161+
with:
162+
arch: ${{ inputs.arch }}
163+
vmlinuz: '${{ github.workspace }}/vmlinuz'
164+
kernel-root: ${{ env.REPO_ROOT }}
165+
kernel-test: test_progs
166+
kbuild-output: ${{ env.REPO_ROOT }}/kbuild-output

ci/vmtest/configs/run-vmtest.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ ALLOWLIST_FILES=(
3030
DENYLIST_FILES=(
3131
"${SELFTESTS_BPF}/DENYLIST"
3232
"${SELFTESTS_BPF}/DENYLIST.${ARCH}"
33+
"${SELFTESTS_BPF}/DENYLIST.${SELFTESTS_BPF_ASAN:+asan}"
3334
"${VMTEST_CONFIGS}/DENYLIST"
3435
"${VMTEST_CONFIGS}/DENYLIST.${ARCH}"
3536
"${VMTEST_CONFIGS}/DENYLIST.${DEPLOYMENT}"
3637
"${VMTEST_CONFIGS}/DENYLIST.${KERNEL_TEST}"
38+
"${VMTEST_CONFIGS}/DENYLIST.${SELFTESTS_BPF_ASAN:+asan}"
3739
)
3840

3941
# Export pipe-separated strings, because bash doesn't support array export
4042
export SELFTESTS_BPF_ALLOWLIST_FILES=$(IFS="|"; echo "${ALLOWLIST_FILES[*]}")
4143
export SELFTESTS_BPF_DENYLIST_FILES=$(IFS="|"; echo "${DENYLIST_FILES[*]}")
42-

0 commit comments

Comments
 (0)