Skip to content

Commit

Permalink
adding/updating ci files
Browse files Browse the repository at this point in the history
  • Loading branch information
chantra committed Oct 17, 2022
1 parent 0bd818d commit da314e0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
1 change: 0 additions & 1 deletion ci/vmtest/configs/DENYLIST
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ kprobe_multi_test/bench_attach
core_reloc/enum64val
core_reloc/size___diff_sz
core_reloc/type_based___diff_sz
verify_pkcs7_sig
41 changes: 39 additions & 2 deletions ci/vmtest/run_selftests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/bash

# run_selftest.sh will run the tests within /${PROJECT_NAME}/selftests/bpf
# If no specific test names are given, all test will be ran, otherwise, it will
# run the test passed as parameters.
# There is 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.
# test names passed as any of those methods will be ran.

set -euo pipefail

source $(cd $(dirname $0) && pwd)/helpers.sh
Expand All @@ -8,6 +16,8 @@ ARCH=$(uname -m)

STATUS_FILE=/exitstatus

declare -a TEST_NAMES=()

read_lists() {
(for path in "$@"; do
if [[ -s "$path" ]]; then
Expand All @@ -22,6 +32,28 @@ TEST_PROGS_ARGS=""
# TEST_PROGS_ARGS="-j"
# fi

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() {
foldable start test_progs "Testing test_progs"
# "&& true" does not change the return code (it is not executed
Expand Down Expand Up @@ -81,13 +113,18 @@ echo "ALLOWLIST: ${ALLOWLIST}"
cd ${PROJECT_NAME}/selftests/bpf
if [ $# -eq 0 ]; then
# populate TEST_NAMES
read_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
test_progs_no_alu32
test_maps
test_verifier
else
for test_name in "$@"; do
# else we run the tests passed as command-line arguments and through boot
# parameter.
for test_name in "${TEST_NAMES[@]}"; do
"${test_name}"
done
fi

0 comments on commit da314e0

Please sign in to comment.