Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run-vmtest: sched_ext selftests support #149

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ 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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

- 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}
# Uncomment this to enable sched_ext selftests jobs
# - {"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
36 changes: 24 additions & 12 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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the change from $(cd $(dirname $0) && pwd) to ${GITHUB_ACTION_PATH}?

Copy link
Contributor Author

@theihor theihor Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been trying to use common env vars for paths everywhere, and $GITHUB_ACTION_PATH makes most sense for actions, when you're looking for relative paths.

However, in this case I don't think important, so I don't mind leaving pwd.

Any particular reasons in favor of $(cd $(dirname $0) && pwd)?


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,30 +35,28 @@ 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..."

# Tests may be comma-separated. vmtest_selftest expect them to come from CLI space-separated.
T=$(echo ${KERNEL_TEST} | tr -s ',' ' ')
# HACK: We need to unmount /tmp to access /tmp from the container....
vmtest -k "${VMLINUZ}" --kargs "panic=-1 sysctl.vm.panic_on_oom=1" "umount /tmp && \
Comment on lines -35 to -36
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was surprised to see this.... but we essentially do not need to umount /tmp since danobi/vmtest@0a63dce

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I actually had to remove it, otherwise it failed to umount.

/bin/mount bpffs /sys/fs/bpf -t bpf && \
ip link set lo up && \
cd '${GITHUB_WORKSPACE}' && \
./ci/vmtest/vmtest_selftests.sh ${T}"
vmtest -k "${VMLINUZ}" --kargs "panic=-1 sysctl.vm.panic_on_oom=1" \
"/bin/mount bpffs /sys/fs/bpf -t bpf && \
ip link set lo up && \
cd '${GITHUB_WORKSPACE}' && \
${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
Loading