From c924f8d3ddbee991b5291c70fd06f5578d5807a1 Mon Sep 17 00:00:00 2001 From: Ihor Solodrai Date: Wed, 15 Jan 2025 09:34:54 -0800 Subject: [PATCH] ci: sync with libbpf/ci@v3 * vmtest.yml * use v3 of libbpf/ci actions * remove unnecessary selftests preparation steps * ci/vmtest * remove unnecessary scripts and configs * add libbpf-specific run-vmtest.env [1] [1] https://github.com/libbpf/ci/pull/166 Signed-off-by: Ihor Solodrai --- .github/workflows/vmtest.yml | 39 ++------ ci/vmtest/configs/ALLOWLIST-4.9.0 | 8 -- ci/vmtest/configs/ALLOWLIST-5.5.0 | 49 ---------- ci/vmtest/configs/DENYLIST-5.5.0 | 5 - .../run-vmtest.env} | 28 ++---- ci/vmtest/helpers.sh | 38 -------- ci/vmtest/prepare-selftests-LATEST.sh | 12 --- ci/vmtest/run_selftests.sh | 96 ------------------- 8 files changed, 19 insertions(+), 256 deletions(-) delete mode 100644 ci/vmtest/configs/ALLOWLIST-4.9.0 delete mode 100644 ci/vmtest/configs/ALLOWLIST-5.5.0 delete mode 100644 ci/vmtest/configs/DENYLIST-5.5.0 rename ci/vmtest/{prepare-selftests-run.sh => configs/run-vmtest.env} (63%) mode change 100755 => 100644 delete mode 100755 ci/vmtest/helpers.sh delete mode 100755 ci/vmtest/prepare-selftests-LATEST.sh delete mode 100755 ci/vmtest/run_selftests.sh diff --git a/.github/workflows/vmtest.yml b/.github/workflows/vmtest.yml index 72ab2b6..7989f86 100644 --- a/.github/workflows/vmtest.yml +++ b/.github/workflows/vmtest.yml @@ -36,7 +36,7 @@ jobs: - uses: actions/checkout@v4 - name: Setup environment - uses: libbpf/ci/setup-build-env@v2 + uses: libbpf/ci/setup-build-env@v3 with: pahole: ${{ inputs.pahole }} arch: ${{ inputs.arch }} @@ -49,14 +49,14 @@ jobs: echo "CHECKPOINT=$(cat CHECKPOINT-COMMIT)" >> $GITHUB_ENV - name: Get kernel source at checkpoint - uses: libbpf/ci/get-linux-source@v2 + uses: libbpf/ci/get-linux-source@v3 with: repo: 'https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git' rev: ${{ env.CHECKPOINT }} dest: '${{ github.workspace }}/.kernel' - name: Patch kernel source - uses: libbpf/ci/patch-kernel@v2 + uses: libbpf/ci/patch-kernel@v3 with: patches-root: '${{ github.workspace }}/ci/diffs' repo-root: '.kernel' @@ -83,23 +83,13 @@ jobs: - name: Download prebuilt kernel if: ${{ inputs.kernel != 'LATEST' }} - uses: libbpf/ci/download-vmlinux@v2 + uses: libbpf/ci/download-vmlinux@v3 with: kernel: ${{ inputs.kernel }} arch: ${{ inputs.arch }} - - name: Prepare to build selftests - shell: bash - env: - PREPARE_SCRIPT: ${{ github.workspace }}/ci/vmtest/prepare-selftests-build-${{ inputs.kernel }}.sh - SELFTESTS_BPF: ${{ github.workspace }}/.kernel/tools/testing/selftests/bpf - run: | - if [ -f "${PREPARE_SCRIPT}" ]; then - bash "${PREPARE_SCRIPT}" - fi - - name: Build selftests/bpf - uses: libbpf/ci/build-selftests@v2 + uses: libbpf/ci/build-selftests@v3 env: MAX_MAKE_JOBS: 32 VMLINUX_BTF: ${{ github.workspace }}/vmlinux @@ -109,28 +99,19 @@ jobs: kernel-root: ${{ github.workspace }}/.kernel llvm-version: ${{ inputs.llvm-version }} - - name: Prepare to run selftests - env: - ALLOWLIST_FILE: /tmp/allowlist - DENYLIST_FILE: /tmp/denylist - ARCH: ${{ inputs.arch }} - KERNEL: ${{ inputs.kernel }} - LLVM_VERSION: ${{ inputs.llvm-version }} - SELFTESTS_BPF: ${{ github.workspace }}/.kernel/tools/testing/selftests/bpf - VMTEST_CONFIGS: ${{ github.workspace }}/ci/vmtest/configs - shell: bash - run: ${{ github.workspace }}/ci/vmtest/prepare-selftests-run.sh - - name: Run selftests env: ALLOWLIST_FILE: /tmp/allowlist DENYLIST_FILE: /tmp/denylist KERNEL: ${{ inputs.kernel }} VMLINUX: ${{ github.workspace }}/vmlinux - uses: libbpf/ci/run-vmtest@v2 + LLVM_VERSION: ${{ inputs.llvm-version }} + SELFTESTS_BPF: ${{ github.workspace }}/.kernel/tools/testing/selftests/bpf + VMTEST_CONFIGS: ${{ github.workspace }}/ci/vmtest/configs + uses: libbpf/ci/run-vmtest@v3 with: arch: ${{ inputs.arch }} kbuild-output: ${{ github.workspace }}/.kernel kernel-root: ${{ github.workspace }}/.kernel - kernel-test: ${{ env.KERNEL_TEST || '' }} vmlinuz: ${{ inputs.arch }}/vmlinuz-${{ inputs.kernel }} + diff --git a/ci/vmtest/configs/ALLOWLIST-4.9.0 b/ci/vmtest/configs/ALLOWLIST-4.9.0 deleted file mode 100644 index ee0d3db..0000000 --- a/ci/vmtest/configs/ALLOWLIST-4.9.0 +++ /dev/null @@ -1,8 +0,0 @@ -# btf_dump -- need to disable data dump sub-tests -core_retro -cpu_mask -hashmap -legacy_printk -perf_buffer -section_names - diff --git a/ci/vmtest/configs/ALLOWLIST-5.5.0 b/ci/vmtest/configs/ALLOWLIST-5.5.0 deleted file mode 100644 index 25f3f5e..0000000 --- a/ci/vmtest/configs/ALLOWLIST-5.5.0 +++ /dev/null @@ -1,49 +0,0 @@ -# attach_probe -autoload -bpf_verif_scale -cgroup_attach_autodetach -cgroup_attach_override -core_autosize -core_extern -core_read_macros -core_reloc -core_retro -cpu_mask -endian -get_branch_snapshot -get_stackid_cannot_attach -global_data -global_data_init -global_func_args -hashmap -legacy_printk -linked_funcs -linked_maps -map_lock -obj_name -perf_buffer -perf_event_stackmap -pinning -pkt_md_access -probe_user -queue_stack_map -raw_tp_writable_reject_nbd_invalid -raw_tp_writable_test_run -rdonly_maps -section_names -signal_pending -sockmap_ktls -spinlock -stacktrace_map -stacktrace_map_raw_tp -static_linked -task_fd_query_rawtp -task_fd_query_tp -tc_bpf -tcp_estats -test_global_funcs/arg_tag_ctx* -tp_attach_query -usdt/urand_pid_attach -xdp -xdp_noinline -xdp_perf diff --git a/ci/vmtest/configs/DENYLIST-5.5.0 b/ci/vmtest/configs/DENYLIST-5.5.0 deleted file mode 100644 index f7161d0..0000000 --- a/ci/vmtest/configs/DENYLIST-5.5.0 +++ /dev/null @@ -1,5 +0,0 @@ -# This complements ALLOWLIST-5.5.0 but excludes subtest that can't work on 5.5 - -btf # "size check test", "func (Non zero vlen)" -tailcalls # tailcall_bpf2bpf_1, tailcall_bpf2bpf_2, tailcall_bpf2bpf_3 -tc_bpf/tc_bpf_non_root diff --git a/ci/vmtest/prepare-selftests-run.sh b/ci/vmtest/configs/run-vmtest.env old mode 100755 new mode 100644 similarity index 63% rename from ci/vmtest/prepare-selftests-run.sh rename to ci/vmtest/configs/run-vmtest.env index 35a6d8a..598009f --- a/ci/vmtest/prepare-selftests-run.sh +++ b/ci/vmtest/configs/run-vmtest.env @@ -1,21 +1,12 @@ #!/bin/bash -set -euo pipefail +# This file is sourced by libbpf/ci/run-vmtest Github Action scripts. -function append_into() { - local out="$1" - shift - local files=("$@") - echo -n > "$out" - for file in "${files[@]}"; do - if [[ -f "$file" ]]; then - echo "cat $file >> $out" - cat "$file" >> "$out" - fi - done -} +# $SELFTESTS_BPF and $VMTEST_CONFIGS are set in the workflow, before +# libbpf/ci/run-vmtest action is called +# See .github/workflows/kernel-test.yml -allowlists=( +ALLOWLIST_FILES=( "${SELFTESTS_BPF}/ALLOWLIST" "${SELFTESTS_BPF}/ALLOWLIST.${ARCH}" "${VMTEST_CONFIGS}/ALLOWLIST" @@ -23,9 +14,7 @@ allowlists=( "${VMTEST_CONFIGS}/ALLOWLIST-${KERNEL}.${ARCH}" ) -append_into "${ALLOWLIST_FILE}" "${allowlists[@]}" - -denylists=( +DENYLIST_FILES=( "${SELFTESTS_BPF}/DENYLIST" "${SELFTESTS_BPF}/DENYLIST.${ARCH}" "${VMTEST_CONFIGS}/DENYLIST" @@ -33,7 +22,9 @@ denylists=( "${VMTEST_CONFIGS}/DENYLIST-${KERNEL}.${ARCH}" ) -append_into "${DENYLIST_FILE}" "${denylists[@]}" +# Export pipe-separated strings, because bash doesn't support array export +export SELFTESTS_BPF_ALLOWLIST_FILES=$(IFS="|"; echo "${ALLOWLIST_FILES[*]}") +export SELFTESTS_BPF_DENYLIST_FILES=$(IFS="|"; echo "${DENYLIST_FILES[*]}") if [[ "${LLVM_VERSION}" -lt 18 ]]; then echo "KERNEL_TEST=test_progs test_progs_no_alu32 test_maps test_verifier" >> $GITHUB_ENV @@ -44,4 +35,3 @@ fi echo "cp -R ${SELFTESTS_BPF} ${GITHUB_WORKSPACE}/selftests" mkdir -p "${GITHUB_WORKSPACE}/selftests" cp -R "${SELFTESTS_BPF}" "${GITHUB_WORKSPACE}/selftests" - diff --git a/ci/vmtest/helpers.sh b/ci/vmtest/helpers.sh deleted file mode 100755 index c44d098..0000000 --- a/ci/vmtest/helpers.sh +++ /dev/null @@ -1,38 +0,0 @@ -# shellcheck shell=bash - -# $1 - start or end -# $2 - fold identifier, no spaces -# $3 - fold section description -foldable() { - local YELLOW='\033[1;33m' - local NOCOLOR='\033[0m' - if [ $1 = "start" ]; then - line="::group::$2" - if [ ! -z "${3:-}" ]; then - line="$line - ${YELLOW}$3${NOCOLOR}" - fi - else - line="::endgroup::" - fi - echo -e "$line" -} - -__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/ci/vmtest/prepare-selftests-LATEST.sh b/ci/vmtest/prepare-selftests-LATEST.sh deleted file mode 100755 index d73036e..0000000 --- a/ci/vmtest/prepare-selftests-LATEST.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -# noop script: it's here as a reminder that we might need it for other kernel versions - -# for 4.9.0 and 5.5.0 code was: -# cd "${SELFTESTS_BPF}" -# printf "all:\n\ttouch bpf_testmod.ko\n\nclean:\n" > bpf_testmod/Makefile -# printf "all:\n\ttouch bpf_test_no_cfi.ko\n\nclean:\n" > bpf_test_no_cfi/Makefile - -exit 0 diff --git a/ci/vmtest/run_selftests.sh b/ci/vmtest/run_selftests.sh deleted file mode 100755 index 7ddcb45..0000000 --- a/ci/vmtest/run_selftests.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -source $(cd $(dirname $0) && pwd)/helpers.sh - -ARCH=$(uname -m) - -STATUS_FILE=/exitstatus - -read_lists() { - (for path in "$@"; do - if [[ -s "$path" ]]; then - cat "$path" - fi; - done) | cut -d'#' -f1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -s '\n' ',' -} - -test_progs() { - if [[ "${KERNEL}" != '4.9.0' ]]; then - foldable start test_progs "Testing test_progs" - # "&& true" does not change the return code (it is not executed - # if the Python script fails), but it prevents exiting on a - # failure due to the "set -e". - ./test_progs ${DENYLIST:+-d"$DENYLIST"} ${ALLOWLIST:+-a"$ALLOWLIST"} && true - echo "test_progs:$?" >> "${STATUS_FILE}" - foldable end test_progs - fi -} - -test_progs_no_alu32() { - foldable start test_progs-no_alu32 "Testing test_progs-no_alu32" - ./test_progs-no_alu32 ${DENYLIST:+-d"$DENYLIST"} ${ALLOWLIST:+-a"$ALLOWLIST"} && true - echo "test_progs-no_alu32:$?" >> "${STATUS_FILE}" - foldable end test_progs-no_alu32 -} - -test_maps() { - if [[ "${KERNEL}" == 'latest' ]]; then - foldable start test_maps "Testing test_maps" - ./test_maps && true - echo "test_maps:$?" >> "${STATUS_FILE}" - foldable end test_maps - fi -} - -test_verifier() { - if [[ "${KERNEL}" == 'latest' ]]; then - foldable start test_verifier "Testing test_verifier" - ./test_verifier && true - echo "test_verifier:$?" >> "${STATUS_FILE}" - foldable end test_verifier - fi -} - -foldable end vm_init - -foldable start kernel_config "Kconfig" - -zcat /proc/config.gz - -foldable end kernel_config - - -configs_path=/${PROJECT_NAME}/selftests/bpf -local_configs_path=${PROJECT_NAME}/vmtest/configs -DENYLIST=$(read_lists \ - "$configs_path/DENYLIST" \ - "$configs_path/DENYLIST.${ARCH}" \ - "$local_configs_path/DENYLIST" \ - "$local_configs_path/DENYLIST-${KERNEL}" \ - "$local_configs_path/DENYLIST-${KERNEL}.${ARCH}" \ -) -ALLOWLIST=$(read_lists \ - "$configs_path/ALLOWLIST" \ - "$configs_path/ALLOWLIST.${ARCH}" \ - "$local_configs_path/ALLOWLIST" \ - "$local_configs_path/ALLOWLIST-${KERNEL}" \ - "$local_configs_path/ALLOWLIST-${KERNEL}.${ARCH}" \ -) - -echo "DENYLIST: ${DENYLIST}" -echo "ALLOWLIST: ${ALLOWLIST}" - -cd ${PROJECT_NAME}/selftests/bpf - -if [ $# -eq 0 ]; then - test_progs - test_progs_no_alu32 - # test_maps - test_verifier -else - for test_name in "$@"; do - "${test_name}" - done -fi