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