Skip to content

Commit

Permalink
ci/vmtest: introduce run-vmtest.env
Browse files Browse the repository at this point in the history
  • Loading branch information
theihor committed Jan 9, 2025
1 parent cf9969d commit 947036b
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 60 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/kernel-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,18 @@ jobs:
# zstd is installed by default in the runner images.
run: zstd -d -T0 vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}.tar.zst --stdout | tar -xf -

- name: Prepare to run selftests
env:
ARCH: ${{ inputs.arch }}
DEPLOYMENT: ${{ env.DEPLOYMENT }}
KERNEL_TEST: ${{ inputs.test }}
SELFTESTS_BPF: ${{ github.workspace }}/selftests/bpf
VMTEST_CONFIGS: ${{ github.workspace }}/ci/vmtest/configs
shell: bash
run: ${{ github.workspace }}/ci/vmtest/prepare-selftests-run.sh

- name: Run selftests
uses: ./run-vmtest
# https://github.com/actions/runner/issues/1483#issuecomment-1031671517
# booleans are weird in GH.
continue-on-error: ${{ fromJSON(env.CONTINUE_ON_ERROR) }}
timeout-minutes: ${{ inputs.timeout_minutes }}
env:
ARCH: ${{ inputs.arch }}
DEPLOYMENT: ${{ env.DEPLOYMENT }}
KERNEL_TEST: ${{ inputs.test }}
SELFTESTS_BPF: ${{ github.workspace }}/selftests/bpf
VMTEST_CONFIGS: ${{ github.workspace }}/ci/vmtest/configs
TEST_PROGS_WATCHDOG_TIMEOUT: 300
with:
arch: ${{ inputs.arch }}
Expand Down
38 changes: 38 additions & 0 deletions ci/vmtest/configs/run-vmtest.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# This file is sourced by libbpf/ci/run-vmtest Github Action scripts.
#
# The primary reason it exists is that assembling ALLOWLIST and
# DENYLIST for a particular test run is not a trivial operation.
#
# Users of libbpf/ci/run-vmtest action need to be able to specify a
# list of allow/denylist **files**, that later has to be correctly
# merged into a single allow/denylist passed to a test runner.
#
# Obviously it's perferrable for the scripts merging many lists into
# one to be reusable, and not copy-pasted between repositories which
# use libbpf/ci actions. And specifying the lists should be trivial.
# This file is a solution to that.

ALLOWLIST_FILES=(
"${SELFTESTS_BPF}/ALLOWLIST"
"${SELFTESTS_BPF}/ALLOWLIST.${ARCH}"
"${VMTEST_CONFIGS}/ALLOWLIST"
"${VMTEST_CONFIGS}/ALLOWLIST.${ARCH}"
"${VMTEST_CONFIGS}/ALLOWLIST.${DEPLOYMENT}"
"${VMTEST_CONFIGS}/ALLOWLIST.${KERNEL_TEST}"
)

DENYLIST_FILES=(
"${SELFTESTS_BPF}/DENYLIST"
"${SELFTESTS_BPF}/DENYLIST.${ARCH}"
"${VMTEST_CONFIGS}/DENYLIST"
"${VMTEST_CONFIGS}/DENYLIST.${ARCH}"
"${VMTEST_CONFIGS}/DENYLIST.${DEPLOYMENT}"
"${VMTEST_CONFIGS}/DENYLIST.${KERNEL_TEST}"
)

# 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[*]}")

45 changes: 0 additions & 45 deletions ci/vmtest/prepare-selftests-run.sh

This file was deleted.

File renamed without changes.
30 changes: 30 additions & 0 deletions run-vmtest/prepare-bpf-selftests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -euo pipefail

function merge_test_lists_into() {
local out="$1"
shift
local files=("$@")
echo -n > "$out"

# first, append all the input lists into one
for file in "${files[@]}"; do
if [[ -f "$file" ]]; then
echo "cat $file >> $out"
cat "$file" >> "$out"
fi
done

# then merge the list of test names
cat "$out" | python3 "$(dirname $0)/merge_test_lists.py" > "$out"
}

# Read arrays from pipe-separated strings
IFS="|" read -a ALLOWLIST_FILES <<< "$SELFTESTS_BPF_ALLOWLIST_FILES"
IFS="|" read -a DENYLIST_FILES <<< "$SELFTESTS_BPF_DENYLIST_FILES"

merge_test_lists_into "${ALLOWLIST_FILE}" "${ALLOWLIST_FILES[@]}"
merge_test_lists_into "${DENYLIST_FILE}" "${DENYLIST_FILES[@]}"

exit 0
17 changes: 12 additions & 5 deletions run-vmtest/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@ then
RUN_BPFTOOL_CHECKS=true
fi

VMTEST_CONFIGS=${VMTEST_CONFIGS:-}
if [[ -n "$VMTEST_CONFIGS" && -f "${VMTEST_CONFIGS}/run-vmtest.env" ]];
then
source "${VMTEST_CONFIGS:-}/run-vmtest.env"
fi

VMTEST_SCRIPT=${VMTEST_SCRIPT:-}
if [[ -z "$VMTEST_SCRIPT" \
&& "$KERNEL_TEST" != "sched_ext" ]];
if [[ -z "$VMTEST_SCRIPT" && "$KERNEL_TEST" == "sched_ext" ]];
then
VMTEST_SCRIPT="${GITHUB_ACTION_PATH}/run-bpf-selftests.sh"
else
VMTEST_SCRIPT="${GITHUB_ACTION_PATH}/run-scx-selftests.sh"
VMTEST_SCRIPT="${GITHUB_ACTION_PATH}/run-scx-selftests.sh"
elif [[ -z "$VMTEST_SCRIPT" ]];
then
${GITHUB_ACTION_PATH}/prepare-bpf-selftests.sh
VMTEST_SCRIPT="${GITHUB_ACTION_PATH}/run-bpf-selftests.sh"
fi

# clear exitstatus file
Expand Down

0 comments on commit 947036b

Please sign in to comment.