Skip to content

Commit 6445a5a

Browse files
committed
adding/updating ci files
1 parent 80fc02e commit 6445a5a

File tree

6 files changed

+309
-18
lines changed

6 files changed

+309
-18
lines changed

.github/workflows/test.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: bpf-ci
2+
3+
on:
4+
pull_request:
5+
6+
concurrency:
7+
group: ci-test-${{ github.head_ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
llvm-toolchain:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
llvm: ${{ steps.llvm-toolchain-impl.outputs.version }}
15+
steps:
16+
- id: llvm-version
17+
uses: libbpf/ci/get-llvm-version@master
18+
- id: llvm-toolchain-impl
19+
shell: bash
20+
run: echo "::set-output name=version::llvm-${{ steps.llvm-version.outputs.version }}"
21+
set-matrix:
22+
needs: llvm-toolchain
23+
runs-on: ubuntu-latest
24+
outputs:
25+
build-matrix: ${{ steps.set-matrix-impl.outputs.build_matrix }}
26+
test-matrix: ${{ steps.set-matrix-impl.outputs.test_matrix }}
27+
steps:
28+
- id: set-matrix-impl
29+
shell: python3 -I {0}
30+
run: |
31+
from json import dumps
32+
33+
matrix = [
34+
{"kernel": "LATEST", "runs_on": ["ubuntu-latest", "self-hosted"], "arch": "x86_64", "toolchain": "gcc"},
35+
{"kernel": "LATEST", "runs_on": ["ubuntu-latest", "self-hosted"], "arch": "x86_64", "toolchain": "${{ needs.llvm-toolchain.outputs.llvm }}"},
36+
{"kernel": "LATEST", "runs_on": ["z15", "self-hosted"], "arch": "s390x", "toolchain": "gcc"},
37+
]
38+
self_hosted_repos = [
39+
"kernel-patches/bpf",
40+
"kernel-patches/vmtest",
41+
]
42+
43+
# Only a few repository within "kernel-patches" use self-hosted runners.
44+
if "${{ github.repository_owner }}" != "kernel-patches" or "${{ github.repository }}" not in self_hosted_repos:
45+
# Outside of those repositories, remove the self-hosted label and skip
46+
# any testing on s390x, as no suitable runners will be available.
47+
for idx in range(len(matrix) - 1, -1, -1):
48+
if "z15" in matrix[idx]["runs_on"]:
49+
del matrix[idx]
50+
else:
51+
matrix[idx]["runs_on"].remove("self-hosted")
52+
53+
build_matrix = {"include": matrix}
54+
print(f"::set-output name=build_matrix::{dumps(build_matrix)}")
55+
56+
tests = ["test_progs", "test_progs_no_alu32", "test_maps", "test_verifier"]
57+
test_matrix = {"include": [{**config, **{"test": test}}
58+
for config in matrix
59+
for test in tests]}
60+
print(f"::set-output name=test_matrix::{dumps(test_matrix)}")
61+
build:
62+
name: build for ${{ matrix.arch }} with ${{ matrix.toolchain }}
63+
needs: set-matrix
64+
runs-on: ${{ matrix.runs_on }}
65+
timeout-minutes: 100
66+
strategy:
67+
fail-fast: false
68+
matrix: ${{ fromJSON(needs.set-matrix.outputs.build-matrix) }}
69+
env:
70+
KERNEL: ${{ matrix.kernel }}
71+
REPO_ROOT: ${{ github.workspace }}
72+
REPO_PATH: ""
73+
steps:
74+
- uses: actions/checkout@v2
75+
- if: ${{ github.repository == 'kernel-patches/vmtest' }}
76+
name: Download bpf-next tree
77+
uses: libbpf/ci/get-linux-source@master
78+
with:
79+
dest: '.kernel'
80+
- if: ${{ github.repository == 'kernel-patches/vmtest' }}
81+
name: Move linux source in place
82+
shell: bash
83+
run: |
84+
rm -rf .kernel/.git
85+
cp -rf .kernel/. .
86+
rm -rf .kernel
87+
- uses: libbpf/ci/patch-kernel@master
88+
with:
89+
patches-root: '${{ github.workspace }}/travis-ci/diffs'
90+
repo-root: '${{ github.workspace }}'
91+
- name: Setup build environment
92+
uses: libbpf/ci/setup-build-env@master
93+
- name: Build kernel image
94+
uses: libbpf/ci/build-linux@master
95+
with:
96+
arch: ${{ matrix.arch }}
97+
toolchain: ${{ matrix.toolchain }}
98+
- name: Build selftests
99+
uses: libbpf/ci/build-selftests@master
100+
with:
101+
vmlinux_btf: ${{ github.workspace }}/vmlinux
102+
toolchain: ${{ matrix.toolchain }}
103+
- name: Build samples
104+
uses: libbpf/ci/build-samples@master
105+
with:
106+
vmlinux_btf: ${{ github.workspace }}/vmlinux
107+
toolchain: ${{ matrix.toolchain }}
108+
- name: Tar artifacts
109+
run: |
110+
file_list=""
111+
if [ "${{ github.repository }}" == "kernel-patches/vmtest" ]; then
112+
# Package up a bunch of additional infrastructure to support running
113+
# 'make kernelrelease' and bpf tool checks later on.
114+
file_list="$(find . -iname Makefile | xargs) \
115+
scripts/ \
116+
tools/testing/selftests/bpf/ \
117+
tools/include/ \
118+
tools/bpf/bpftool/";
119+
fi
120+
121+
tar -czf vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}.tar.gz \
122+
.config \
123+
arch/*/boot/bzImage \
124+
include/config/auto.conf \
125+
include/generated/autoconf.h \
126+
${file_list} \
127+
--exclude '*.h' \
128+
selftests/bpf/ \
129+
vmlinux
130+
- uses: actions/upload-artifact@v3
131+
with:
132+
name: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}
133+
if-no-files-found: error
134+
path: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}.tar.gz
135+
test:
136+
name: ${{ matrix.test }} on ${{ matrix.arch }} with ${{ matrix.toolchain }}
137+
needs: [set-matrix, build]
138+
strategy:
139+
fail-fast: false
140+
matrix: ${{ fromJSON(needs.set-matrix.outputs.test-matrix) }}
141+
runs-on: ${{ matrix.runs_on }}
142+
timeout-minutes: 100
143+
env:
144+
KERNEL: ${{ matrix.kernel }}
145+
REPO_ROOT: ${{ github.workspace }}
146+
REPO_PATH: ""
147+
steps:
148+
- uses: actions/checkout@main
149+
- uses: actions/download-artifact@v3
150+
with:
151+
name: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}
152+
path: .
153+
- name: Untar artifacts
154+
run: tar -xzf vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}.tar.gz
155+
- name: Prepare rootfs
156+
uses: libbpf/ci/prepare-rootfs@master
157+
with:
158+
project-name: 'libbpf'
159+
arch: ${{ matrix.arch }}
160+
kernel: ${{ matrix.kernel }}
161+
kernel-root: '.'
162+
image-output: '/tmp/root.img'
163+
test: ${{ matrix.test }}
164+
- name: Run selftests
165+
uses: libbpf/ci/run-qemu@master
166+
with:
167+
arch: ${{ matrix.arch}}
168+
img: '/tmp/root.img'
169+
vmlinuz: '${{ github.workspace }}/vmlinuz'
170+
kernel-root: '.'

README

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +0,0 @@
1-
Linux kernel
2-
============
3-
4-
There are several guides for kernel developers and users. These guides can
5-
be rendered in a number of formats, like HTML and PDF. Please read
6-
Documentation/admin-guide/README.rst first.
7-
8-
In order to build the documentation, use ``make htmldocs`` or
9-
``make pdfdocs``. The formatted documentation can also be read online at:
10-
11-
https://www.kernel.org/doc/html/latest/
12-
13-
There are various text files in the Documentation/ subdirectory,
14-
several of them using the Restructured Text markup notation.
15-
16-
Please read the Documentation/process/changes.rst file, as it contains the
17-
requirements for building and running the kernel, and information about
18-
the problems which may result by upgrading your kernel.

travis-ci/vmtest/configs/DENYLIST

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# TEMPORARY
2+
btf_dump/btf_dump: syntax
3+
kprobe_multi_test/bench_attach
4+
core_reloc/enum64val
5+
core_reloc/size___diff_sz
6+
core_reloc/type_based___diff_sz
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
tc_redirect/tc_redirect_dtime # very flaky
2+
lru_bug # not yet in bpf-next denylist
3+
usdt/basic # failing verifier due to bounds check after LLVM update
4+
usdt/multispec # same as above

travis-ci/vmtest/helpers.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# $1 - start or end
2+
# $2 - fold identifier, no spaces
3+
# $3 - fold section description
4+
foldable() {
5+
local YELLOW='\033[1;33m'
6+
local NOCOLOR='\033[0m'
7+
if [ $1 = "start" ]; then
8+
line="::group::$2"
9+
if [ ! -z "${3:-}" ]; then
10+
line="$line - ${YELLOW}$3${NOCOLOR}"
11+
fi
12+
else
13+
line="::endgroup::"
14+
fi
15+
echo -e "$line"
16+
}
17+
18+
__print() {
19+
local TITLE=""
20+
if [[ -n $2 ]]; then
21+
TITLE=" title=$2"
22+
fi
23+
echo "::$1${TITLE}::$3"
24+
}
25+
26+
# $1 - title
27+
# $2 - message
28+
print_error() {
29+
__print error $1 $2
30+
}
31+
32+
# $1 - title
33+
# $2 - message
34+
print_notice() {
35+
__print notice $1 $2
36+
}

travis-ci/vmtest/run_selftests.sh

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
source $(cd $(dirname $0) && pwd)/helpers.sh
6+
7+
ARCH=$(uname -m)
8+
9+
STATUS_FILE=/exitstatus
10+
11+
read_lists() {
12+
(for path in "$@"; do
13+
if [[ -s "$path" ]]; then
14+
cat "$path"
15+
fi;
16+
done) | cut -d'#' -f1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -s '\n' ','
17+
}
18+
19+
TEST_PROGS_ARGS=""
20+
# Disabled due to issue
21+
# if [[ "$(nproc)" -gt 2 ]]; then
22+
# TEST_PROGS_ARGS="-j"
23+
# fi
24+
25+
test_progs() {
26+
foldable start test_progs "Testing test_progs"
27+
# "&& true" does not change the return code (it is not executed
28+
# if the Python script fails), but it prevents exiting on a
29+
# failure due to the "set -e".
30+
./test_progs ${DENYLIST:+-d"$DENYLIST"} ${ALLOWLIST:+-a"$ALLOWLIST"} ${TEST_PROGS_ARGS} && true
31+
echo "test_progs:$?" >>"${STATUS_FILE}"
32+
foldable end test_progs
33+
}
34+
35+
test_progs_no_alu32() {
36+
foldable start test_progs-no_alu32 "Testing test_progs-no_alu32"
37+
./test_progs-no_alu32 ${DENYLIST:+-d"$DENYLIST"} ${ALLOWLIST:+-a"$ALLOWLIST"} ${TEST_PROGS_ARGS} && true
38+
echo "test_progs-no_alu32:$?" >>"${STATUS_FILE}"
39+
foldable end test_progs-no_alu32
40+
}
41+
42+
test_maps() {
43+
foldable start test_maps "Testing test_maps"
44+
taskset 0xF ./test_maps && true
45+
echo "test_maps:$?" >>"${STATUS_FILE}"
46+
foldable end test_maps
47+
}
48+
49+
test_verifier() {
50+
foldable start test_verifier "Testing test_verifier"
51+
./test_verifier && true
52+
echo "test_verifier:$?" >>"${STATUS_FILE}"
53+
foldable end test_verifier
54+
}
55+
56+
foldable end vm_init
57+
58+
foldable start kernel_config "Kconfig"
59+
60+
zcat /proc/config.gz
61+
62+
foldable end kernel_config
63+
64+
configs_path=${PROJECT_NAME}/selftests/bpf
65+
local_configs_path=${PROJECT_NAME}/vmtest/configs
66+
DENYLIST=$(read_lists \
67+
"$configs_path/DENYLIST" \
68+
"$configs_path/DENYLIST.${ARCH}" \
69+
"$local_configs_path/DENYLIST" \
70+
"$local_configs_path/DENYLIST.${ARCH}" \
71+
)
72+
ALLOWLIST=$(read_lists \
73+
"$configs_path/ALLOWLIST" \
74+
"$configs_path/ALLOWLIST.${ARCH}" \
75+
"$local_configs_path/ALLOWLIST" \
76+
"$local_configs_path/ALLOWLIST.${ARCH}" \
77+
)
78+
79+
echo "DENYLIST: ${DENYLIST}"
80+
echo "ALLOWLIST: ${ALLOWLIST}"
81+
82+
cd ${PROJECT_NAME}/selftests/bpf
83+
84+
if [ $# -eq 0 ]; then
85+
test_progs
86+
test_progs_no_alu32
87+
test_maps
88+
test_verifier
89+
else
90+
for test_name in "$@"; do
91+
"${test_name}"
92+
done
93+
fi

0 commit comments

Comments
 (0)