From: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
To: bpf@vger.kernel.org
Cc: Jiri Benc <jbenc@redhat.com>, Jiri Olsa <jolsa@redhat.com>,
Andrii Nakryiko <andriin@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>
Subject: [PATCH 7/8] selftests/bpf: fix test.h placing for out of tree build
Date: Fri, 22 May 2020 07:13:09 +0300 [thread overview]
Message-ID: <20200522041310.233185-8-yauheni.kaliuta@redhat.com> (raw)
In-Reply-To: <20200522041310.233185-1-yauheni.kaliuta@redhat.com>
Flavors of test.h are generated in tree even for out of tree
build. Use OUTPUT directory for that.
It requires rules to make sure the directories exist.
Split EXTRA_CLEAN generation since existance of test.h files depends
of dynamic makefile generation.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
---
tools/testing/selftests/bpf/Makefile | 38 +++++++++++++++++++++-------
1 file changed, 29 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 31598ca2d396..bade24e29a1a 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -83,6 +83,7 @@ TEST_GEN_PROGS_EXTENDED = test_sock_addr test_skb_cgroup_id_user \
test_lirc_mode2_user xdping test_cpp runqslower bench
TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read
+EXTRA_CLEAN += $(TEST_CUSTOM_PROGS)
# Emit succinct information message describing current building step
# $1 - generic step name (e.g., CC, LINK, etc);
@@ -267,7 +268,7 @@ TRUNNER_TEST_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.test.o, \
TRUNNER_EXTRA_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.o, \
$$(filter %.c,$(TRUNNER_EXTRA_SOURCES)))
TRUNNER_EXTRA_HDRS := $$(filter %.h,$(TRUNNER_EXTRA_SOURCES))
-TRUNNER_TESTS_HDR := $(TRUNNER_TESTS_DIR)/tests.h
+TRUNNER_TESTS_HDR := $(OUTPUT)/$(TRUNNER_TESTS_DIR)/tests.h
TRUNNER_BPF_SRCS := $$(notdir $$(wildcard $(TRUNNER_BPF_PROGS_DIR)/*.c))
TRUNNER_BPF_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.o, $$(TRUNNER_BPF_SRCS))
TRUNNER_BPF_SKELS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.skel.h, \
@@ -295,6 +296,11 @@ $(TRUNNER_OUTPUT)-dir := y
$(TRUNNER_OUTPUT):
$$(call msg,MKDIR,,$$@)
mkdir -p $$@
+
+ifneq ($2,)
+EXTRA_CLEAN +=$(TRUNNER_OUTPUT)
+endif
+
endif
# ensure we set up BPF objects generation rule just once for a given
@@ -320,13 +326,19 @@ endif
# ensure we set up tests.h header generation rule just once
ifeq ($($(TRUNNER_TESTS_DIR)-tests-hdr),)
$(TRUNNER_TESTS_DIR)-tests-hdr := y
-$(TRUNNER_TESTS_HDR): $(TRUNNER_TESTS_DIR)/*.c
+$(TRUNNER_TESTS_HDR): $(TRUNNER_TESTS_DIR)/*.c | $(dir $(TRUNNER_TESTS_HDR))
$$(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)@'; \
) > $$@)
+
+EXTRA_CLEAN += $(TRUNNER_TESTS_HDR)
+
+$(dir $(TRUNNER_TESTS_HDR)):
+ $$(call msg,MKDIR,,$$@)
+ mkdir -p $$@
endif
# compile individual test files
@@ -402,14 +414,23 @@ $(eval $(call DEFINE_TEST_RUNNER,test_maps))
# It is much simpler than test_maps/test_progs and sufficiently different from
# them (e.g., test.h is using completely pattern), that it's worth just
# explicitly defining all the rules explicitly.
-verifier/tests.h: verifier/*.c
+$(OUTPUT)/verifier/tests.h: verifier/*.c | $(OUTPUT)/verifier
$(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' \
- ) > verifier/tests.h)
-$(OUTPUT)/test_verifier: test_verifier.c verifier/tests.h $(BPFOBJ) | $(OUTPUT)
+ ) > $@)
+
+EXTRA_CLEAN += $(OUTPUT)/verifier/tests.h
+
+$(OUTPUT)/verifier:
+ $(call msg,MKDIR,,$@)
+ mkdir -p $@
+
+$(OUTPUT)/test_verifier: CFLAGS += -I$(abspath verifier)
+$(OUTPUT)/test_verifier: test_verifier.c $(OUTPUT)/verifier/tests.h $(BPFOBJ) \
+ | $(OUTPUT)
$(call msg,BINARY,,$@)
$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@
@@ -433,7 +454,6 @@ $(OUTPUT)/bench: $(OUTPUT)/bench.o $(OUTPUT)/testing_helpers.o \
$(call msg,BINARY,,$@)
$(CC) $(LDFLAGS) -o $@ $(filter %.a %.o,$^) $(LDLIBS)
-EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(SCRATCH_DIR) \
- prog_tests/tests.h map_tests/tests.h verifier/tests.h \
- feature \
- $(addprefix $(OUTPUT)/,*.o *.skel.h no_alu32 bpf_gcc)
+EXTRA_CLEAN += $(SCRATCH_DIR) \
+ feature \
+ $(addprefix $(OUTPUT)/,*.o *.skel.h)
--
2.26.2
next prev parent reply other threads:[~2020-05-22 4:13 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-22 4:13 [PATCH 0/8] selftests/bpf: installation and out of tree build fixes Yauheni Kaliuta
2020-05-22 4:13 ` [PATCH 1/8] selftests/bpf: remove test_align from Makefile Yauheni Kaliuta
2020-05-26 22:13 ` Andrii Nakryiko
2020-05-22 4:13 ` [PATCH 2/8] selftests/bpf: build bench.o for any $(OUTPUT) Yauheni Kaliuta
2020-05-26 22:13 ` Andrii Nakryiko
2020-05-27 4:54 ` Yauheni Kaliuta
2020-05-22 4:13 ` [PATCH 3/8] selftests/bpf: install btf .c files Yauheni Kaliuta
2020-05-22 4:13 ` [PATCH 4/8] selftests/bpf: fix object files installation Yauheni Kaliuta
2020-05-26 22:30 ` Andrii Nakryiko
2020-05-27 5:17 ` Yauheni Kaliuta
2020-05-28 18:39 ` Andrii Nakryiko
2020-05-28 18:46 ` Yauheni Kaliuta
2020-05-22 4:13 ` [PATCH 5/8] selftests/bpf: add output dir to include list Yauheni Kaliuta
2020-05-26 22:13 ` Andrii Nakryiko
2020-05-22 4:13 ` [PATCH 6/8] selftests/bpf: fix urandom_read installation Yauheni Kaliuta
2020-05-26 22:13 ` Andrii Nakryiko
2020-05-22 4:13 ` Yauheni Kaliuta [this message]
2020-05-26 22:26 ` [PATCH 7/8] selftests/bpf: fix test.h placing for out of tree build Andrii Nakryiko
2020-05-27 5:06 ` Yauheni Kaliuta
2020-05-22 4:13 ` [PATCH 8/8] selftests/bpf: factor out MKDIR rule Yauheni Kaliuta
2020-05-26 22:29 ` Andrii Nakryiko
2020-05-27 5:07 ` Yauheni Kaliuta
2020-05-22 6:40 ` [PATCH 0/8] selftests/bpf: installation and out of tree build fixes Yauheni Kaliuta
2020-05-22 8:19 ` [PATCH] selftests/bpf: split -extras target to -static and -gen Yauheni Kaliuta
2020-05-27 0:19 ` Andrii Nakryiko
2020-05-27 5:21 ` Yauheni Kaliuta
2020-05-27 5:37 ` Alexei Starovoitov
2020-05-27 7:19 ` Yauheni Kaliuta
2020-05-27 16:48 ` Alexei Starovoitov
2020-05-27 17:02 ` Yauheni Kaliuta
2020-05-27 17:05 ` Alexei Starovoitov
2020-05-27 22:01 ` shuah
2020-05-27 22:23 ` Alexei Starovoitov
2020-05-28 8:05 ` Jiri Benc
2020-05-28 10:56 ` Greg KH
2020-05-28 16:14 ` Alexei Starovoitov
2020-05-28 17:07 ` Shuah Khan
2020-05-28 18:15 ` Alexei Starovoitov
2020-05-28 18:29 ` Yauheni Kaliuta
2020-05-28 18:34 ` Alexei Starovoitov
2020-05-28 19:05 ` Shuah Khan
2020-05-28 18:59 ` Shuah Khan
2020-05-28 19:18 ` Alexei Starovoitov
2020-05-28 20:09 ` Shuah Khan
2020-05-28 22:47 ` Shuah Khan
2020-05-28 17:10 ` Yauheni Kaliuta
2020-05-28 18:17 ` Alexei Starovoitov
2020-05-28 19:09 ` Shuah Khan
2020-05-28 19:20 ` Yauheni Kaliuta
2020-05-28 19:34 ` Shuah Khan
2020-05-26 21:48 ` [PATCH 0/8] selftests/bpf: installation and out of tree build fixes Daniel Borkmann
2020-05-27 4:45 ` Yauheni Kaliuta
2020-05-26 22:32 ` Andrii Nakryiko
2020-05-27 4:52 ` Yauheni Kaliuta
2020-05-27 5:04 ` Andrii Nakryiko
2020-05-27 7:25 ` Yauheni Kaliuta
2020-05-27 8:05 ` Yauheni Kaliuta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200522041310.233185-8-yauheni.kaliuta@redhat.com \
--to=yauheni.kaliuta@redhat.com \
--cc=andriin@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jbenc@redhat.com \
--cc=jolsa@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).