|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +source $(cd $(dirname $0) && pwd)/helpers.sh |
| 6 | + |
| 7 | +ARCH=$(uname -m) |
| 8 | + |
| 9 | +STATUS_FILE=/exitstatus |
| 10 | + |
| 11 | +read_lists() { |
| 12 | + (for path in "$@"; do |
| 13 | + if [[ -s "$path" ]]; then |
| 14 | + cat "$path" |
| 15 | + fi; |
| 16 | + done) | cut -d'#' -f1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -s '\n' ',' |
| 17 | +} |
| 18 | + |
| 19 | +TEST_PROGS_ARGS="" |
| 20 | +# Disabled due to issue |
| 21 | +# if [[ "$(nproc)" -gt 2 ]]; then |
| 22 | +# TEST_PROGS_ARGS="-j" |
| 23 | +# fi |
| 24 | + |
| 25 | +test_progs() { |
| 26 | + foldable start test_progs "Testing test_progs" |
| 27 | + # "&& true" does not change the return code (it is not executed |
| 28 | + # if the Python script fails), but it prevents exiting on a |
| 29 | + # failure due to the "set -e". |
| 30 | + ./test_progs ${DENYLIST:+-d"$DENYLIST"} ${ALLOWLIST:+-a"$ALLOWLIST"} ${TEST_PROGS_ARGS} && true |
| 31 | + echo "test_progs:$?" >>"${STATUS_FILE}" |
| 32 | + foldable end test_progs |
| 33 | +} |
| 34 | + |
| 35 | +test_progs_no_alu32() { |
| 36 | + foldable start test_progs-no_alu32 "Testing test_progs-no_alu32" |
| 37 | + ./test_progs-no_alu32 ${DENYLIST:+-d"$DENYLIST"} ${ALLOWLIST:+-a"$ALLOWLIST"} ${TEST_PROGS_ARGS} && true |
| 38 | + echo "test_progs-no_alu32:$?" >>"${STATUS_FILE}" |
| 39 | + foldable end test_progs-no_alu32 |
| 40 | +} |
| 41 | + |
| 42 | +test_maps() { |
| 43 | + foldable start test_maps "Testing test_maps" |
| 44 | + taskset 0xF ./test_maps && true |
| 45 | + echo "test_maps:$?" >>"${STATUS_FILE}" |
| 46 | + foldable end test_maps |
| 47 | +} |
| 48 | + |
| 49 | +test_verifier() { |
| 50 | + foldable start test_verifier "Testing test_verifier" |
| 51 | + ./test_verifier && true |
| 52 | + echo "test_verifier:$?" >>"${STATUS_FILE}" |
| 53 | + foldable end test_verifier |
| 54 | +} |
| 55 | + |
| 56 | +foldable end vm_init |
| 57 | + |
| 58 | +foldable start kernel_config "Kconfig" |
| 59 | + |
| 60 | +zcat /proc/config.gz |
| 61 | + |
| 62 | +foldable end kernel_config |
| 63 | + |
| 64 | +configs_path=${PROJECT_NAME}/selftests/bpf |
| 65 | +local_configs_path=${PROJECT_NAME}/vmtest/configs |
| 66 | +DENYLIST=$(read_lists \ |
| 67 | + "$configs_path/DENYLIST" \ |
| 68 | + "$configs_path/DENYLIST.${ARCH}" \ |
| 69 | + "$local_configs_path/DENYLIST" \ |
| 70 | + "$local_configs_path/DENYLIST.${ARCH}" \ |
| 71 | +) |
| 72 | +ALLOWLIST=$(read_lists \ |
| 73 | + "$configs_path/ALLOWLIST" \ |
| 74 | + "$configs_path/ALLOWLIST.${ARCH}" \ |
| 75 | + "$local_configs_path/ALLOWLIST" \ |
| 76 | + "$local_configs_path/ALLOWLIST.${ARCH}" \ |
| 77 | +) |
| 78 | + |
| 79 | +echo "DENYLIST: ${DENYLIST}" |
| 80 | +echo "ALLOWLIST: ${ALLOWLIST}" |
| 81 | + |
| 82 | +cd ${PROJECT_NAME}/selftests/bpf |
| 83 | + |
| 84 | +if [ $# -eq 0 ]; then |
| 85 | + test_progs |
| 86 | + test_progs_no_alu32 |
| 87 | + test_maps |
| 88 | + test_verifier |
| 89 | +else |
| 90 | + for test_name in "$@"; do |
| 91 | + "${test_name}" |
| 92 | + done |
| 93 | +fi |
0 commit comments