diff mbox series

[bpf-next,v4,03/10] selftests: Pass VMLINUX_BTF to runqslower Makefile

Message ID 157926820025.1555735.5663814379544078154.stgit@toke.dk (mailing list archive)
State New
Headers show
Series tools: Use consistent libbpf include paths everywhere | expand

Commit Message

Toke Høiland-Jørgensen Jan. 17, 2020, 1:36 p.m. UTC
From: Toke Høiland-Jørgensen <toke@redhat.com>

Add a VMLINUX_BTF variable with the locally-built path when calling the
runqslower Makefile from selftests. This makes sure a simple 'make'
invocation in the selftests dir works even when there is no BTF information
for the running kernel. Do a wildcard expansion and include the same paths
for BTF for the running kernel as in the runqslower Makefile, to make it
possible to build selftests without having a vmlinux in the local tree.

Also fix the make invocation to use $(OUTPUT)/tools as the destination
directory instead of $(CURDIR)/tools.

Fixes: 3a0d3092a4ed ("selftests/bpf: Build runqslower from selftests")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 tools/testing/selftests/bpf/Makefile |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Andrii Nakryiko Jan. 17, 2020, 9:36 p.m. UTC | #1
On Fri, Jan 17, 2020 at 5:37 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>
> From: Toke Høiland-Jørgensen <toke@redhat.com>
>
> Add a VMLINUX_BTF variable with the locally-built path when calling the
> runqslower Makefile from selftests. This makes sure a simple 'make'
> invocation in the selftests dir works even when there is no BTF information
> for the running kernel. Do a wildcard expansion and include the same paths
> for BTF for the running kernel as in the runqslower Makefile, to make it
> possible to build selftests without having a vmlinux in the local tree.
>
> Also fix the make invocation to use $(OUTPUT)/tools as the destination
> directory instead of $(CURDIR)/tools.
>
> Fixes: 3a0d3092a4ed ("selftests/bpf: Build runqslower from selftests")
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
> ---

With formatting fixes:

Acked-by: Andrii Nakryiko <andriin@fb.com>

>  tools/testing/selftests/bpf/Makefile |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 246d09ffb296..dcc8dbb1510b 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -124,10 +124,14 @@ $(OUTPUT)/test_stub.o: test_stub.c
>         $(call msg,CC,,$@)
>         $(CC) -c $(CFLAGS) -o $@ $<
>
> +VMLINUX_BTF_PATHS := $(abspath ../../../../vmlinux)                    \
> +                       /sys/kernel/btf/vmlinux                 \
> +                       /boot/vmlinux-$(shell uname -r)

it's not 100% consistent in this Makefile, unfortunately, but usually
(and similarly to function arguments) we align items for such
multi-line statements

> +VMLINUX_BTF:= $(firstword $(wildcard $(VMLINUX_BTF_PATHS)))
>  .PHONY: $(OUTPUT)/runqslower
>  $(OUTPUT)/runqslower: force
> -       $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower           \
> -                   OUTPUT=$(CURDIR)/tools/
> +       $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower     \
> +                   OUTPUT=$(OUTPUT)/tools/ VMLINUX_BTF=$(VMLINUX_BTF)
>

please, keep \ alignment, it's all over the place

>  BPFOBJ := $(OUTPUT)/libbpf.a
>
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 246d09ffb296..dcc8dbb1510b 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -124,10 +124,14 @@  $(OUTPUT)/test_stub.o: test_stub.c
 	$(call msg,CC,,$@)
 	$(CC) -c $(CFLAGS) -o $@ $<
 
+VMLINUX_BTF_PATHS := $(abspath ../../../../vmlinux)			\
+			/sys/kernel/btf/vmlinux			\
+			/boot/vmlinux-$(shell uname -r)
+VMLINUX_BTF:= $(firstword $(wildcard $(VMLINUX_BTF_PATHS)))
 .PHONY: $(OUTPUT)/runqslower
 $(OUTPUT)/runqslower: force
-	$(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower	      \
-		    OUTPUT=$(CURDIR)/tools/
+	$(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower	\
+		    OUTPUT=$(OUTPUT)/tools/ VMLINUX_BTF=$(VMLINUX_BTF)
 
 BPFOBJ := $(OUTPUT)/libbpf.a