From a68f94112e48005f002f0acc5f98ea0e316a47e6 Mon Sep 17 00:00:00 2001 From: Ihor Solodrai Date: Thu, 24 Oct 2024 14:35:05 -0700 Subject: [PATCH] run-vmtest: sched_ext selftests support --- .github/workflows/test.yml | 8 +++++++- ci/vmtest/helpers.sh | 8 ++++++++ ci/vmtest/sched_ext_selftests.sh | 19 +++++++++++++++++++ ci/vmtest/vmtest_selftests.sh | 8 -------- run-vmtest/action.yml | 9 +++++++-- run-vmtest/run.sh | 27 ++++++++++++++++++++------- 6 files changed, 61 insertions(+), 18 deletions(-) create mode 100755 ci/vmtest/sched_ext_selftests.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ae3e273..0604f3d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,13 @@ jobs: toolchain: - {"name": "gcc", "fullname": "gcc", "version": 17} - {"name": "llvm", "fullname": "llvm-17", "version": 17} - tests: [{"include": [{"test": "test_progs", "continue_on_error": false, "timeout_minutes": 360}, {"test": "test_progs_no_alu32", "continue_on_error": false, "timeout_minutes": 360}, {"test": "test_verifier", "continue_on_error": false, "timeout_minutes": 360}, {"test": "test_maps", "continue_on_error": false, "timeout_minutes": 360}]}] + tests: + - include: + - {"test": "test_progs", "continue_on_error": false, "timeout_minutes": 360} + - {"test": "test_progs_no_alu32", "continue_on_error": false, "timeout_minutes": 360} + - {"test": "test_verifier", "continue_on_error": false, "timeout_minutes": 360} + - {"test": "test_maps", "continue_on_error": false, "timeout_minutes": 360} + - {"test": "sched_ext", "continue_on_error": false, "timeout_minutes": 360} fail-fast: false # Setting name to arch-compiler here to avoid lengthy autogenerated names due to matrix # e.g build-and-test x86_64-gcc / test (test_progs_parallel, true, 30) / test_progs_parallel on x86_64 with gcc diff --git a/ci/vmtest/helpers.sh b/ci/vmtest/helpers.sh index c44d098..86c734c 100755 --- a/ci/vmtest/helpers.sh +++ b/ci/vmtest/helpers.sh @@ -36,3 +36,11 @@ print_error() { print_notice() { __print notice $1 $2 } + +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' ',' +} diff --git a/ci/vmtest/sched_ext_selftests.sh b/ci/vmtest/sched_ext_selftests.sh new file mode 100755 index 0000000..a20672d --- /dev/null +++ b/ci/vmtest/sched_ext_selftests.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd "$(dirname "$0")" && pwd)/helpers.sh" + +foldable start selftests/sched_ext "Executing selftests/sched_ext/runner" + +SELFTESTS_DIR="${KERNEL_ROOT}/selftests/sched_ext" +STATUS_FILE=/mnt/vmtest/exitstatus + +cd "${SELFTESTS_DIR}" +./runner "$@" | tee runner.log + +failed=$(tail -n 16 runner.log | grep "FAILED" | awk '{print $2}') + +echo "selftests/sched_ext:$failed" >>"${STATUS_FILE}" + +foldable end selftests/sched_ext diff --git a/ci/vmtest/vmtest_selftests.sh b/ci/vmtest/vmtest_selftests.sh index b37eded..699a92e 100755 --- a/ci/vmtest/vmtest_selftests.sh +++ b/ci/vmtest/vmtest_selftests.sh @@ -22,14 +22,6 @@ WORKING_DIR="/${PROJECT_NAME}" BPF_SELFTESTS_DIR="${WORKING_DIR}/selftests/bpf" VMTEST_CONFIGS_PATH="${WORKING_DIR}/ci/vmtest/configs" -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' ',' -} - DENYLIST=$(read_lists \ "$BPF_SELFTESTS_DIR/DENYLIST" \ "$BPF_SELFTESTS_DIR/DENYLIST.${ARCH}" \ diff --git a/run-vmtest/action.yml b/run-vmtest/action.yml index d998990..17cfee6 100644 --- a/run-vmtest/action.yml +++ b/run-vmtest/action.yml @@ -29,6 +29,10 @@ inputs: required: false type: string default: 'kbuild-output' + vmtest-release: + description: 'Release version of vmtest tool to use' + required: false + default: 'v0.14.0' runs: using: "composite" @@ -42,9 +46,10 @@ runs: cp "$vmlinuz" ${{ inputs.vmlinuz }} - name: Download vmtest shell: bash - # FIXME: move to proper release run: | - sudo curl -L https://github.com/danobi/vmtest/releases/download/v0.12.0/vmtest-$(uname -m) -o /usr/bin/vmtest && sudo chmod 755 /usr/bin/vmtest + VMTEST_URL="https://github.com/danobi/vmtest/releases/download/${{ inputs.vmtest-release }}/vmtest-$(uname -m)" + sudo curl -L $VMTEST_URL -o /usr/bin/vmtest + sudo chmod 755 /usr/bin/vmtest - name: install qemu tools and selftest dependencies shell: bash run: | diff --git a/run-vmtest/run.sh b/run-vmtest/run.sh index b1cc175..08e030a 100755 --- a/run-vmtest/run.sh +++ b/run-vmtest/run.sh @@ -3,14 +3,28 @@ set -euo pipefail trap 'exit 2' ERR -source $(cd $(dirname $0) && pwd)/../helpers.sh +source "${GITHUB_ACTION_PATH}/../helpers.sh" + +RUN_BPFTOOL_CHECKS= + +if [[ "$KERNEL_TEST" != "sched_ext" ]]; then + VMTEST_SCRIPT="${GITHUB_ACTION_PATH}/../ci/vmtest/vmtest_selftests.sh" + if [[ "${KERNEL}" = 'LATEST' ]]; then + RUN_BPFTOOL_CHECKS=true + fi +else + VMTEST_SCRIPT="${GITHUB_ACTION_PATH}/../ci/vmtest/sched_ext_selftests.sh" +fi + +# clear exitstatus file +echo -n "" > exitstatus foldable start bpftool_checks "Running bpftool checks..." -bpftool_exitstatus=0 # bpftool checks are aimed at checking type names, documentation, shell # completion etc. against the current kernel, so only run on LATEST. -if [[ "${KERNEL}" = 'LATEST' ]]; then +if [[ -n "${RUN_BPFTOOL_CHECKS}" ]]; then + bpftool_exitstatus=0 # "&& 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. @@ -21,11 +35,11 @@ if [[ "${KERNEL}" = 'LATEST' ]]; then else echo "bpftool checks returned ${bpftool_exitstatus}." fi + echo "bpftool:${bpftool_exitstatus}" >> exitstatus else echo "bpftool checks skipped." fi -bpftool_exitstatus="bpftool:${bpftool_exitstatus}" foldable end bpftool_checks foldable start vmtest "Starting virtual machine..." @@ -37,14 +51,13 @@ vmtest -k "${VMLINUZ}" --kargs "panic=-1 sysctl.vm.panic_on_oom=1" "umount /tmp /bin/mount bpffs /sys/fs/bpf -t bpf && \ ip link set lo up && \ cd '${GITHUB_WORKSPACE}' && \ - ./ci/vmtest/vmtest_selftests.sh ${T}" + ${VMTEST_SCRIPT} ${T}" foldable end vmtest foldable start collect_status "Collecting exit status" -exitfile="${bpftool_exitstatus}\n" -exitfile+="$(cat exitstatus 2>/dev/null)" +exitfile="$(cat exitstatus 2>/dev/null)" exitstatus="$(echo -e "$exitfile" | awk --field-separator ':' \ 'BEGIN { s=0 } { if ($2) {s=1} } END { print s }')"