Skip to content

Commit

Permalink
run-vmtest: misc scripts updates
Browse files Browse the repository at this point in the history
* remove boot parameter processing in run-bpf-selftests.sh
* add logging to run.sh re VMLINUX and VMLINUZ variables

Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>
  • Loading branch information
theihor committed Nov 18, 2024
1 parent b6d0593 commit 5502345
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 35 deletions.
35 changes: 3 additions & 32 deletions run-vmtest/run-bpf-selftests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
# See also action.yml and run.sh
#
# The script executes the tests within $SELFTESTS_BPF directory.
# If no specific test names are given, all test runners will be
# executed. Otherwise, executed runners passed as parameters.
# There are 2 ways to pass test names.
# 1) command-line arguments to this script
# 2) a comma-separated list of test names passed as `run_tests` boot
# parameters.
# Runners passed as arguments are executed. In case of no arguments,
# all test runners are executed.

set -euo pipefail

Expand All @@ -31,30 +27,6 @@ ALLOWLIST=$(read_lists "${ALLOWLIST_FILE}")
DENYLIST_FILE=${DENYLIST_FILE:-}
DENYLIST=$(read_lists "${DENYLIST_FILE}")

declare -a TEST_NAMES=()

read_test_names() {
foldable start read_test_names "Reading test names from boot parameters and command line arguments"
# Check if test names were passed as boot parameter.
# We expect `run_tests` to be a comma-separated list of test names.
IFS=',' read -r -a test_names_from_boot <<< \
"$(sed -n 's/.*run_tests=\([^ ]*\).*/\1/p' /proc/cmdline)"
echo "${#test_names_from_boot[@]} tests extracted from boot parameters: ${test_names_from_boot[*]}"
# Sort and only keep unique test names from both boot params and arguments
# TEST_NAMES will contain a sorted list of uniq tests to be ran.
# Only do this if any of $test_names_from_boot[@] or $@ has elements as
# "printf '%s\0'" will otherwise generate an empty element.
if [[ ${#test_names_from_boot[@]} -gt 0 || $# -gt 0 ]]
then
readarray -t TEST_NAMES < \
<(printf '%s\0' "${test_names_from_boot[@]}" "$@" | \
sort --zero-terminated --unique | \
xargs --null --max-args=1)
fi
foldable end read_test_names
}
test_progs_helper() {
local selftest="test_progs${1}"
local args="$2"
Expand Down Expand Up @@ -167,8 +139,7 @@ echo "ALLOWLIST: ${ALLOWLIST}"

cd $SELFTESTS_BPF

# populate TEST_NAMES
read_test_names "$@"
declare -a TEST_NAMES=($@)
# if we don't have any test name provided to the script, we run all tests.
if [ ${#TEST_NAMES[@]} -eq 0 ]; then
test_progs
Expand Down
12 changes: 9 additions & 3 deletions run-vmtest/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@ source "${GITHUB_ACTION_PATH}/../helpers.sh"

export VMLINUZ=${VMLINUZ:-}
if [[ ! -f "${VMLINUZ}" ]]; then
echo "Could not find VMLINUZ=\"$VMLINUZ\", searching with make -s image_name"
image_name=$(make -C ${KERNEL_ROOT} -s image_name)
export VMLINUZ=$(realpath ${KBUILD_OUTPUT})/${image_name}
fi

if [[ ! -f "${VMLINUZ}" ]]; then
echo "Could not find VMLINUZ (compressed kernel binary), exiting"
exit 2
fi

# Create a symlink to vmlinux from a "standard" location
# See btf__load_vmlinux_btf() in libbpf
VMLINUX=${VMLINUX:-"$KBUILD_OUTPUT/vmlinux"}
export VMLINUX=${VMLINUX:-"$KBUILD_OUTPUT/vmlinux"}
if [[ -f "${VMLINUX}" ]]; then
VMLINUX_VERSION="$(strings ${VMLINUX} | grep -m 1 'Linux version' | awk '{print $3}')" || true
sudo mkdir -p /usr/lib/debug/boot
sudo ln -sf "${VMLINUX}" "/usr/lib/debug/boot/vmlinux-${VMLINUX_VERSION}"
else
echo "$VMLINUX does not exist"
echo "Could not find VMLINUX=\"$VMLINUX\", exiting"
exit 2
fi

Expand All @@ -41,7 +47,7 @@ else
fi

# clear exitstatus file
echo -n "" > exitstatus
echo -n > exitstatus

foldable start bpftool_checks "Running bpftool checks..."

Expand Down

0 comments on commit 5502345

Please sign in to comment.