Skip to content

Commit 1975213

Browse files
author
Nobody
committed
adding ci files
1 parent 3b3d653 commit 1975213

22 files changed

+86347
-18
lines changed

.github/workflows/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
VM_Test:
12+
timeout-minutes: 100
13+
runs-on: ubuntu-latest
14+
env:
15+
PROJECT_NAME: 'libbpf'
16+
AUTHOR_EMAIL: "$(git log -1 --pretty=\"%aE\")"
17+
KERNEL: LATEST
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: install
22+
run: sudo apt-get update && sudo apt-get install aptitude qemu-kvm zstd binutils-dev elfutils libcap-dev libelf-dev libdw-dev python3-docutils
23+
- name: Get bpf-next source
24+
if: ${{ github.repository != 'kernel-patches/bpf' }}
25+
uses: actions/checkout@v2
26+
with:
27+
repository: kernel-patches/bpf
28+
ref: 'bpf-next'
29+
path: 'linux'
30+
- name: Move linux source in place
31+
if: ${{ github.repository != 'kernel-patches/bpf' }}
32+
run: rsync --exclude .git -av linux/. . && rm -rf linux
33+
- name: Kernel LATEST + selftests
34+
run: export REPO_ROOT=$GITHUB_WORKSPACE; export CI_ROOT=$REPO_ROOT/travis-ci; export VMTEST_ROOT=$CI_ROOT/vmtest; ${CI_ROOT}/vmtest/run_vmtest.sh || exit 1

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/managers/debian.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
3+
PHASES=(${@:-SETUP RUN RUN_ASAN CLEANUP})
4+
DEBIAN_RELEASE="${DEBIAN_RELEASE:-testing}"
5+
CONT_NAME="${CONT_NAME:-libbpf-debian-$DEBIAN_RELEASE}"
6+
ENV_VARS="${ENV_VARS:-}"
7+
DOCKER_RUN="${DOCKER_RUN:-docker run}"
8+
REPO_ROOT="${REPO_ROOT:-$PWD}"
9+
ADDITIONAL_DEPS=(clang pkg-config gcc-10)
10+
CFLAGS="-g -O2 -Werror -Wall"
11+
12+
function info() {
13+
echo -e "\033[33;1m$1\033[0m"
14+
}
15+
16+
function error() {
17+
echo -e "\033[31;1m$1\033[0m"
18+
}
19+
20+
function docker_exec() {
21+
docker exec $ENV_VARS -it $CONT_NAME "$@"
22+
}
23+
24+
set -eu
25+
26+
source "$(dirname $0)/travis_wait.bash"
27+
28+
for phase in "${PHASES[@]}"; do
29+
case $phase in
30+
SETUP)
31+
info "Setup phase"
32+
info "Using Debian $DEBIAN_RELEASE"
33+
34+
# Install Docker Engine
35+
sudo apt-get update
36+
sudo apt-get install \
37+
apt-transport-https \
38+
ca-certificates \
39+
curl \
40+
gnupg-agent \
41+
software-properties-common
42+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
43+
sudo add-apt-repository \
44+
"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
45+
sudo apt-get update
46+
sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
47+
docker --version
48+
49+
docker pull debian:$DEBIAN_RELEASE
50+
info "Starting container $CONT_NAME"
51+
$DOCKER_RUN -v $REPO_ROOT:/build:rw \
52+
-w /build --privileged=true --name $CONT_NAME \
53+
-dit --net=host debian:$DEBIAN_RELEASE /bin/bash
54+
docker_exec bash -c "echo deb-src http://deb.debian.org/debian $DEBIAN_RELEASE main >>/etc/apt/sources.list"
55+
docker_exec apt-get -y update
56+
docker_exec apt-get -y build-dep libelf-dev
57+
docker_exec apt-get -y install libelf-dev
58+
docker_exec apt-get -y install "${ADDITIONAL_DEPS[@]}"
59+
;;
60+
RUN|RUN_CLANG|RUN_GCC10|RUN_ASAN|RUN_CLANG_ASAN|RUN_GCC10_ASAN)
61+
if [[ "$phase" = *"CLANG"* ]]; then
62+
ENV_VARS="-e CC=clang -e CXX=clang++"
63+
CC="clang"
64+
elif [[ "$phase" = *"GCC10"* ]]; then
65+
ENV_VARS="-e CC=gcc-10 -e CXX=g++-10"
66+
CC="gcc-10"
67+
else
68+
CFLAGS="${CFLAGS} -Wno-stringop-truncation"
69+
fi
70+
if [[ "$phase" = *"ASAN"* ]]; then
71+
CFLAGS="${CFLAGS} -fsanitize=address,undefined"
72+
fi
73+
docker_exec mkdir build install
74+
docker_exec ${CC:-cc} --version
75+
info "build"
76+
docker_exec make -j$((4*$(nproc))) CFLAGS="${CFLAGS}" -C ./src -B OBJDIR=../build
77+
info "ldd build/libbpf.so:"
78+
docker_exec ldd build/libbpf.so
79+
if ! docker_exec ldd build/libbpf.so | grep -q libelf; then
80+
error "No reference to libelf.so in libbpf.so!"
81+
exit 1
82+
fi
83+
info "install"
84+
docker_exec make -j$((4*$(nproc))) -C src OBJDIR=../build DESTDIR=../install install
85+
docker_exec rm -rf build install
86+
;;
87+
CLEANUP)
88+
info "Cleanup phase"
89+
docker stop $CONT_NAME
90+
docker rm -f $CONT_NAME
91+
;;
92+
*)
93+
echo >&2 "Unknown phase '$phase'"
94+
exit 1
95+
esac
96+
done

