From 7e89be4022f639061dbeae9e8d3a42a20836ec05 Mon Sep 17 00:00:00 2001 From: Yucong Sun Date: Thu, 11 Nov 2021 15:17:43 -0800 Subject: [PATCH] Migrate vmtest to modular actions in libbpf/ci --- .github/actions/build-selftests/action.yml | 30 + .../build-selftests}/build_selftests.sh | 16 +- .github/actions/build-selftests/helpers.sh | 44 ++ .../prepare_selftests-4.9.0.sh | 0 .../prepare_selftests-5.5.0.sh | 0 .../actions/build-selftests}/vmlinux.h | 0 .github/actions/vmtest/action.yml | 87 ++- .github/workflows/build.yml | 81 +++ .github/workflows/test.yml | 77 +-- travis-ci/{vmtest => rootfs}/mkrootfs_arch.sh | 0 .../{vmtest => rootfs}/mkrootfs_debian.sh | 0 .../{vmtest => rootfs}/mkrootfs_tweak.sh | 0 .../s390x-self-hosted-builder/README.md | 0 .../actions-runner-libbpf.Dockerfile | 0 .../actions-runner-libbpf.service | 0 .../fs/usr/bin/actions-runner | 0 .../fs/usr/bin/entrypoint | 0 .../qemu-user-static.service | 0 travis-ci/vmtest/build_pahole.sh | 34 -- travis-ci/vmtest/checkout_latest_kernel.sh | 54 -- travis-ci/vmtest/configs/INDEX | 9 - travis-ci/vmtest/helpers.sh | 2 - travis-ci/vmtest/prepare_selftests.sh | 21 - travis-ci/vmtest/run.sh | 569 ------------------ travis-ci/vmtest/run_selftests.sh | 6 +- travis-ci/vmtest/run_vmtest.sh | 53 -- 26 files changed, 241 insertions(+), 842 deletions(-) create mode 100644 .github/actions/build-selftests/action.yml rename {travis-ci/vmtest => .github/actions/build-selftests}/build_selftests.sh (69%) create mode 100644 .github/actions/build-selftests/helpers.sh rename {travis-ci/vmtest => .github/actions/build-selftests}/prepare_selftests-4.9.0.sh (100%) rename {travis-ci/vmtest => .github/actions/build-selftests}/prepare_selftests-5.5.0.sh (100%) rename {travis-ci/vmtest => .github/actions/build-selftests}/vmlinux.h (100%) create mode 100644 .github/workflows/build.yml rename travis-ci/{vmtest => rootfs}/mkrootfs_arch.sh (100%) rename travis-ci/{vmtest => rootfs}/mkrootfs_debian.sh (100%) rename travis-ci/{vmtest => rootfs}/mkrootfs_tweak.sh (100%) rename travis-ci/{vmtest => rootfs}/s390x-self-hosted-builder/README.md (100%) rename travis-ci/{vmtest => rootfs}/s390x-self-hosted-builder/actions-runner-libbpf.Dockerfile (100%) rename travis-ci/{vmtest => rootfs}/s390x-self-hosted-builder/actions-runner-libbpf.service (100%) rename travis-ci/{vmtest => rootfs}/s390x-self-hosted-builder/fs/usr/bin/actions-runner (100%) rename travis-ci/{vmtest => rootfs}/s390x-self-hosted-builder/fs/usr/bin/entrypoint (100%) rename travis-ci/{vmtest => rootfs}/s390x-self-hosted-builder/qemu-user-static.service (100%) delete mode 100755 travis-ci/vmtest/build_pahole.sh delete mode 100755 travis-ci/vmtest/checkout_latest_kernel.sh delete mode 100644 travis-ci/vmtest/configs/INDEX mode change 100644 => 100755 travis-ci/vmtest/helpers.sh delete mode 100755 travis-ci/vmtest/prepare_selftests.sh delete mode 100755 travis-ci/vmtest/run.sh delete mode 100755 travis-ci/vmtest/run_vmtest.sh diff --git a/.github/actions/build-selftests/action.yml b/.github/actions/build-selftests/action.yml new file mode 100644 index 0000000..af7981b --- /dev/null +++ b/.github/actions/build-selftests/action.yml @@ -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 diff --git a/travis-ci/vmtest/build_selftests.sh b/.github/actions/build-selftests/build_selftests.sh similarity index 69% rename from travis-ci/vmtest/build_selftests.sh rename to .github/actions/build-selftests/build_selftests.sh index 18dc613..05e3d39 100755 --- a/travis-ci/vmtest/build_selftests.sh +++ b/.github/actions/build-selftests/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 diff --git a/.github/actions/build-selftests/helpers.sh b/.github/actions/build-selftests/helpers.sh new file mode 100644 index 0000000..856660a --- /dev/null +++ b/.github/actions/build-selftests/helpers.sh @@ -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 +} diff --git a/travis-ci/vmtest/prepare_selftests-4.9.0.sh b/.github/actions/build-selftests/prepare_selftests-4.9.0.sh similarity index 100% rename from travis-ci/vmtest/prepare_selftests-4.9.0.sh rename to .github/actions/build-selftests/prepare_selftests-4.9.0.sh diff --git a/travis-ci/vmtest/prepare_selftests-5.5.0.sh b/.github/actions/build-selftests/prepare_selftests-5.5.0.sh similarity index 100% rename from travis-ci/vmtest/prepare_selftests-5.5.0.sh rename to .github/actions/build-selftests/prepare_selftests-5.5.0.sh diff --git a/travis-ci/vmtest/vmlinux.h b/.github/actions/build-selftests/vmlinux.h similarity index 100% rename from travis-ci/vmtest/vmlinux.h rename to .github/actions/build-selftests/vmlinux.h diff --git a/.github/actions/vmtest/action.yml b/.github/actions/vmtest/action.yml index b0deb51..2f86607 100644 --- a/.github/actions/vmtest/action.yml +++ b/.github/actions/vmtest/action.yml @@ -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 }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..25768d6 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 64dbbcb..5904843 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 }} diff --git a/travis-ci/vmtest/mkrootfs_arch.sh b/travis-ci/rootfs/mkrootfs_arch.sh similarity index 100% rename from travis-ci/vmtest/mkrootfs_arch.sh rename to travis-ci/rootfs/mkrootfs_arch.sh diff --git a/travis-ci/vmtest/mkrootfs_debian.sh b/travis-ci/rootfs/mkrootfs_debian.sh similarity index 100% rename from travis-ci/vmtest/mkrootfs_debian.sh rename to travis-ci/rootfs/mkrootfs_debian.sh diff --git a/travis-ci/vmtest/mkrootfs_tweak.sh b/travis-ci/rootfs/mkrootfs_tweak.sh similarity index 100% rename from travis-ci/vmtest/mkrootfs_tweak.sh rename to travis-ci/rootfs/mkrootfs_tweak.sh diff --git a/travis-ci/vmtest/s390x-self-hosted-builder/README.md b/travis-ci/rootfs/s390x-self-hosted-builder/README.md similarity index 100% rename from travis-ci/vmtest/s390x-self-hosted-builder/README.md rename to travis-ci/rootfs/s390x-self-hosted-builder/README.md diff --git a/travis-ci/vmtest/s390x-self-hosted-builder/actions-runner-libbpf.Dockerfile b/travis-ci/rootfs/s390x-self-hosted-builder/actions-runner-libbpf.Dockerfile similarity index 100% rename from travis-ci/vmtest/s390x-self-hosted-builder/actions-runner-libbpf.Dockerfile rename to travis-ci/rootfs/s390x-self-hosted-builder/actions-runner-libbpf.Dockerfile diff --git a/travis-ci/vmtest/s390x-self-hosted-builder/actions-runner-libbpf.service b/travis-ci/rootfs/s390x-self-hosted-builder/actions-runner-libbpf.service similarity index 100% rename from travis-ci/vmtest/s390x-self-hosted-builder/actions-runner-libbpf.service rename to travis-ci/rootfs/s390x-self-hosted-builder/actions-runner-libbpf.service diff --git a/travis-ci/vmtest/s390x-self-hosted-builder/fs/usr/bin/actions-runner b/travis-ci/rootfs/s390x-self-hosted-builder/fs/usr/bin/actions-runner similarity index 100% rename from travis-ci/vmtest/s390x-self-hosted-builder/fs/usr/bin/actions-runner rename to travis-ci/rootfs/s390x-self-hosted-builder/fs/usr/bin/actions-runner diff --git a/travis-ci/vmtest/s390x-self-hosted-builder/fs/usr/bin/entrypoint b/travis-ci/rootfs/s390x-self-hosted-builder/fs/usr/bin/entrypoint similarity index 100% rename from travis-ci/vmtest/s390x-self-hosted-builder/fs/usr/bin/entrypoint rename to travis-ci/rootfs/s390x-self-hosted-builder/fs/usr/bin/entrypoint diff --git a/travis-ci/vmtest/s390x-self-hosted-builder/qemu-user-static.service b/travis-ci/rootfs/s390x-self-hosted-builder/qemu-user-static.service similarity index 100% rename from travis-ci/vmtest/s390x-self-hosted-builder/qemu-user-static.service rename to travis-ci/rootfs/s390x-self-hosted-builder/qemu-user-static.service diff --git a/travis-ci/vmtest/build_pahole.sh b/travis-ci/vmtest/build_pahole.sh deleted file mode 100755 index b1f54e7..0000000 --- a/travis-ci/vmtest/build_pahole.sh +++ /dev/null @@ -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 diff --git a/travis-ci/vmtest/checkout_latest_kernel.sh b/travis-ci/vmtest/checkout_latest_kernel.sh deleted file mode 100755 index 6cc3c3a..0000000 --- a/travis-ci/vmtest/checkout_latest_kernel.sh +++ /dev/null @@ -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 diff --git a/travis-ci/vmtest/configs/INDEX b/travis-ci/vmtest/configs/INDEX deleted file mode 100644 index b6cbf08..0000000 --- a/travis-ci/vmtest/configs/INDEX +++ /dev/null @@ -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 diff --git a/travis-ci/vmtest/helpers.sh b/travis-ci/vmtest/helpers.sh old mode 100644 new mode 100755 index 116e72c..856660a --- a/travis-ci/vmtest/helpers.sh +++ b/travis-ci/vmtest/helpers.sh @@ -23,8 +23,6 @@ travis_fold() { fi } -ARCH=$(uname -m) - __print() { local TITLE="" if [[ -n $2 ]]; then diff --git a/travis-ci/vmtest/prepare_selftests.sh b/travis-ci/vmtest/prepare_selftests.sh deleted file mode 100755 index 2ca6c09..0000000 --- a/travis-ci/vmtest/prepare_selftests.sh +++ /dev/null @@ -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 - diff --git a/travis-ci/vmtest/run.sh b/travis-ci/vmtest/run.sh deleted file mode 100755 index 2a765b0..0000000 --- a/travis-ci/vmtest/run.sh +++ /dev/null @@ -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 <"$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 <"$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 <"$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" diff --git a/travis-ci/vmtest/run_selftests.sh b/travis-ci/vmtest/run_selftests.sh index b400ad0..d1e8536 100755 --- a/travis-ci/vmtest/run_selftests.sh +++ b/travis-ci/vmtest/run_selftests.sh @@ -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 diff --git a/travis-ci/vmtest/run_vmtest.sh b/travis-ci/vmtest/run_vmtest.sh deleted file mode 100755 index a846d46..0000000 --- a/travis-ci/vmtest/run_vmtest.sh +++ /dev/null @@ -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