Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: bpf: prepare for break up of verifier tests

test_verifier.c has grown to be very long (almost 16 kLoC),
and it is very conflict prone since we always add tests at
the end.

Try to break it apart a little bit. Allow test snippets
to be defined in separate files and include them automatically
into the huge test array.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Jakub Kicinski and committed by
Alexei Starovoitov
2dfb4012 ae575c8a

+17
+13
tools/testing/selftests/bpf/Makefile
··· 212 212 $(BTF_PAHOLE) -J $@ 213 213 endif 214 214 215 + $(OUTPUT)/test_verifier: $(OUTPUT)/verifier/tests.h 216 + $(OUTPUT)/test_verifier: CFLAGS += -I$(OUTPUT) 217 + 218 + VERIFIER_TEST_FILES := $(wildcard verifier/*.c) 219 + $(OUTPUT)/verifier/tests.h: $(VERIFIER_TEST_FILES) 220 + $(shell ( cd verifier/ 221 + echo '/* Generated header, do not edit */'; \ 222 + echo '#ifdef FILL_ARRAY'; \ 223 + ls *.c 2> /dev/null | \ 224 + sed -e 's@\(.*\)@#include \"\1\"@'; \ 225 + echo '#endif' \ 226 + ) > $(OUTPUT)/verifier/tests.h) 227 + 215 228 EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(ALU32_BUILD_DIR)
+3
tools/testing/selftests/bpf/test_verifier.c
··· 248 248 BPF_ALU64_IMM(BPF_ARSH, BPF_REG_7, 32) 249 249 250 250 static struct bpf_test tests[] = { 251 + #define FILL_ARRAY 252 + #include <verifier/tests.h> 253 + #undef FILL_ARRAY 251 254 { 252 255 "add+sub+mul", 253 256 .insns = {
+1
tools/testing/selftests/bpf/verifier/.gitignore
··· 1 + tests.h