travis-ci/managers/travis_wait.bash

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This was borrowed from https://github.com/travis-ci/travis-build/tree/master/lib/travis/build/bash
2+
# to get around https://github.com/travis-ci/travis-ci/issues/9979. It should probably be removed
3+
# as soon as Travis CI has started to provide an easy way to export the functions to bash scripts.
4+
5+
travis_jigger() {
6+
local cmd_pid="${1}"
7+
shift
8+
local timeout="${1}"
9+
shift
10+
local count=0
11+
12+
echo -e "\\n"
13+
14+
while [[ "${count}" -lt "${timeout}" ]]; do
15+
count="$((count + 1))"
16+
echo -ne "Still running (${count} of ${timeout}): ${*}\\r"
17+
sleep 60
18+
done
19+
20+
echo -e "\\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"${*}\"${ANSI_RESET}\\n"
21+
kill -9 "${cmd_pid}"
22+
}
23+
24+
travis_wait() {
25+
local timeout="${1}"
26+
27+
if [[ "${timeout}" =~ ^[0-9]+$ ]]; then
28+
shift
29+
else
30+
timeout=20
31+
fi
32+
33+
local cmd=("${@}")
34+
local log_file="travis_wait_${$}.log"
35+
36+
"${cmd[@]}" &>"${log_file}" &
37+
local cmd_pid="${!}"
38+
39+
travis_jigger "${!}" "${timeout}" "${cmd[@]}" &
40+
local jigger_pid="${!}"
41+
local result
42+
43+
{
44+
set +e
45+
wait "${cmd_pid}" 2>/dev/null
46+
result="${?}"
47+
ps -p"${jigger_pid}" &>/dev/null && kill "${jigger_pid}"
48+
set -e
49+
}
50+
51+
if [[ "${result}" -eq 0 ]]; then
52+
echo -e "\\n${ANSI_GREEN}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}"
53+
else
54+
echo -e "\\n${ANSI_RED}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}"
55+
fi
56+
57+
echo -e "\\n${ANSI_GREEN}Log:${ANSI_RESET}\\n"
58+
cat "${log_file}"
59+
60+
return "${result}"
61+
}

travis-ci/managers/ubuntu.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
set -eux
3+
4+
RELEASE="focal"
5+
6+
echo "deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricted universe multiverse" >>/etc/apt/sources.list
7+
8+
apt-get update
9+
apt-get -y build-dep libelf-dev
10+
apt-get install -y libelf-dev pkg-config
11+
12+
source "$(dirname $0)/travis_wait.bash"
13+
14+
cd $REPO_ROOT
15+
16+
CFLAGS="-g -O2 -Werror -Wall -fsanitize=address,undefined -Wno-stringop-truncation"
17+
mkdir build install
18+
cc --version
19+
make -j$((4*$(nproc))) CFLAGS="${CFLAGS}" -C ./src -B OBJDIR=../build
20+
ldd build/libbpf.so
21+
if ! ldd build/libbpf.so | grep -q libelf; then
22+
echo "FAIL: No reference to libelf.so in libbpf.so!"
23+
exit 1
24+
fi
25+
make -j$((4*$(nproc))) -C src OBJDIR=../build DESTDIR=../install install
26+
rm -rf build install

travis-ci/vmtest/build_pahole.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
source $(cd $(dirname $0) && pwd)/helpers.sh
6+
7+
travis_fold start build_pahole "Building pahole"
8+
9+
CWD=$(pwd)
10+
REPO_PATH=$1
11+
PAHOLE_ORIGIN=https://git.kernel.org/pub/scm/devel/pahole/pahole.git
12+
13+
mkdir -p ${REPO_PATH}
14+
cd ${REPO_PATH}
15+
git init
16+
git remote add origin ${PAHOLE_ORIGIN}
17+
git fetch origin
18+
git checkout master
19+
20+
# temporary fix up for pahole until official 1.22 release
21+
sed -i 's/DDWARVES_MINOR_VERSION=21/DDWARVES_MINOR_VERSION=22/' CMakeLists.txt
22+
23+
mkdir -p build
24+
cd build
25+
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -D__LIB=lib ..
26+
make -j$((4*$(nproc))) all
27+
sudo make install
28+
29+
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:/usr/local/lib
30+
ldd $(which pahole)
31+
pahole --version
32+
33+
travis_fold end build_pahole

