[PATCH] selftests/bpf: split -extras target to -static and -gen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is difference in depoying static and generated extra resource
files between in/out of tree build and flavors:

- in case of unflavored out-of-tree build static files are not
available and must be copied as well as both static and generated
files for flavored build.

So split the rules and variables. The name TRUNNER_EXTRA_GEN_FILES
is chosen in analogy to TEST_GEN_* variants.

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@xxxxxxxxxx>
---
 tools/testing/selftests/bpf/Makefile | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 26497d8869ea..c80c06272759 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -363,12 +363,28 @@ $(TRUNNER_EXTRA_OBJS): $(TRUNNER_OUTPUT)/%.o:				\
 	$$(call msg,EXT-OBJ,$(TRUNNER_BINARY),$$@)
 	$$(CC) $$(CFLAGS) -c $$< $$(LDLIBS) -o $$@
 
-# only copy extra resources if in flavored build
-$(TRUNNER_BINARY)-extras: $(TRUNNER_EXTRA_FILES) | $(TRUNNER_OUTPUT)
-ifneq ($2,)
+# copy extra resources when needed.
+# Static files for both out of tree and flavored (so, not current dir).
+# Generated files for flavored only.
+$(TRUNNER_BINARY)-extras: $(TRUNNER_BINARY)-extras-static \
+			  $(TRUNNER_BINARY)-extras-gen
+
+$(TRUNNER_BINARY)-extras-static: $(TRUNNER_EXTRA_FILES) | $(TRUNNER_OUTPUT)
+ifneq ($(CURDIR)),$(realpath $(TRUNNER_OUTPUT)))
 	$$(call msg,EXT-COPY,$(TRUNNER_BINARY),$(TRUNNER_EXTRA_FILES))
+ifneq ($(TRUNNER_EXTRA_FILES),)
 	cp -a $$^ $(TRUNNER_OUTPUT)/
 endif
+endif
+
+$(TRUNNER_BINARY)-extras-gen: $(addprefix $(OUTPUT)/,$(TRUNNER_EXTRA_GEN_FILES)) \
+			    | $(TRUNNER_OUTPUT)
+ifneq ($2,)
+	$$(call msg,EXT-COPY,$(TRUNNER_BINARY),$(TRUNNER_EXTRA_GEN_FILES))
+ifneq ($(TRUNNER_EXTRA_GEN_FILES),)
+	cp -a $$^ $(TRUNNER_OUTPUT)/
+endif
+endif
 
 $(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS)			\
 			     $(TRUNNER_EXTRA_OBJS) $$(BPFOBJ)		\
@@ -384,7 +400,8 @@ TRUNNER_BPF_PROGS_DIR := progs
 TRUNNER_EXTRA_SOURCES := test_progs.c cgroup_helpers.c trace_helpers.c	\
 			 network_helpers.c testing_helpers.c		\
 			 flow_dissector_load.h
-TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read $(BTF_C_FILES)
+TRUNNER_EXTRA_FILES := $(BTF_C_FILES)
+TRUNNER_EXTRA_GEN_FILES := urandom_read
 TRUNNER_BPF_BUILD_RULE := CLANG_BPF_BUILD_RULE
 TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS)
 TRUNNER_BPF_LDFLAGS := -mattr=+alu32
@@ -408,6 +425,7 @@ TRUNNER_TESTS_DIR := map_tests
 TRUNNER_BPF_PROGS_DIR := progs
 TRUNNER_EXTRA_SOURCES := test_maps.c
 TRUNNER_EXTRA_FILES :=
+TRUNNER_EXTRA_GEN_FILES :=
 TRUNNER_BPF_BUILD_RULE := $$(error no BPF objects should be built)
 TRUNNER_BPF_CFLAGS :=
 TRUNNER_BPF_LDFLAGS :=
-- 
2.26.2




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux