Skip to content

Commit 207cf6e

Browse files
cupermiranakryiko
authored andcommitted
selftests/bpf: Add CFLAGS per source file and runner
This patch adds support to specify CFLAGS per source file and per test runner. Signed-off-by: Cupertino Miranda <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 675b4e2 commit 207cf6e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

tools/testing/selftests/bpf/Makefile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ TEST_INST_SUBDIRS += bpf_gcc
8181
# The following tests contain C code that, although technically legal,
8282
# triggers GCC warnings that cannot be disabled: declaration of
8383
# anonymous struct types in function parameter lists.
84-
progs/btf_dump_test_case_bitfields.c-CFLAGS := -Wno-error
85-
progs/btf_dump_test_case_namespacing.c-CFLAGS := -Wno-error
86-
progs/btf_dump_test_case_packing.c-CFLAGS := -Wno-error
87-
progs/btf_dump_test_case_padding.c-CFLAGS := -Wno-error
88-
progs/btf_dump_test_case_syntax.c-CFLAGS := -Wno-error
84+
progs/btf_dump_test_case_bitfields.c-bpf_gcc-CFLAGS := -Wno-error
85+
progs/btf_dump_test_case_namespacing.c-bpf_gcc-CFLAGS := -Wno-error
86+
progs/btf_dump_test_case_packing.c-bpf_gcc-CFLAGS := -Wno-error
87+
progs/btf_dump_test_case_padding.c-bpf_gcc-CFLAGS := -Wno-error
88+
progs/btf_dump_test_case_syntax.c-bpf_gcc-CFLAGS := -Wno-error
8989
endif
9090

9191
ifneq ($(CLANG_CPUV4),)
@@ -470,7 +470,7 @@ LINKED_BPF_SRCS := $(patsubst %.bpf.o,%.c,$(foreach skel,$(LINKED_SKELS),$($(ske
470470
# $eval()) and pass control to DEFINE_TEST_RUNNER_RULES.
471471
# Parameters:
472472
# $1 - test runner base binary name (e.g., test_progs)
473-
# $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, gcc-bpf, etc)
473+
# $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, bpf_gcc, etc)
474474
define DEFINE_TEST_RUNNER
475475

476476
TRUNNER_OUTPUT := $(OUTPUT)$(if $2,/)$2
@@ -498,7 +498,7 @@ endef
498498
# Using TRUNNER_XXX variables, provided by callers of DEFINE_TEST_RUNNER and
499499
# set up by DEFINE_TEST_RUNNER itself, create test runner build rules with:
500500
# $1 - test runner base binary name (e.g., test_progs)
501-
# $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, gcc-bpf, etc)
501+
# $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, bpf_gcc, etc)
502502
define DEFINE_TEST_RUNNER_RULES
503503

504504
ifeq ($($(TRUNNER_OUTPUT)-dir),)
@@ -521,7 +521,8 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o: \
521521
| $(TRUNNER_OUTPUT) $$(BPFOBJ)
522522
$$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \
523523
$(TRUNNER_BPF_CFLAGS) \
524-
$$($$<-CFLAGS))
524+
$$($$<-CFLAGS) \
525+
$$($$<-$2-CFLAGS))
525526

526527
$(TRUNNER_BPF_SKELS): %.skel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
527528
$$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)

0 commit comments

Comments
 (0)