diff mbox series

[bpf-next] selftests/bpf: Copy extra resources in the non-flavored build too

Message ID 20210222232451.84574-1-iii@linux.ibm.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next] selftests/bpf: Copy extra resources in the non-flavored build too | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 8 maintainers not CCed: linux-kselftest@vger.kernel.org yhs@fb.com netdev@vger.kernel.org john.fastabend@gmail.com kpsingh@kernel.org songliubraving@fb.com shuah@kernel.org kafai@fb.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Ilya Leoshkevich Feb. 22, 2021, 11:24 p.m. UTC
Building selftests in a separate directory like this:

    make O=... -C tools/testing/selftests/bpf

and then running:

    ./test_progs -t btf

causes all the non-flavored btf_dump_test_case_*.c tests to fail,
because these files are not copied to where test_progs expects to find
them.

Fix by removing the flavored build check and using rsync instead of cp:
cp fails because e.g. urandom_read is being copied into itself, and
rsync simply skips such cases. rsync is used by kselftests elsewhere
and therefore is not a new dependency.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 tools/testing/selftests/bpf/Makefile | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Andrii Nakryiko Feb. 24, 2021, 7:18 a.m. UTC | #1
On Mon, Feb 22, 2021 at 3:25 PM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>
> Building selftests in a separate directory like this:
>
>     make O=... -C tools/testing/selftests/bpf
>
> and then running:
>
>     ./test_progs -t btf
>
> causes all the non-flavored btf_dump_test_case_*.c tests to fail,
> because these files are not copied to where test_progs expects to find
> them.
>
> Fix by removing the flavored build check and using rsync instead of cp:
> cp fails because e.g. urandom_read is being copied into itself, and
> rsync simply skips such cases. rsync is used by kselftests elsewhere
> and therefore is not a new dependency.

So this leaves a bunch of non-ignored files in selftests/bpf directory:

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        btf_dump_test_case_bitfields.c
        btf_dump_test_case_multidim.c
        btf_dump_test_case_namespacing.c
        btf_dump_test_case_ordering.c
        btf_dump_test_case_packing.c
        btf_dump_test_case_padding.c
        btf_dump_test_case_syntax.c

We can add them to .gitignore, but that feels wrong, to be honest. Any
ideas how to fix this in some better way?

>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>  tools/testing/selftests/bpf/Makefile | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 044bfdcf5b74..192119f6aeb7 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -382,12 +382,9 @@ $(TRUNNER_EXTRA_OBJS): $(TRUNNER_OUTPUT)/%.o:                              \
>         $$(call msg,EXT-OBJ,$(TRUNNER_BINARY),$$@)
>         $(Q)$$(CC) $$(CFLAGS) -c $$< $$(LDLIBS) -o $$@
>
> -# only copy extra resources if in flavored build
>  $(TRUNNER_BINARY)-extras: $(TRUNNER_EXTRA_FILES) | $(TRUNNER_OUTPUT)
> -ifneq ($2,)
>         $$(call msg,EXT-COPY,$(TRUNNER_BINARY),$(TRUNNER_EXTRA_FILES))
> -       $(Q)cp -a $$^ $(TRUNNER_OUTPUT)/
> -endif
> +       $(Q)rsync -aq $$^ $(TRUNNER_OUTPUT)/
>
>  $(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS)                      \
>                              $(TRUNNER_EXTRA_OBJS) $$(BPFOBJ)           \
> --
> 2.29.2
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 044bfdcf5b74..192119f6aeb7 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -382,12 +382,9 @@  $(TRUNNER_EXTRA_OBJS): $(TRUNNER_OUTPUT)/%.o:				\
 	$$(call msg,EXT-OBJ,$(TRUNNER_BINARY),$$@)
 	$(Q)$$(CC) $$(CFLAGS) -c $$< $$(LDLIBS) -o $$@
 
-# only copy extra resources if in flavored build
 $(TRUNNER_BINARY)-extras: $(TRUNNER_EXTRA_FILES) | $(TRUNNER_OUTPUT)
-ifneq ($2,)
 	$$(call msg,EXT-COPY,$(TRUNNER_BINARY),$(TRUNNER_EXTRA_FILES))
-	$(Q)cp -a $$^ $(TRUNNER_OUTPUT)/
-endif
+	$(Q)rsync -aq $$^ $(TRUNNER_OUTPUT)/
 
 $(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS)			\
 			     $(TRUNNER_EXTRA_OBJS) $$(BPFOBJ)		\