mirror of
https://gitee.com/openharmony/third_party_libbpf
synced 2024-10-07 06:23:25 +00:00
Migrate vmtest to modular actions in libbpf/ci
This commit is contained in:
parent
93e89b3474
commit
7e89be4022
30
.github/actions/build-selftests/action.yml
vendored
Normal file
30
.github/actions/build-selftests/action.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: 'build-selftests'
|
||||
description: 'Build BPF selftests'
|
||||
inputs:
|
||||
repo-path:
|
||||
description: 'where is the source code'
|
||||
required: true
|
||||
kernel:
|
||||
description: 'kernel version or LATEST'
|
||||
required: true
|
||||
default: 'LATEST'
|
||||
vmlinux:
|
||||
description: 'where is vmlinux file'
|
||||
required: true
|
||||
default: '${{ github.workspace }}/vmlinux'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- shell: bash
|
||||
run: |
|
||||
echo "::group::Setup Env"
|
||||
sudo apt-get install -y qemu-kvm zstd binutils-dev elfutils libcap-dev libelf-dev libdw-dev python3-docutils
|
||||
echo "::endgroup::"
|
||||
- shell: bash
|
||||
run: |
|
||||
export KERNEL=${{ inputs.kernel }}
|
||||
export REPO_ROOT="${{ github.workspace }}"
|
||||
export REPO_PATH="${{ inputs.repo-path }}"
|
||||
export VMLINUX_BTF="${{ inputs.vmlinux }}"
|
||||
${{ github.action_path }}/build_selftests.sh
|
@ -2,16 +2,16 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source $(cd $(dirname $0) && pwd)/helpers.sh
|
||||
THISDIR="$(cd $(dirname $0) && pwd)"
|
||||
|
||||
source ${THISDIR}/helpers.sh
|
||||
|
||||
travis_fold start prepare_selftests "Building selftests"
|
||||
|
||||
sudo apt-get -y install python3-docutils # for rst2man
|
||||
|
||||
LLVM_VER=14
|
||||
LIBBPF_PATH="${REPO_ROOT}"
|
||||
|
||||
PREPARE_SELFTESTS_SCRIPT=${VMTEST_ROOT}/prepare_selftests-${KERNEL}.sh
|
||||
PREPARE_SELFTESTS_SCRIPT=${THISDIR}/prepare_selftests-${KERNEL}.sh
|
||||
if [ -f "${PREPARE_SELFTESTS_SCRIPT}" ]; then
|
||||
(cd "${REPO_ROOT}/${REPO_PATH}/tools/testing/selftests/bpf" && ${PREPARE_SELFTESTS_SCRIPT})
|
||||
fi
|
||||
@ -19,9 +19,10 @@ fi
|
||||
if [[ "${KERNEL}" = 'LATEST' ]]; then
|
||||
VMLINUX_H=
|
||||
else
|
||||
VMLINUX_H=${VMTEST_ROOT}/vmlinux.h
|
||||
VMLINUX_H=${THISDIR}/vmlinux.h
|
||||
fi
|
||||
|
||||
cd ${REPO_ROOT}/${REPO_PATH}
|
||||
make \
|
||||
CLANG=clang-${LLVM_VER} \
|
||||
LLC=llc-${LLVM_VER} \
|
||||
@ -29,7 +30,8 @@ make \
|
||||
VMLINUX_BTF="${VMLINUX_BTF}" \
|
||||
VMLINUX_H=${VMLINUX_H} \
|
||||
-C "${REPO_ROOT}/${REPO_PATH}/tools/testing/selftests/bpf" \
|
||||
-j $((4*$(nproc))) >/dev/null
|
||||
-j $((4*$(nproc))) > /dev/null
|
||||
cd -
|
||||
mkdir ${LIBBPF_PATH}/selftests
|
||||
cp -R "${REPO_ROOT}/${REPO_PATH}/tools/testing/selftests/bpf" \
|
||||
${LIBBPF_PATH}/selftests
|
||||
@ -37,6 +39,4 @@ cd ${LIBBPF_PATH}
|
||||
rm selftests/bpf/.gitignore
|
||||
git add selftests
|
||||
|
||||
git add "${VMTEST_ROOT}"/configs/blacklist/BLACKLIST-* "${VMTEST_ROOT}"/configs/whitelist/WHITELIST-*
|
||||
|
||||
travis_fold end prepare_selftests
|
44
.github/actions/build-selftests/helpers.sh
vendored
Normal file
44
.github/actions/build-selftests/helpers.sh
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
# $1 - start or end
|
||||
# $2 - fold identifier, no spaces
|
||||
# $3 - fold section description
|
||||
travis_fold() {
|
||||
local YELLOW='\033[1;33m'
|
||||
local NOCOLOR='\033[0m'
|
||||
if [ -z ${GITHUB_WORKFLOW+x} ]; then
|
||||
echo travis_fold:$1:$2
|
||||
if [ ! -z "${3:-}" ]; then
|
||||
echo -e "${YELLOW}$3${NOCOLOR}"
|
||||
fi
|
||||
echo
|
||||
else
|
||||
if [ $1 = "start" ]; then
|
||||
line="::group::$2"
|
||||
if [ ! -z "${3:-}" ]; then
|
||||
line="$line - ${YELLOW}$3${NOCOLOR}"
|
||||
fi
|
||||
else
|
||||
line="::endgroup::"
|
||||
fi
|
||||
echo -e "$line"
|
||||
fi
|
||||
}
|
||||
|
||||
__print() {
|
||||
local TITLE=""
|
||||
if [[ -n $2 ]]; then
|
||||
TITLE=" title=$2"
|
||||
fi
|
||||
echo "::$1${TITLE}::$3"
|
||||
}
|
||||
|
||||
# $1 - title
|
||||
# $2 - message
|
||||
print_error() {
|
||||
__print error $1 $2
|
||||
}
|
||||
|
||||
# $1 - title
|
||||
# $2 - message
|
||||
print_notice() {
|
||||
__print notice $1 $2
|
||||
}
|
87
.github/actions/vmtest/action.yml
vendored
87
.github/actions/vmtest/action.yml
vendored
@ -5,31 +5,78 @@ inputs:
|
||||
description: 'kernel version or LATEST'
|
||||
required: true
|
||||
default: 'LATEST'
|
||||
kernel-rev:
|
||||
description: 'CHECKPOINT or rev/tag/branch'
|
||||
arch:
|
||||
description: 'what arch to test'
|
||||
required: true
|
||||
default: 'CHECKPOINT'
|
||||
kernel-origin:
|
||||
description: 'kernel repo'
|
||||
required: true
|
||||
default: 'https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git'
|
||||
default: 'x86_64'
|
||||
pahole:
|
||||
description: 'pahole rev/tag/branch'
|
||||
description: 'pahole rev or master'
|
||||
required: true
|
||||
default: 'master'
|
||||
pahole-origin:
|
||||
description: 'pahole repo'
|
||||
required: true
|
||||
default: 'https://git.kernel.org/pub/scm/devel/pahole/pahole.git'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- run: |
|
||||
source /tmp/ci_setup
|
||||
export KERNEL=${{ inputs.kernel }}
|
||||
export KERNEL_BRANCH=${{ inputs.kernel-rev }}
|
||||
export KERNEL_ORIGIN=${{ inputs.kernel-origin }}
|
||||
export PAHOLE_BRANCH=${{ inputs.pahole }}
|
||||
export PAHOLE_ORIGIN=${{ inputs.pahole-origin }}
|
||||
$CI_ROOT/vmtest/run_vmtest.sh
|
||||
# setup envinronment
|
||||
- name: Setup environment
|
||||
uses: libbpf/ci/setup-build-env@master
|
||||
with:
|
||||
pahole: ${{ inputs.pahole }}
|
||||
# 1. download CHECKPOINT kernel source
|
||||
- name: Get checkpoint commit
|
||||
shell: bash
|
||||
run: |
|
||||
cat CHECKPOINT-COMMIT
|
||||
echo "CHECKPOINT=$(cat CHECKPOINT-COMMIT)" >> $GITHUB_ENV
|
||||
- name: Get kernel source at checkpoint
|
||||
uses: libbpf/ci/get-linux-source@master
|
||||
with:
|
||||
repo: 'https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git'
|
||||
rev: ${{ env.CHECKPOINT }}
|
||||
dest: '${{ github.workspace }}/.kernel'
|
||||
- name: Prepare to build BPF selftests
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::group::Prepare buidling selftest"
|
||||
cd .kernel
|
||||
cp ${{ github.workspace }}/travis-ci/vmtest/configs/config-latest.${{ inputs.arch }} .config
|
||||
make olddefconfig && make prepare
|
||||
cd -
|
||||
echo "::endgroup::"
|
||||
# 2. if kernel == LATEST, build kernel image from tree
|
||||
- name: Build kernel image
|
||||
if: ${{ inputs.kernel == 'LATEST' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::group::Build Kernel Image"
|
||||
cd .kernel
|
||||
make -j $((4*$(nproc))) all > /dev/null
|
||||
cp vmlinux ${{ github.workspace }}
|
||||
cd -
|
||||
echo "::endgroup::"
|
||||
# else, just download prebuilt kernel image
|
||||
- name: Download prebuilt kernel
|
||||
if: ${{ inputs.kernel != 'LATEST' }}
|
||||
uses: libbpf/ci/download-vmlinux@master
|
||||
with:
|
||||
kernel: ${{ inputs.kernel }}
|
||||
arch: ${{ inputs.arch }}
|
||||
# 3. build selftests
|
||||
- name: Build BPF selftests
|
||||
uses: ./.github/actions/build-selftests
|
||||
with:
|
||||
repo-path: '.kernel'
|
||||
kernel: ${{ inputs.kernel }}
|
||||
# 4. prepare rootfs
|
||||
- name: prepare rootfs
|
||||
uses: libbpf/ci/prepare-rootfs@master
|
||||
with:
|
||||
kernel: ${{ inputs.kernel }}
|
||||
project-name: 'libbpf'
|
||||
arch: ${{ inputs.arch }}
|
||||
# 5. run selftest in QEMU
|
||||
- name: Run selftests
|
||||
uses: libbpf/ci/run-qemu@master
|
||||
with:
|
||||
img: '/tmp/root.img'
|
||||
vmlinuz: 'vmlinuz'
|
||||
arch: ${{ inputs.arch }}
|
||||
|
81
.github/workflows/build.yml
vendored
Normal file
81
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
name: libbpf-build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
schedule:
|
||||
- cron: '0 18 * * *'
|
||||
|
||||
concurrency:
|
||||
group: ci-build-${{ github.head_ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
|
||||
debian:
|
||||
runs-on: ubuntu-latest
|
||||
name: Debian Build (${{ matrix.name }})
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: default
|
||||
target: RUN
|
||||
- name: ASan+UBSan
|
||||
target: RUN_ASAN
|
||||
- name: clang
|
||||
target: RUN_CLANG
|
||||
- name: clang ASan+UBSan
|
||||
target: RUN_CLANG_ASAN
|
||||
- name: gcc-10
|
||||
target: RUN_GCC10
|
||||
- name: gcc-10 ASan+UBSan
|
||||
target: RUN_GCC10_ASAN
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
name: Checkout
|
||||
- uses: ./.github/actions/setup
|
||||
name: Setup
|
||||
- uses: ./.github/actions/debian
|
||||
name: Build
|
||||
with:
|
||||
target: ${{ matrix.target }}
|
||||
|
||||
ubuntu:
|
||||
runs-on: ubuntu-latest
|
||||
name: Ubuntu Focal Build (${{ matrix.arch }})
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: aarch64
|
||||
- arch: ppc64le
|
||||
- arch: s390x
|
||||
- arch: x86
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
name: Checkout
|
||||
- uses: ./.github/actions/setup
|
||||
name: Pre-Setup
|
||||
- run: source /tmp/ci_setup && sudo -E $CI_ROOT/managers/ubuntu.sh
|
||||
if: matrix.arch == 'x86'
|
||||
name: Setup
|
||||
- uses: uraimo/run-on-arch-action@v2.0.5
|
||||
name: Build in docker
|
||||
if: matrix.arch != 'x86'
|
||||
with:
|
||||
distro:
|
||||
ubuntu20.04
|
||||
arch:
|
||||
${{ matrix.arch }}
|
||||
setup:
|
||||
cp /tmp/ci_setup $GITHUB_WORKSPACE
|
||||
dockerRunArgs: |
|
||||
--volume "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}"
|
||||
shell: /bin/bash
|
||||
install: |
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
export TZ="America/Los_Angeles"
|
||||
apt-get update -y
|
||||
apt-get install -y tzdata build-essential sudo
|
||||
run: source ${GITHUB_WORKSPACE}/ci_setup && $CI_ROOT/managers/ubuntu.sh
|
77
.github/workflows/test.yml
vendored
77
.github/workflows/test.yml
vendored
@ -20,12 +20,16 @@ jobs:
|
||||
include:
|
||||
- kernel: 'LATEST'
|
||||
runs_on: ubuntu-latest
|
||||
- kernel: 'LATEST'
|
||||
runs_on: z15
|
||||
arch: 'x86_64'
|
||||
- kernel: '5.5.0'
|
||||
runs_on: ubuntu-latest
|
||||
arch: 'x86_64'
|
||||
- kernel: '4.9.0'
|
||||
runs_on: ubuntu-latest
|
||||
arch: 'x86_64'
|
||||
- kernel: 'LATEST'
|
||||
runs_on: z15
|
||||
arch: 's390x'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
name: Checkout
|
||||
@ -35,71 +39,4 @@ jobs:
|
||||
name: vmtest
|
||||
with:
|
||||
kernel: ${{ matrix.kernel }}
|
||||
|
||||
debian:
|
||||
runs-on: ubuntu-latest
|
||||
name: Debian Build (${{ matrix.name }})
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: default
|
||||
target: RUN
|
||||
- name: ASan+UBSan
|
||||
target: RUN_ASAN
|
||||
- name: clang
|
||||
target: RUN_CLANG
|
||||
- name: clang ASan+UBSan
|
||||
target: RUN_CLANG_ASAN
|
||||
- name: gcc-10
|
||||
target: RUN_GCC10
|
||||
- name: gcc-10 ASan+UBSan
|
||||
target: RUN_GCC10_ASAN
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
name: Checkout
|
||||
- uses: ./.github/actions/setup
|
||||
name: Setup
|
||||
- uses: ./.github/actions/debian
|
||||
name: Build
|
||||
with:
|
||||
target: ${{ matrix.target }}
|
||||
|
||||
ubuntu:
|
||||
runs-on: ubuntu-latest
|
||||
name: Ubuntu Focal Build (${{ matrix.arch }})
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: aarch64
|
||||
- arch: ppc64le
|
||||
- arch: s390x
|
||||
- arch: x86
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
name: Checkout
|
||||
- uses: ./.github/actions/setup
|
||||
name: Pre-Setup
|
||||
- run: source /tmp/ci_setup && sudo -E $CI_ROOT/managers/ubuntu.sh
|
||||
if: matrix.arch == 'x86'
|
||||
name: Setup
|
||||
- uses: uraimo/run-on-arch-action@v2.0.5
|
||||
name: Build in docker
|
||||
if: matrix.arch != 'x86'
|
||||
with:
|
||||
distro:
|
||||
ubuntu20.04
|
||||
arch:
|
||||
${{ matrix.arch }}
|
||||
setup:
|
||||
cp /tmp/ci_setup $GITHUB_WORKSPACE
|
||||
dockerRunArgs: |
|
||||
--volume "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}"
|
||||
shell: /bin/bash
|
||||
install: |
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
export TZ="America/Los_Angeles"
|
||||
apt-get update -y
|
||||
apt-get install -y tzdata build-essential sudo
|
||||
run: source ${GITHUB_WORKSPACE}/ci_setup && $CI_ROOT/managers/ubuntu.sh
|
||||
arch: ${{ matrix.arch }}
|
||||
|
@ -1,34 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
source $(cd $(dirname $0) && pwd)/helpers.sh
|
||||
|
||||
CWD=$(pwd)
|
||||
REPO_PATH=$1
|
||||
PAHOLE_ORIGIN=${PAHOLE_ORIGIN:-https://git.kernel.org/pub/scm/devel/pahole/pahole.git}
|
||||
PAHOLE_BRANCH=${PAHOLE_BRANCH:-master}
|
||||
|
||||
travis_fold start build_pahole "Building pahole ${PAHOLE_ORIGIN} ${PAHOLE_BRANCH}"
|
||||
|
||||
mkdir -p ${REPO_PATH}
|
||||
cd ${REPO_PATH}
|
||||
git init
|
||||
git remote add origin ${PAHOLE_ORIGIN}
|
||||
git fetch origin
|
||||
git checkout ${PAHOLE_BRANCH}
|
||||
|
||||
# temporary work-around to bump pahole to 1.22 before it is officially released
|
||||
sed -i 's/DDWARVES_MINOR_VERSION=21/DDWARVES_MINOR_VERSION=22/' CMakeLists.txt
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -D__LIB=lib ..
|
||||
make -j$((4*$(nproc))) all
|
||||
sudo make install
|
||||
|
||||
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:/usr/local/lib
|
||||
ldd $(which pahole)
|
||||
pahole --version
|
||||
|
||||
travis_fold end build_pahole
|
@ -1,54 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
source $(cd $(dirname $0) && pwd)/helpers.sh
|
||||
|
||||
CWD=$(pwd)
|
||||
LIBBPF_PATH=$(pwd)
|
||||
REPO_PATH=$1
|
||||
|
||||
KERNEL_ORIGIN=${KERNEL_ORIGIN:-https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git}
|
||||
KERNEL_BRANCH=${KERNEL_BRANCH:-CHECKPOINT}
|
||||
if [[ "${KERNEL_BRANCH}" = 'CHECKPOINT' ]]; then
|
||||
echo "using CHECKPOINT sha1"
|
||||
LINUX_SHA=$(cat ${LIBBPF_PATH}/CHECKPOINT-COMMIT)
|
||||
else
|
||||
echo "using ${KERNEL_BRANCH} sha1"
|
||||
LINUX_SHA=$(git ls-remote ${KERNEL_ORIGIN} ${KERNEL_BRANCH} | awk '{print $1}')
|
||||
fi
|
||||
SNAPSHOT_URL=${KERNEL_ORIGIN}/snapshot/bpf-next-${LINUX_SHA}.tar.gz
|
||||
|
||||
echo REPO_PATH = ${REPO_PATH}
|
||||
|
||||
echo KERNEL_ORIGIN = ${KERNEL_ORIGIN}
|
||||
echo LINUX_SHA = ${LINUX_SHA}
|
||||
echo SNAPSHOT_URL = ${SNAPSHOT_URL}
|
||||
|
||||
if [ ! -d "${REPO_PATH}" ]; then
|
||||
echo
|
||||
travis_fold start pull_kernel_srcs "Fetching kernel sources"
|
||||
|
||||
mkdir -p $(dirname "${REPO_PATH}")
|
||||
cd $(dirname "${REPO_PATH}")
|
||||
# attempt to fetch desired bpf-next repo snapshot
|
||||
if wget -nv ${SNAPSHOT_URL} && tar xf bpf-next-${LINUX_SHA}.tar.gz --totals ; then
|
||||
mv bpf-next-${LINUX_SHA} $(basename ${REPO_PATH})
|
||||
else
|
||||
# but fallback to git fetch approach if that fails
|
||||
mkdir -p $(basename ${REPO_PATH})
|
||||
cd $(basename ${REPO_PATH})
|
||||
git init
|
||||
git remote add bpf-next ${KERNEL_ORIGIN}
|
||||
# try shallow clone first
|
||||
git fetch --depth 32 bpf-next
|
||||
# check if desired SHA exists
|
||||
if ! git cat-file -e ${LINUX_SHA}^{commit} ; then
|
||||
# if not, fetch all of bpf-next; slow and painful
|
||||
git fetch bpf-next
|
||||
fi
|
||||
git reset --hard ${LINUX_SHA}
|
||||
fi
|
||||
|
||||
travis_fold end pull_kernel_srcs
|
||||
fi
|
@ -1,9 +0,0 @@
|
||||
INDEX https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/INDEX
|
||||
x86_64/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
|
||||
x86_64/vmlinux-4.9.0.zst https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinux-4.9.0.zst
|
||||
x86_64/vmlinux-5.5.0-rc6.zst https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinux-5.5.0-rc6.zst
|
||||
x86_64/vmlinux-5.5.0.zst https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinux-5.5.0.zst
|
||||
x86_64/vmlinuz-5.5.0-rc6 https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinuz-5.5.0-rc6
|
||||
x86_64/vmlinuz-5.5.0 https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinuz-5.5.0
|
||||
x86_64/vmlinuz-4.9.0 https://libbpf-vmtest.s3-us-west-1.amazonaws.com/x86_64/vmlinuz-4.9.0
|
||||
s390x/libbpf-vmtest-rootfs-2021.03.24.tar.zst https://libbpf-vmtest.s3-us-west-1.amazonaws.com/s390x/libbpf-vmtest-rootfs-2021.03.24.tar.zst
|
2
travis-ci/vmtest/helpers.sh
Normal file → Executable file
2
travis-ci/vmtest/helpers.sh
Normal file → Executable file
@ -23,8 +23,6 @@ travis_fold() {
|
||||
fi
|
||||
}
|
||||
|
||||
ARCH=$(uname -m)
|
||||
|
||||
__print() {
|
||||
local TITLE=""
|
||||
if [[ -n $2 ]]; then
|
||||
|
@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
source $(cd $(dirname $0) && pwd)/helpers.sh
|
||||
|
||||
REPO_PATH=${1:-}
|
||||
|
||||
if [[ ! -z "$REPO_PATH" ]]; then
|
||||
${VMTEST_ROOT}/checkout_latest_kernel.sh ${REPO_PATH}
|
||||
cd ${REPO_PATH}
|
||||
fi
|
||||
|
||||
if [[ "${KERNEL}" = 'LATEST' ]]; then
|
||||
travis_fold start build_kernel "Kernel build"
|
||||
|
||||
cp "$VMTEST_ROOT"/configs/config-latest."$ARCH" .config
|
||||
make -j $((4*$(nproc))) olddefconfig all >/dev/null
|
||||
travis_fold end build_kernel
|
||||
fi
|
||||
|
@ -1,569 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -uo pipefail
|
||||
trap 'exit 2' ERR
|
||||
|
||||
source $(cd $(dirname $0) && pwd)/helpers.sh
|
||||
|
||||
usage () {
|
||||
USAGE_STRING="usage: $0 [-k KERNELRELEASE|-b DIR] [[-r ROOTFSVERSION] [-fo]|-I] [-Si] [-d DIR] IMG
|
||||
$0 [-k KERNELRELEASE] -l
|
||||
$0 -h
|
||||
|
||||
Run "${PROJECT_NAME}" tests in a virtual machine.
|
||||
|
||||
This exits with status 0 on success, 1 if the virtual machine ran successfully
|
||||
but tests failed, and 2 if we encountered a fatal error.
|
||||
|
||||
This script uses sudo to work around a libguestfs bug.
|
||||
|
||||
Arguments:
|
||||
IMG path of virtual machine disk image to create
|
||||
|
||||
Versions:
|
||||
-k, --kernel=KERNELRELEASE
|
||||
kernel release to test. This is a glob pattern; the
|
||||
newest (sorted by version number) release that matches
|
||||
the pattern is used (default: newest available release)
|
||||
|
||||
-b, --build DIR use the kernel built in the given directory. This option
|
||||
cannot be combined with -k
|
||||
|
||||
-r, --rootfs=ROOTFSVERSION
|
||||
version of root filesystem to use (default: newest
|
||||
available version)
|
||||
|
||||
Setup:
|
||||
-f, --force overwrite IMG if it already exists
|
||||
|
||||
-o, --one-shot one-shot mode. By default, this script saves a clean copy
|
||||
of the downloaded root filesystem image and vmlinux and
|
||||
makes a copy (reflinked, when possible) for executing the
|
||||
virtual machine. This allows subsequent runs to skip
|
||||
downloading these files. If this option is given, the
|
||||
root filesystem image and vmlinux are always
|
||||
re-downloaded and are not saved. This option implies -f
|
||||
|
||||
-s, --setup-cmd setup commands run on VM boot. Whitespace characters
|
||||
should be escaped with preceding '\'.
|
||||
|
||||
-I, --skip-image skip creating the disk image; use the existing one at
|
||||
IMG. This option cannot be combined with -r, -f, or -o
|
||||
|
||||
-S, --skip-source skip copying the source files and init scripts
|
||||
|
||||
Miscellaneous:
|
||||
-i, --interactive interactive mode. Boot the virtual machine into an
|
||||
interactive shell instead of automatically running tests
|
||||
|
||||
-d, --dir=DIR working directory to use for downloading and caching
|
||||
files (default: current working directory)
|
||||
|
||||
-l, --list list available kernel releases instead of running tests.
|
||||
The list may be filtered with -k
|
||||
|
||||
-h, --help display this help message and exit"
|
||||
|
||||
case "$1" in
|
||||
out)
|
||||
echo "$USAGE_STRING"
|
||||
exit 0
|
||||
;;
|
||||
err)
|
||||
echo "$USAGE_STRING" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
TEMP=$(getopt -o 'k:b:r:fos:ISid:lh' --long 'kernel:,build:,rootfs:,force,one-shot,setup-cmd,skip-image,skip-source:,interactive,dir:,list,help' -n "$0" -- "$@")
|
||||
eval set -- "$TEMP"
|
||||
unset TEMP
|
||||
|
||||
unset KERNELRELEASE
|
||||
unset BUILDDIR
|
||||
unset ROOTFSVERSION
|
||||
unset IMG
|
||||
unset SETUPCMD
|
||||
FORCE=0
|
||||
ONESHOT=0
|
||||
SKIPIMG=0
|
||||
SKIPSOURCE=0
|
||||
APPEND=""
|
||||
DIR="$PWD"
|
||||
LIST=0
|
||||
|
||||
# by default will copy all files that aren't listed in git exclusions
|
||||
# but it doesn't work for entire kernel tree very well
|
||||
# so for full kernel tree you may need to SOURCE_FULLCOPY=0
|
||||
SOURCE_FULLCOPY=${SOURCE_FULLCOPY:-1}
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-k|--kernel)
|
||||
KERNELRELEASE="$2"
|
||||
shift 2
|
||||
;;
|
||||
-b|--build)
|
||||
BUILDDIR="$2"
|
||||
shift 2
|
||||
;;
|
||||
-r|--rootfs)
|
||||
ROOTFSVERSION="$2"
|
||||
shift 2
|
||||
;;
|
||||
-f|--force)
|
||||
FORCE=1
|
||||
shift
|
||||
;;
|
||||
-o|--one-shot)
|
||||
ONESHOT=1
|
||||
FORCE=1
|
||||
shift
|
||||
;;
|
||||
-s|--setup-cmd)
|
||||
SETUPCMD="$2"
|
||||
shift 2
|
||||
;;
|
||||
-I|--skip-image)
|
||||
SKIPIMG=1
|
||||
shift
|
||||
;;
|
||||
-S|--skip-source)
|
||||
SKIPSOURCE=1
|
||||
shift
|
||||
;;
|
||||
-i|--interactive)
|
||||
APPEND=" single"
|
||||
shift
|
||||
;;
|
||||
-d|--dir)
|
||||
DIR="$2"
|
||||
shift 2
|
||||
;;
|
||||
-l|--list)
|
||||
LIST=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage out
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
usage err
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [[ -v BUILDDIR ]]; then
|
||||
if [[ -v KERNELRELEASE ]]; then
|
||||
usage err
|
||||
fi
|
||||
elif [[ ! -v KERNELRELEASE ]]; then
|
||||
KERNELRELEASE='*'
|
||||
fi
|
||||
if [[ $SKIPIMG -ne 0 && ( -v ROOTFSVERSION || $FORCE -ne 0 ) ]]; then
|
||||
usage err
|
||||
fi
|
||||
if (( LIST )); then
|
||||
if [[ $# -ne 0 || -v BUILDDIR || -v ROOTFSVERSION || $FORCE -ne 0 ||
|
||||
$SKIPIMG -ne 0 || $SKIPSOURCE -ne 0 || -n $APPEND ]]; then
|
||||
usage err
|
||||
fi
|
||||
else
|
||||
if [[ $# -ne 1 ]]; then
|
||||
usage err
|
||||
fi
|
||||
IMG="${!OPTIND}"
|
||||
fi
|
||||
if [[ "${SOURCE_FULLCOPY}" == "1" ]]; then
|
||||
img_size=2G
|
||||
else
|
||||
img_size=8G
|
||||
fi
|
||||
|
||||
unset URLS
|
||||
cache_urls() {
|
||||
if ! declare -p URLS &> /dev/null; then
|
||||
# This URL contains a mapping from file names to URLs where
|
||||
# those files can be downloaded.
|
||||
declare -gA URLS
|
||||
while IFS=$'\t' read -r name url; do
|
||||
URLS["$name"]="$url"
|
||||
done < <(cat "${VMTEST_ROOT}/configs/INDEX")
|
||||
fi
|
||||
}
|
||||
|
||||
matching_kernel_releases() {
|
||||
local pattern="$1"
|
||||
{
|
||||
for file in "${!URLS[@]}"; do
|
||||
if [[ $file =~ ^${ARCH}/vmlinux-(.*).zst$ ]]; then
|
||||
release="${BASH_REMATCH[1]}"
|
||||
case "$release" in
|
||||
$pattern)
|
||||
# sort -V handles rc versions properly
|
||||
# if we use "~" instead of "-".
|
||||
echo "${release//-rc/~rc}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
} | sort -rV | sed 's/~rc/-rc/g'
|
||||
}
|
||||
|
||||
newest_rootfs_version() {
|
||||
{
|
||||
for file in "${!URLS[@]}"; do
|
||||
if [[ $file =~ ^${ARCH}/${PROJECT_NAME}-vmtest-rootfs-(.*)\.tar\.zst$ ]]; then
|
||||
echo "${BASH_REMATCH[1]}"
|
||||
fi
|
||||
done
|
||||
} | sort -rV | head -1
|
||||
}
|
||||
|
||||
download() {
|
||||
local file="$1"
|
||||
cache_urls
|
||||
if [[ ! -v URLS[$file] ]]; then
|
||||
echo "$file not found" >&2
|
||||
return 1
|
||||
fi
|
||||
echo "Downloading $file..." >&2
|
||||
curl -Lf "${URLS[$file]}" "${@:2}"
|
||||
}
|
||||
|
||||
set_nocow() {
|
||||
touch "$@"
|
||||
chattr +C "$@" >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
cp_img() {
|
||||
set_nocow "$2"
|
||||
cp --reflink=auto "$1" "$2"
|
||||
}
|
||||
|
||||
create_rootfs_img() {
|
||||
local path="$1"
|
||||
set_nocow "$path"
|
||||
truncate -s "$img_size" "$path"
|
||||
mkfs.ext4 -q "$path"
|
||||
}
|
||||
|
||||
download_rootfs() {
|
||||
local rootfsversion="$1"
|
||||
download "${ARCH}/${PROJECT_NAME}-vmtest-rootfs-$rootfsversion.tar.zst" |
|
||||
zstd -d
|
||||
}
|
||||
|
||||
tar_in() {
|
||||
local dst_path="$1"
|
||||
# guestfish --remote does not forward file descriptors, which prevents
|
||||
# us from using `tar-in -` or bash process substitution. We don't want
|
||||
# to copy all the data into a temporary file, so use a FIFO.
|
||||
tmp=$(mktemp -d)
|
||||
mkfifo "$tmp/fifo"
|
||||
cat >"$tmp/fifo" &
|
||||
local cat_pid=$!
|
||||
guestfish --remote tar-in "$tmp/fifo" "$dst_path"
|
||||
wait "$cat_pid"
|
||||
rm -r "$tmp"
|
||||
tmp=
|
||||
}
|
||||
|
||||
if (( LIST )); then
|
||||
cache_urls
|
||||
matching_kernel_releases "$KERNELRELEASE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $FORCE -eq 0 && $SKIPIMG -eq 0 && -e $IMG ]]; then
|
||||
echo "$IMG already exists; use -f to overwrite it or -I to reuse it" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Only go to the network if it's actually a glob pattern.
|
||||
if [[ -v BUILDDIR ]]; then
|
||||
KERNELRELEASE="$(make -C "$BUILDDIR" -s kernelrelease)"
|
||||
elif [[ ! $KERNELRELEASE =~ ^([^\\*?[]|\\[*?[])*\\?$ ]]; then
|
||||
# We need to cache the list of URLs outside of the command
|
||||
# substitution, which happens in a subshell.
|
||||
cache_urls
|
||||
KERNELRELEASE="$(matching_kernel_releases "$KERNELRELEASE" | head -1)"
|
||||
if [[ -z $KERNELRELEASE ]]; then
|
||||
echo "No matching kernel release found" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if [[ $SKIPIMG -eq 0 && ! -v ROOTFSVERSION ]]; then
|
||||
cache_urls
|
||||
ROOTFSVERSION="$(newest_rootfs_version)"
|
||||
fi
|
||||
|
||||
travis_fold start vmlinux_setup "Preparing Linux image"
|
||||
|
||||
echo "Kernel release: $KERNELRELEASE" >&2
|
||||
echo
|
||||
|
||||
if (( SKIPIMG )); then
|
||||
echo "Not extracting root filesystem" >&2
|
||||
else
|
||||
echo "Root filesystem version: $ROOTFSVERSION" >&2
|
||||
fi
|
||||
echo "Disk image: $IMG" >&2
|
||||
|
||||
tmp=
|
||||
ARCH_DIR="$DIR/$ARCH"
|
||||
mkdir -p "$ARCH_DIR"
|
||||
|
||||
cleanup() {
|
||||
if [[ -n $tmp ]]; then
|
||||
rm -rf "$tmp" || true
|
||||
fi
|
||||
guestfish --remote exit 2>/dev/null || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if [[ -v BUILDDIR ]]; then
|
||||
vmlinuz="$BUILDDIR/$(make -C "$BUILDDIR" -s image_name)"
|
||||
else
|
||||
vmlinuz="${ARCH_DIR}/vmlinuz-${KERNELRELEASE}"
|
||||
if [[ ! -e $vmlinuz ]]; then
|
||||
tmp="$(mktemp "$vmlinuz.XXX.part")"
|
||||
download "${ARCH}/vmlinuz-${KERNELRELEASE}" -o "$tmp"
|
||||
mv "$tmp" "$vmlinuz"
|
||||
tmp=
|
||||
fi
|
||||
fi
|
||||
|
||||
# Mount and set up the rootfs image. Use a persistent guestfish session in
|
||||
# order to avoid the startup overhead.
|
||||
# Work around https://bugs.launchpad.net/fuel/+bug/1467579.
|
||||
sudo chmod +r /boot/vmlinuz*
|
||||
eval "$(guestfish --listen)"
|
||||
if (( ONESHOT )); then
|
||||
rm -f "$IMG"
|
||||
create_rootfs_img "$IMG"
|
||||
guestfish --remote \
|
||||
add "$IMG" label:img : \
|
||||
launch : \
|
||||
mount /dev/disk/guestfs/img /
|
||||
download_rootfs "$ROOTFSVERSION" | tar_in /
|
||||
else
|
||||
if (( ! SKIPIMG )); then
|
||||
rootfs_img="${ARCH_DIR}/${PROJECT_NAME}-vmtest-rootfs-${ROOTFSVERSION}.img"
|
||||
|
||||
if [[ ! -e $rootfs_img ]]; then
|
||||
tmp="$(mktemp "$rootfs_img.XXX.part")"
|
||||
set_nocow "$tmp"
|
||||
truncate -s "$img_size" "$tmp"
|
||||
mkfs.ext4 -q "$tmp"
|
||||
|
||||
# libguestfs supports hotplugging only with a libvirt
|
||||
# backend, which we are not using here, so handle the
|
||||
# temporary image in a separate session.
|
||||
download_rootfs "$ROOTFSVERSION" |
|
||||
guestfish -a "$tmp" tar-in - /
|
||||
|
||||
mv "$tmp" "$rootfs_img"
|
||||
tmp=
|
||||
fi
|
||||
|
||||
rm -f "$IMG"
|
||||
cp_img "$rootfs_img" "$IMG"
|
||||
fi
|
||||
guestfish --remote \
|
||||
add "$IMG" label:img : \
|
||||
launch : \
|
||||
mount /dev/disk/guestfs/img /
|
||||
fi
|
||||
|
||||
# Install vmlinux.
|
||||
vmlinux="/boot/vmlinux-${KERNELRELEASE}"
|
||||
if [[ -v BUILDDIR || $ONESHOT -eq 0 ]]; then
|
||||
if [[ -v BUILDDIR ]]; then
|
||||
source_vmlinux="${BUILDDIR}/vmlinux"
|
||||
else
|
||||
source_vmlinux="${ARCH_DIR}/vmlinux-${KERNELRELEASE}"
|
||||
if [[ ! -e $source_vmlinux ]]; then
|
||||
tmp="$(mktemp "$source_vmlinux.XXX.part")"
|
||||
download "${ARCH}/vmlinux-${KERNELRELEASE}.zst" | zstd -dfo "$tmp"
|
||||
mv "$tmp" "$source_vmlinux"
|
||||
tmp=
|
||||
fi
|
||||
fi
|
||||
else
|
||||
source_vmlinux="${ARCH_DIR}/vmlinux-${KERNELRELEASE}"
|
||||
download "${ARCH}/vmlinux-${KERNELRELEASE}.zst" | zstd -d >"$source_vmlinux"
|
||||
fi
|
||||
echo "Copying vmlinux..." >&2
|
||||
guestfish --remote \
|
||||
upload "$source_vmlinux" "$vmlinux" : \
|
||||
chmod 644 "$vmlinux"
|
||||
|
||||
travis_fold end vmlinux_setup
|
||||
|
||||
REPO_PATH="${SELFTEST_REPO_PATH:-travis-ci/vmtest/bpf-next}"
|
||||
LIBBPF_PATH="${REPO_ROOT}" \
|
||||
VMTEST_ROOT="${VMTEST_ROOT}" \
|
||||
REPO_PATH="${REPO_PATH}" \
|
||||
VMLINUX_BTF=$(realpath ${source_vmlinux}) ${VMTEST_ROOT}/build_selftests.sh
|
||||
|
||||
travis_fold start bpftool_checks "Running bpftool checks..."
|
||||
bpftool_exitstatus=
|
||||
if [[ "${KERNEL}" = 'LATEST' ]]; then
|
||||
# "&& true" does not change the return code (it is not executed if the
|
||||
# Python script fails), but it prevents the trap on ERR set at the top
|
||||
# of this file to trigger on failure.
|
||||
"${REPO_ROOT}/${REPO_PATH}/tools/testing/selftests/bpf/test_bpftool_synctypes.py" && true
|
||||
bpftool_exitstatus=$?
|
||||
if [[ "$bpftool_exitstatus" -eq 0 ]]; then
|
||||
print_notice bpftool_checks "bpftool checks passed successfully."
|
||||
else
|
||||
print_error bpftool_checks "bpftool checks returned ${bpftool_exitstatus}."
|
||||
fi
|
||||
bpftool_exitstatus="bpftool:${bpftool_exitstatus}"
|
||||
else
|
||||
echo "bpftool checks skipped."
|
||||
fi
|
||||
travis_fold end bpftool_checks
|
||||
|
||||
travis_fold start vm_init "Starting virtual machine..."
|
||||
|
||||
if (( SKIPSOURCE )); then
|
||||
echo "Not copying source files..." >&2
|
||||
else
|
||||
echo "Copying source files..." >&2
|
||||
# Copy the source files in.
|
||||
guestfish --remote \
|
||||
mkdir-p "/${PROJECT_NAME}" : \
|
||||
chmod 0755 "/${PROJECT_NAME}"
|
||||
if [[ "${SOURCE_FULLCOPY}" == "1" ]]; then
|
||||
git ls-files -z | tar --null --files-from=- -c | tar_in "/${PROJECT_NAME}"
|
||||
else
|
||||
guestfish --remote \
|
||||
mkdir-p "/${PROJECT_NAME}/selftests" : \
|
||||
chmod 0755 "/${PROJECT_NAME}/selftests" : \
|
||||
mkdir-p "/${PROJECT_NAME}/travis-ci" : \
|
||||
chmod 0755 "/${PROJECT_NAME}/travis-ci"
|
||||
tree --du -shaC "${REPO_ROOT}/selftests/bpf"
|
||||
tar -C "${REPO_ROOT}/selftests" -c bpf | tar_in "/${PROJECT_NAME}/selftests"
|
||||
tar -C "${REPO_ROOT}/travis-ci" -c vmtest | tar_in "/${PROJECT_NAME}/travis-ci"
|
||||
fi
|
||||
fi
|
||||
|
||||
tmp=$(mktemp)
|
||||
cat <<HERE >"$tmp"
|
||||
"#!/bin/sh
|
||||
|
||||
echo 'Skipping setup commands'
|
||||
echo vm_start:0 > /exitstatus
|
||||
chmod 644 /exitstatus
|
||||
HERE
|
||||
|
||||
# Create the init scripts.
|
||||
if [[ ! -z SETUPCMD ]]; then
|
||||
# Unescape whitespace characters.
|
||||
setup_cmd=$(sed 's/\(\\\)\([[:space:]]\)/\2/g' <<< "${SETUPCMD}")
|
||||
kernel="${KERNELRELEASE}"
|
||||
if [[ -v BUILDDIR ]]; then kernel='latest'; fi
|
||||
setup_envvars="export KERNEL=${kernel}"
|
||||
cat <<HERE >"$tmp"
|
||||
#!/bin/sh
|
||||
set -eux
|
||||
|
||||
echo 'Running setup commands'
|
||||
${setup_envvars}
|
||||
set +e
|
||||
${setup_cmd}; exitstatus=\$?
|
||||
echo -e '$(travis_fold start collect_status "Collect status")'
|
||||
set -e
|
||||
# If setup command did not write its exit status to /exitstatus, do it now
|
||||
if [[ ! -s /exitstatus ]]; then
|
||||
echo setup_cmd:\$exitstatus > /exitstatus
|
||||
fi
|
||||
chmod 644 /exitstatus
|
||||
echo -e '$(travis_fold end collect_status)'
|
||||
echo -e '$(travis_fold start shutdown Shutdown)'
|
||||
HERE
|
||||
fi
|
||||
|
||||
guestfish --remote \
|
||||
upload "$tmp" /etc/rcS.d/S50-run-tests : \
|
||||
chmod 755 /etc/rcS.d/S50-run-tests
|
||||
|
||||
cat <<HERE >"$tmp"
|
||||
#!/bin/sh
|
||||
|
||||
poweroff
|
||||
HERE
|
||||
guestfish --remote \
|
||||
upload "$tmp" /etc/rcS.d/S99-poweroff : \
|
||||
chmod 755 /etc/rcS.d/S99-poweroff
|
||||
rm "$tmp"
|
||||
tmp=
|
||||
|
||||
guestfish --remote exit
|
||||
|
||||
echo "Starting VM with $(nproc) CPUs..."
|
||||
|
||||
case "$ARCH" in
|
||||
s390x)
|
||||
qemu="qemu-system-s390x"
|
||||
console="ttyS1"
|
||||
smp=2
|
||||
kvm_accel="-enable-kvm"
|
||||
tcg_accel="-machine accel=tcg"
|
||||
;;
|
||||
x86_64)
|
||||
qemu="qemu-system-x86_64"
|
||||
console="ttyS0,115200"
|
||||
smp=$(nproc)
|
||||
kvm_accel="-cpu kvm64 -enable-kvm"
|
||||
tcg_accel="-cpu qemu64 -machine accel=tcg"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported architecture"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
if kvm-ok ; then
|
||||
accel=$kvm_accel
|
||||
else
|
||||
accel=$tcg_accel
|
||||
fi
|
||||
"$qemu" -nodefaults -display none -serial mon:stdio \
|
||||
${accel} -smp "$smp" -m 4G \
|
||||
-drive file="$IMG",format=raw,index=1,media=disk,if=virtio,cache=none \
|
||||
-kernel "$vmlinuz" -append "root=/dev/vda rw console=$console kernel.panic=-1 $APPEND"
|
||||
|
||||
# Set exit status to 1 if at least one group test returned non-0
|
||||
exitfile="${bpftool_exitstatus}${bpftool_exitstatus:+\n}"
|
||||
exitfile+="$(guestfish --ro -a "$IMG" -i cat /exitstatus 2>/dev/null)"
|
||||
exitstatus="$(echo -e "$exitfile" | awk --field-separator ':' \
|
||||
'BEGIN { s=0 } { if ($2) {s=1} } END { print s }')"
|
||||
|
||||
if [[ "$exitstatus" =~ ^[0-9]+$ ]]; then
|
||||
printf '\nTests exit status: %s\n' "$exitstatus" >&2
|
||||
else
|
||||
printf '\nCould not read tests exit status ("%s")\n' "$exitstatus" >&2
|
||||
exitstatus=1
|
||||
fi
|
||||
|
||||
travis_fold end shutdown
|
||||
|
||||
# Final summary - Don't use a fold, keep it visible
|
||||
echo -e "\033[1;33mTest Results:\033[0m"
|
||||
echo -e "$exitfile" | while read result; do
|
||||
testgroup=${result%:*}
|
||||
status=${result#*:}
|
||||
# Print final result for each group of tests
|
||||
if [[ "$status" -eq 0 ]]; then
|
||||
printf "%20s: \033[1;32mPASS\033[0m\n" "$testgroup"
|
||||
else
|
||||
printf "%20s: \033[1;31mFAIL\033[0m (returned %s)\n" "$testgroup" "$status"
|
||||
fi
|
||||
done
|
||||
|
||||
exit "$exitstatus"
|
@ -4,6 +4,8 @@ set -euo pipefail
|
||||
|
||||
source $(cd $(dirname $0) && pwd)/helpers.sh
|
||||
|
||||
ARCH=$(uname -m)
|
||||
|
||||
STATUS_FILE=/exitstatus
|
||||
|
||||
read_lists() {
|
||||
@ -47,11 +49,11 @@ test_verifier() {
|
||||
|
||||
travis_fold end vm_init
|
||||
|
||||
configs_path=libbpf/travis-ci/vmtest/configs
|
||||
configs_path=${PROJECT_NAME}/vmtest/configs
|
||||
BLACKLIST=$(read_lists "$configs_path/blacklist/BLACKLIST-${KERNEL}" "$configs_path/blacklist/BLACKLIST-${KERNEL}.${ARCH}")
|
||||
WHITELIST=$(read_lists "$configs_path/whitelist/WHITELIST-${KERNEL}" "$configs_path/whitelist/WHITELIST-${KERNEL}.${ARCH}")
|
||||
|
||||
cd libbpf/selftests/bpf
|
||||
cd ${PROJECT_NAME}/selftests/bpf
|
||||
|
||||
test_progs
|
||||
|
||||
|
@ -1,53 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
source $(cd $(dirname $0) && pwd)/helpers.sh
|
||||
|
||||
VMTEST_SETUPCMD="GITHUB_WORKFLOW=${GITHUB_WORKFLOW:-} PROJECT_NAME=${PROJECT_NAME} ./${PROJECT_NAME}/travis-ci/vmtest/run_selftests.sh"
|
||||
|
||||
# if CHECKOUT_KERNEL is 1 code will consider that kernel code lives elsewhere
|
||||
# if 0 it will consider that REPO_ROOT is a kernel tree
|
||||
CHECKOUT_KERNEL=${CHECKOUT_KERNEL:-1}
|
||||
|
||||
echo "KERNEL: $KERNEL"
|
||||
echo
|
||||
|
||||
# Build latest pahole
|
||||
${VMTEST_ROOT}/build_pahole.sh travis-ci/vmtest/pahole
|
||||
|
||||
travis_fold start install_clang "Installing Clang/LLVM"
|
||||
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main"
|
||||
sudo apt-get update
|
||||
sudo apt-get install --allow-downgrades -y libc6=2.31-0ubuntu9.2
|
||||
sudo aptitude install -y g++ libelf-dev
|
||||
sudo aptitude install -y clang-14 llvm-14
|
||||
|
||||
travis_fold end install_clang
|
||||
|
||||
# Build selftests (and latest kernel, if necessary)
|
||||
|
||||
if [[ "$CHECKOUT_KERNEL" == "1" ]]; then
|
||||
${VMTEST_ROOT}/prepare_selftests.sh travis-ci/vmtest/bpf-next
|
||||
else
|
||||
${VMTEST_ROOT}/prepare_selftests.sh
|
||||
fi
|
||||
|
||||
travis_fold start adduser_to_kvm "Add user ${USER}"
|
||||
sudo adduser "${USER}" kvm
|
||||
travis_fold stop adduser_to_kvm
|
||||
|
||||
# Escape whitespace characters.
|
||||
setup_cmd=$(sed 's/\([[:space:]]\)/\\\1/g' <<< "${VMTEST_SETUPCMD}")
|
||||
|
||||
if [[ "${KERNEL}" = 'LATEST' ]]; then
|
||||
if [[ "$CHECKOUT_KERNEL" == "1" ]]; then
|
||||
sudo -E sudo -E -u "${USER}" "${VMTEST_ROOT}/run.sh" -b travis-ci/vmtest/bpf-next -o -d ~ -s "${setup_cmd}" ~/root.img
|
||||
else
|
||||
sudo -E sudo -E -u "${USER}" "${VMTEST_ROOT}/run.sh" -b "${REPO_ROOT}" -o -d ~ -s "${setup_cmd}" ~/root.img
|
||||
fi
|
||||
else
|
||||
sudo -E sudo -E -u "${USER}" "${VMTEST_ROOT}/run.sh" -k "${KERNEL}*" -o -d ~ -s "${setup_cmd}" ~/root.img
|
||||
fi
|
Loading…
Reference in New Issue
Block a user