travis-ci/vmtest/build_selftests.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
source $(cd $(dirname $0) && pwd)/helpers.sh
6+
7+
travis_fold start prepare_selftests "Building selftests"
8+
9+
LLVM_VER=14
10+
LIBBPF_PATH="${REPO_ROOT}"
11+
12+
PREPARE_SELFTESTS_SCRIPT=${VMTEST_ROOT}/prepare_selftests-${KERNEL}.sh
13+
if [ -f "${PREPARE_SELFTESTS_SCRIPT}" ]; then
14+
(cd "${REPO_ROOT}/tools/testing/selftests/bpf" && ${PREPARE_SELFTESTS_SCRIPT})
15+
fi
16+
17+
if [[ "${KERNEL}" = 'LATEST' ]]; then
18+
VMLINUX_H=
19+
else
20+
VMLINUX_H=${VMTEST_ROOT}/vmlinux.h
21+
fi
22+
23+
make \
24+
CLANG=clang-${LLVM_VER} \
25+
LLC=llc-${LLVM_VER} \
26+
LLVM_STRIP=llvm-strip-${LLVM_VER} \
27+
VMLINUX_BTF="${VMLINUX_BTF}" \
28+
VMLINUX_H=${VMLINUX_H} \
29+
-C "${REPO_ROOT}/tools/testing/selftests/bpf" \
30+
-j $((2*$(nproc)))
31+
mkdir ${LIBBPF_PATH}/selftests
32+
cp -R "${REPO_ROOT}/tools/testing/selftests/bpf" \
33+
${LIBBPF_PATH}/selftests
34+
cd ${LIBBPF_PATH}
35+
rm selftests/bpf/.gitignore
36+
git add selftests
37+
38+
git add "${VMTEST_ROOT}/configs/blacklist"
39+
40+
travis_fold end prepare_selftests
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
source $(cd $(dirname $0) && pwd)/helpers.sh
6+
7+
CWD=$(pwd)
8+
LIBBPF_PATH=$(pwd)
9+
REPO_PATH=$1
10+
11+
BPF_NEXT_ORIGIN=https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git
12+
LINUX_SHA=$(cat ${LIBBPF_PATH}/CHECKPOINT-COMMIT)
13+
SNAPSHOT_URL=https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/snapshot/bpf-next-${LINUX_SHA}.tar.gz
14+
15+
echo REPO_PATH = ${REPO_PATH}
16+
echo LINUX_SHA = ${LINUX_SHA}
17+
18+
if [ ! -d "${REPO_PATH}" ]; then
19+
echo
20+
travis_fold start pull_kernel_srcs "Fetching kernel sources"
21+
22+
mkdir -p $(dirname "${REPO_PATH}")
23+
cd $(dirname "${REPO_PATH}")
24+
# attempt to fetch desired bpf-next repo snapshot
25+
if wget ${SNAPSHOT_URL} ; then
26+
tar xf bpf-next-${LINUX_SHA}.tar.gz
27+
mv bpf-next-${LINUX_SHA} $(basename ${REPO_PATH})
28+
else
29+
# but fallback to git fetch approach if that fails
30+
mkdir -p ${REPO_PATH}
31+
cd ${REPO_PATH}
32+
git init
33+
git remote add bpf-next ${BPF_NEXT_ORIGIN}
34+
# try shallow clone first
35+
git fetch --depth 32 bpf-next
36+
# check if desired SHA exists
37+
if ! git cat-file -e ${LINUX_SHA}^{commit} ; then
38+
# if not, fetch all of bpf-next; slow and painful
39+
git fetch bpf-next
40+
fi
41+
git reset --hard ${LINUX_SHA}
42+
fi
43+
44+
travis_fold end pull_kernel_srcs
45+
fi

travis-ci/vmtest/configs/INDEX

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
INDEX https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/INDEX
2+
libbpf-vmtest-rootfs-2020.09.27.tar.zst https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/libbpf-vmtest-rootfs-2020.09.27.tar.zst
3+
vmlinux-4.9.0.zst https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinux-4.9.0.zst
4+
vmlinux-5.5.0-rc6.zst https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinux-5.5.0-rc6.zst
5+
vmlinux-5.5.0.zst https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinux-5.5.0.zst
6+
vmlinuz-5.5.0-rc6 https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinuz-5.5.0-rc6
7+
vmlinuz-5.5.0 https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinuz-5.5.0
8+
vmlinuz-4.9.0 https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinuz-4.9.0

0 commit comments

Comments
 (0)