Skip to contentSkip to conversation

selftests/bpf: Include build flavors for install target

PATCH Superseded Björn Töpel 2 participants 3 messages Aug 28, 2023 – Aug 31, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: Include build flavors for install target

From: Björn Töpel <[email protected]>

When using the "install" or targets depending on install, e.g. "gen_tar", the BPF machine flavors weren't included.

A command like:

  | make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- O=/workspace/kbuild \
  |    HOSTCC=gcc FORMAT= SKIP_TARGETS="arm64 ia64 powerpc sparc64 x86 sgx" \
  |    -C tools/testing/selftests gen_tar

would not include bpf/no_alu32, bpf/cpuv4, or bpf/bpf-gcc.

Include the BPF machine flavors for "install" make target.

---
 tools/testing/selftests/bpf/Makefile | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tools/testing/selftests/bpf/Makefile +12 -0
index edef49fcd23e..7c77a21c3371 100644
@@ -598,12 +598,14 @@ $(eval $(call DEFINE_TEST_RUNNER,test_progs))
 TRUNNER_BPF_BUILD_RULE := CLANG_NOALU32_BPF_BUILD_RULE
 TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS)
 $(eval $(call DEFINE_TEST_RUNNER,test_progs,no_alu32))
+INSTDIRS := no_alu32
 
 # Define test_progs-cpuv4 test runner.
 ifneq ($(CLANG_CPUV4),)
 TRUNNER_BPF_BUILD_RULE := CLANG_CPUV4_BPF_BUILD_RULE
 TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS)
 $(eval $(call DEFINE_TEST_RUNNER,test_progs,cpuv4))
+INSTDIRS += cpuv4
 endif
 
 # Define test_progs BPF-GCC-flavored test runner.
@@ -611,6 +613,7 @@ ifneq ($(BPF_GCC),)
 TRUNNER_BPF_BUILD_RULE := GCC_BPF_BUILD_RULE
 TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(call get_sys_includes,gcc,)
 $(eval $(call DEFINE_TEST_RUNNER,test_progs,bpf_gcc))
+INSTDIRS += bpf_gcc
 endif
 
 # Define test_maps test runner.
@@ -714,3 +717,12 @@ EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(SCRATCH_DIR) $(HOST_SCRATCH_DIR)	\
 
 # Delete partially updated (corrupted) files on error
 .DELETE_ON_ERROR:
+
+DEFAULT_INSTALL_RULE := $(INSTALL_RULE)
+override define INSTALL_RULE
+	$(DEFAULT_INSTALL_RULE)
+	@for DIR in $(INSTDIRS); do		  \
+		mkdir -p $(INSTALL_PATH)/$$DIR;   \
+		rsync -a $(OUTPUT)/$$DIR/*.bpf.o $(INSTALL_PATH)/$$DIR;\
+	done
+endef

base-commit: 8be6f88b9d3fe1f6724daec4a70d6023742c9df7

Signature · 1 line
2.39.2
maintainer
#1 lore raw
Quoted 6 lines · Björn Töpel

From: Björn Töpel <[email protected]>

When using the "install" or targets depending on install, e.g. "gen_tar", the BPF machine flavors weren't included.

A command like:

Quoted 8 lines
   | make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- O=/workspace/kbuild \
   |    HOSTCC=gcc FORMAT= SKIP_TARGETS="arm64 ia64 powerpc sparc64 x86 sgx" \
   |    -C tools/testing/selftests gen_tar

would not include bpf/no_alu32, bpf/cpuv4, or bpf/bpf-gcc.

Include the BPF machine flavors for "install" make target.

Looks good and BPF CI also seems to be fine with it, wrt INSTDIRS could we use a more appropriate location where we define it? Was thinking sth like:

tools/testing/selftests/bpf/Makefile +3 -0
index 7c77a21c3371..8b724efb8b7f 100644
@@ -50,14 +50,17 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test
        test_cgroup_storage \
        test_tcpnotify_user test_sysctl \
        test_progs-no_alu32
+TEST_INST_SUBDIRS := no_alu32
 
 # Also test bpf-gcc, if present
 ifneq ($(BPF_GCC),)
 TEST_GEN_PROGS += test_progs-bpf_gcc
+TEST_INST_SUBDIRS += bpf_gcc
 endif
 
 ifneq ($(CLANG_CPUV4),)
 TEST_GEN_PROGS += test_progs-cpuv4
+TEST_INST_SUBDIRS += cpuv4
 endif
 

[...]

Thanks,
Daniel

#2 lore raw
Quoted 31 lines · Daniel Borkmann
Quoted 6 lines · Björn Töpel

From: Björn Töpel <[email protected]>

When using the "install" or targets depending on install, e.g. "gen_tar", the BPF machine flavors weren't included.

A command like:

Quoted 8 lines
   | make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- O=/workspace/kbuild \
   |    HOSTCC=gcc FORMAT= SKIP_TARGETS="arm64 ia64 powerpc sparc64 x86 sgx" \
   |    -C tools/testing/selftests gen_tar

would not include bpf/no_alu32, bpf/cpuv4, or bpf/bpf-gcc.

Include the BPF machine flavors for "install" make target.

Looks good and BPF CI also seems to be fine with it, wrt INSTDIRS could we use a more appropriate location where we define it? Was thinking sth like:

tools/testing/selftests/bpf/Makefile +1 -0
index 7c77a21c3371..8b724efb8b7f 100644
@@ -50,14 +50,17 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test
         test_cgroup_storage \
         test_tcpnotify_user test_sysctl \
         test_progs-no_alu32
+TEST_INST_SUBDIRS := no_alu32
 
  # Also test bpf-gcc, if present
  ifneq ($(BPF_GCC),)

tools/testing/selftests/bpf/Makefile TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test · line 65

Quoted 10 lines
tools/testing/selftests/bpf/Makefile +2 -0
  TEST_GEN_PROGS += test_progs-bpf_gcc
+TEST_INST_SUBDIRS += bpf_gcc
  endif
 
  ifneq ($(CLANG_CPUV4),)
  TEST_GEN_PROGS += test_progs-cpuv4
+TEST_INST_SUBDIRS += cpuv4
  endif
 
[...]

Ok! I'll spin a v2!