]> git.dujemihanovic.xyz Git - linux.git/commitdiff
selftests/bpf: Support multiple tests per file
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 22 Oct 2021 22:32:26 +0000 (15:32 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 25 Oct 2021 21:45:46 +0000 (14:45 -0700)
Revamp how test discovery works for test_progs and allow multiple test
entries per file. Any global void function with no arguments and
serial_test_ or test_ prefix is considered a test.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211022223228.99920-3-andrii@kernel.org
tools/testing/selftests/bpf/Makefile

index 498222543c374a0a9efb7711b7e242d8784c3331..ac47cf9760fc56c6eca8f9313c5b0a2deacd77f0 100644 (file)
@@ -421,10 +421,9 @@ ifeq ($($(TRUNNER_TESTS_DIR)-tests-hdr),)
 $(TRUNNER_TESTS_DIR)-tests-hdr := y
 $(TRUNNER_TESTS_HDR): $(TRUNNER_TESTS_DIR)/*.c
        $$(call msg,TEST-HDR,$(TRUNNER_BINARY),$$@)
-       $$(shell ( cd $(TRUNNER_TESTS_DIR);                             \
-                 echo '/* Generated header, do not edit */';           \
-                 ls *.c 2> /dev/null |                                 \
-                       sed -e 's@\([^\.]*\)\.c@DEFINE_TEST(\1)@';      \
+       $$(shell (echo '/* Generated header, do not edit */';                                   \
+                 sed -n -E 's/^void (serial_)?test_([a-zA-Z0-9_]+)\((void)?\).*/DEFINE_TEST(\2)/p'     \
+                       $(TRUNNER_TESTS_DIR)/*.c | sort ;       \
                 ) > $$@)
 endif