Skip to content

Commit

Permalink
run-vmtest: sched_ext selftests support
Browse files Browse the repository at this point in the history
  • Loading branch information
theihor committed Oct 24, 2024
1 parent 4c85516 commit a68f941
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 18 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions ci/vmtest/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' ','
}
19 changes: 19 additions & 0 deletions ci/vmtest/sched_ext_selftests.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions ci/vmtest/vmtest_selftests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand Down
9 changes: 7 additions & 2 deletions run-vmtest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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: |
Expand Down
27 changes: 20 additions & 7 deletions run-vmtest/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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..."
Expand All @@ -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 }')"

Expand Down

0 comments on commit a68f941

Please sign in to comment.