selftests: bpf: prepare for break up of verifier tests
authorJakub Kicinski <jakub.kicinski@netronome.com>
Fri, 25 Jan 2019 23:24:42 +0000 (15:24 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 28 Jan 2019 05:37:45 +0000 (21:37 -0800)
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>
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/bpf/test_verifier.c
tools/testing/selftests/bpf/verifier/.gitignore [new file with mode: 0644]

index d61b023c8ddc339d469ffc6bf8e31f67326f4b42..89b0d1799ff3a5bfadea532b53b724996b3269b2 100644 (file)
@@ -212,4 +212,17 @@ ifeq ($(DWARF2BTF),y)
        $(BTF_PAHOLE) -J $@
 endif
 
+$(OUTPUT)/test_verifier: $(OUTPUT)/verifier/tests.h
+$(OUTPUT)/test_verifier: CFLAGS += -I$(OUTPUT)
+
+VERIFIER_TEST_FILES := $(wildcard verifier/*.c)
+$(OUTPUT)/verifier/tests.h: $(VERIFIER_TEST_FILES)
+       $(shell ( cd verifier/
+                 echo '/* Generated header, do not edit */'; \
+                 echo '#ifdef FILL_ARRAY'; \
+                 ls *.c 2> /dev/null | \
+                       sed -e 's@\(.*\)@#include \"\1\"@'; \
+                 echo '#endif' \
+                ) > $(OUTPUT)/verifier/tests.h)
+
 EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(ALU32_BUILD_DIR)
index 1df757645a9a928ead523aab8e73bdb24758c418..0a1847c3d1a3b0dee298ab4ddd3efe4aee51fdf1 100644 (file)
@@ -248,6 +248,9 @@ static void bpf_fill_rand_ld_dw(struct bpf_test *self)
        BPF_ALU64_IMM(BPF_ARSH, BPF_REG_7, 32)
 
 static struct bpf_test tests[] = {
+#define FILL_ARRAY
+#include <verifier/tests.h>
+#undef FILL_ARRAY
        {
                "add+sub+mul",
                .insns = {
diff --git a/tools/testing/selftests/bpf/verifier/.gitignore b/tools/testing/selftests/bpf/verifier/.gitignore
new file mode 100644 (file)
index 0000000..45984a3
--- /dev/null
@@ -0,0 +1 @@
+tests.h