All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] selftests/bpf: fix ima_setup.sh missing issue
@ 2022-05-12  7:18 Hangbin Liu
  2022-05-12  7:18 ` [PATCH net 1/2] selftests/bpf: Fix build error with ima_setup.sh Hangbin Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Hangbin Liu @ 2022-05-12  7:18 UTC (permalink / raw)
  To: netdev
  Cc: Shuah Khan, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Ilya Leoshkevich, linux-kselftest, bpf, Hangbin Liu

The ima_setup.sh is needed by test_progs test_ima. But the file is
missed if we build test_progs separately or installed bpf test to
another folder. This patch set fixed the issue in 2 different
scenarios.

Hangbin Liu (2):
  selftests/bpf: Fix build error with ima_setup.sh
  selftests/bpf: add missed ima_setup.sh in Makefile

 tools/testing/selftests/bpf/Makefile | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH net 1/2] selftests/bpf: Fix build error with ima_setup.sh
  2022-05-12  7:18 [PATCH net 0/2] selftests/bpf: fix ima_setup.sh missing issue Hangbin Liu
@ 2022-05-12  7:18 ` Hangbin Liu
  2022-05-13 21:58   ` Andrii Nakryiko
  2022-05-12  7:18 ` [PATCH net 2/2] selftests/bpf: add missed ima_setup.sh in Makefile Hangbin Liu
  2022-05-12 14:02 ` [PATCH net 0/2] selftests/bpf: fix ima_setup.sh missing issue Alexei Starovoitov
  2 siblings, 1 reply; 9+ messages in thread
From: Hangbin Liu @ 2022-05-12  7:18 UTC (permalink / raw)
  To: netdev
  Cc: Shuah Khan, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Ilya Leoshkevich, linux-kselftest, bpf, Hangbin Liu

KP fixed ima_setup.sh missing issue when build test_progs separately with
commit 854055c0cf30 ("selftests/bpf: Fix flavored variants of
test_ima"). But the fix is incorrect because the build will failed with
error:

  $ OUTPUT="/tmp/bpf" make test_progs
    [...]
  make: *** No rule to make target '/tmp/bpf/ima_setup.sh', needed by 'ima_setup.sh'.  Stop.

Fix it by adding a new variable TRUNNER_EXTRA_BUILD to build extra binaries.
Left TRUNNER_EXTRA_FILES only for copying files

Fixes: 854055c0cf30 ("selftests/bpf: Fix flavored variants of test_ima")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 tools/testing/selftests/bpf/Makefile | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 3820608faf57..5944d3a8fff6 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -466,10 +466,10 @@ $(TRUNNER_EXTRA_OBJS): $(TRUNNER_OUTPUT)/%.o:				\
 
 # non-flavored in-srctree builds receive special treatment, in particular, we
 # do not need to copy extra resources (see e.g. test_btf_dump_case())
-$(TRUNNER_BINARY)-extras: $(TRUNNER_EXTRA_FILES) | $(TRUNNER_OUTPUT)
+$(TRUNNER_BINARY)-extras: $(TRUNNER_EXTRA_BUILD) | $(TRUNNER_OUTPUT)
 ifneq ($2:$(OUTPUT),:$(shell pwd))
 	$$(call msg,EXT-COPY,$(TRUNNER_BINARY),$(TRUNNER_EXTRA_FILES))
-	$(Q)rsync -aq $$^ $(TRUNNER_OUTPUT)/
+	$(Q)rsync -aq $(TRUNNER_EXTRA_FILES) $(TRUNNER_OUTPUT)/
 endif
 
 $(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS)			\
@@ -490,9 +490,9 @@ TRUNNER_EXTRA_SOURCES := test_progs.c cgroup_helpers.c trace_helpers.c	\
 			 network_helpers.c testing_helpers.c		\
 			 btf_helpers.c flow_dissector_load.h		\
 			 cap_helpers.c
-TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko	\
-		       ima_setup.sh					\
+TRUNNER_EXTRA_BUILD := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko	\
 		       $(wildcard progs/btf_dump_test_case_*.c)
+TRUNNER_EXTRA_FILES := $(TRUNNER_EXTRA_BUILD) ima_setup.sh
 TRUNNER_BPF_BUILD_RULE := CLANG_BPF_BUILD_RULE
 TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS) -DENABLE_ATOMICS_TESTS
 $(eval $(call DEFINE_TEST_RUNNER,test_progs))
@@ -513,6 +513,7 @@ endif
 TRUNNER_TESTS_DIR := map_tests
 TRUNNER_BPF_PROGS_DIR := progs
 TRUNNER_EXTRA_SOURCES := test_maps.c
+TRUNNER_EXTRA_BUILD :=
 TRUNNER_EXTRA_FILES :=
 TRUNNER_BPF_BUILD_RULE := $$(error no BPF objects should be built)
 TRUNNER_BPF_CFLAGS :=
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net 2/2] selftests/bpf: add missed ima_setup.sh in Makefile
  2022-05-12  7:18 [PATCH net 0/2] selftests/bpf: fix ima_setup.sh missing issue Hangbin Liu
  2022-05-12  7:18 ` [PATCH net 1/2] selftests/bpf: Fix build error with ima_setup.sh Hangbin Liu
@ 2022-05-12  7:18 ` Hangbin Liu
  2022-05-12 14:02 ` [PATCH net 0/2] selftests/bpf: fix ima_setup.sh missing issue Alexei Starovoitov
  2 siblings, 0 replies; 9+ messages in thread
From: Hangbin Liu @ 2022-05-12  7:18 UTC (permalink / raw)
  To: netdev
  Cc: Shuah Khan, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Ilya Leoshkevich, linux-kselftest, bpf, Hangbin Liu

When build bpf test and install it to another folder, e.g.

  make -j10 install -C tools/testing/selftests/ TARGETS="bpf" \
	SKIP_TARGETS="" INSTALL_PATH=/tmp/kselftests

The ima_setup.sh is missed in target folder, which makes test_ima failed.

Fix it by adding ima_setup.sh to TEST_PROGS_EXTENDED.

Fixes: 34b82d3ac105 ("bpf: Add a selftest for bpf_ima_inode_hash")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 tools/testing/selftests/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 5944d3a8fff6..b4fd1352a2ac 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -75,7 +75,7 @@ TEST_PROGS := test_kmod.sh \
 	test_xsk.sh
 
 TEST_PROGS_EXTENDED := with_addr.sh \
-	with_tunnels.sh \
+	with_tunnels.sh ima_setup.sh \
 	test_xdp_vlan.sh test_bpftool.py
 
 # Compile but not part of 'make run_tests'
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net 0/2] selftests/bpf: fix ima_setup.sh missing issue
  2022-05-12  7:18 [PATCH net 0/2] selftests/bpf: fix ima_setup.sh missing issue Hangbin Liu
  2022-05-12  7:18 ` [PATCH net 1/2] selftests/bpf: Fix build error with ima_setup.sh Hangbin Liu
  2022-05-12  7:18 ` [PATCH net 2/2] selftests/bpf: add missed ima_setup.sh in Makefile Hangbin Liu
@ 2022-05-12 14:02 ` Alexei Starovoitov
  2 siblings, 0 replies; 9+ messages in thread
From: Alexei Starovoitov @ 2022-05-12 14:02 UTC (permalink / raw)
  To: Hangbin Liu
  Cc: Network Development, Shuah Khan, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Ilya Leoshkevich,
	open list:KERNEL SELFTEST FRAMEWORK, bpf

On Thu, May 12, 2022 at 12:18 AM Hangbin Liu <liuhangbin@gmail.com> wrote:
>
> The ima_setup.sh is needed by test_progs test_ima. But the file is
> missed if we build test_progs separately or installed bpf test to
> another folder. This patch set fixed the issue in 2 different
> scenarios.

Patch subject is incorrect.
Please use [PATCH bpf-next].

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net 1/2] selftests/bpf: Fix build error with ima_setup.sh
  2022-05-12  7:18 ` [PATCH net 1/2] selftests/bpf: Fix build error with ima_setup.sh Hangbin Liu
@ 2022-05-13 21:58   ` Andrii Nakryiko
  2022-05-16  3:53     ` Hangbin Liu
  0 siblings, 1 reply; 9+ messages in thread
From: Andrii Nakryiko @ 2022-05-13 21:58 UTC (permalink / raw)
  To: Hangbin Liu
  Cc: Networking, Shuah Khan, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Ilya Leoshkevich,
	open list:KERNEL SELFTEST FRAMEWORK, bpf

On Thu, May 12, 2022 at 12:18 AM Hangbin Liu <liuhangbin@gmail.com> wrote:
>
> KP fixed ima_setup.sh missing issue when build test_progs separately with
> commit 854055c0cf30 ("selftests/bpf: Fix flavored variants of
> test_ima"). But the fix is incorrect because the build will failed with
> error:
>
>   $ OUTPUT="/tmp/bpf" make test_progs
>     [...]
>   make: *** No rule to make target '/tmp/bpf/ima_setup.sh', needed by 'ima_setup.sh'.  Stop.
>
> Fix it by adding a new variable TRUNNER_EXTRA_BUILD to build extra binaries.
> Left TRUNNER_EXTRA_FILES only for copying files
>
> Fixes: 854055c0cf30 ("selftests/bpf: Fix flavored variants of test_ima")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
>  tools/testing/selftests/bpf/Makefile | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 3820608faf57..5944d3a8fff6 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -466,10 +466,10 @@ $(TRUNNER_EXTRA_OBJS): $(TRUNNER_OUTPUT)/%.o:                             \
>
>  # non-flavored in-srctree builds receive special treatment, in particular, we
>  # do not need to copy extra resources (see e.g. test_btf_dump_case())
> -$(TRUNNER_BINARY)-extras: $(TRUNNER_EXTRA_FILES) | $(TRUNNER_OUTPUT)
> +$(TRUNNER_BINARY)-extras: $(TRUNNER_EXTRA_BUILD) | $(TRUNNER_OUTPUT)
>  ifneq ($2:$(OUTPUT),:$(shell pwd))
>         $$(call msg,EXT-COPY,$(TRUNNER_BINARY),$(TRUNNER_EXTRA_FILES))
> -       $(Q)rsync -aq $$^ $(TRUNNER_OUTPUT)/
> +       $(Q)rsync -aq $(TRUNNER_EXTRA_FILES) $(TRUNNER_OUTPUT)/
>  endif
>
>  $(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS)                      \
> @@ -490,9 +490,9 @@ TRUNNER_EXTRA_SOURCES := test_progs.c cgroup_helpers.c trace_helpers.c      \
>                          network_helpers.c testing_helpers.c            \
>                          btf_helpers.c flow_dissector_load.h            \
>                          cap_helpers.c
> -TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \
> -                      ima_setup.sh                                     \
> +TRUNNER_EXTRA_BUILD := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \
>                        $(wildcard progs/btf_dump_test_case_*.c)


note that progs/btf_dump_test_case_*.c are not built, they are just
copied over (C source files), so I don't think this fix is necessary.

btw, I tried running `OUTPUT="/tmp/bpf" make test_progs` and it didn't
error out. But tbh, I'd recommend building everything instead of
building individual targets.


> +TRUNNER_EXTRA_FILES := $(TRUNNER_EXTRA_BUILD) ima_setup.sh
>  TRUNNER_BPF_BUILD_RULE := CLANG_BPF_BUILD_RULE
>  TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS) -DENABLE_ATOMICS_TESTS
>  $(eval $(call DEFINE_TEST_RUNNER,test_progs))
> @@ -513,6 +513,7 @@ endif
>  TRUNNER_TESTS_DIR := map_tests
>  TRUNNER_BPF_PROGS_DIR := progs
>  TRUNNER_EXTRA_SOURCES := test_maps.c
> +TRUNNER_EXTRA_BUILD :=
>  TRUNNER_EXTRA_FILES :=
>  TRUNNER_BPF_BUILD_RULE := $$(error no BPF objects should be built)
>  TRUNNER_BPF_CFLAGS :=
> --
> 2.35.1
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net 1/2] selftests/bpf: Fix build error with ima_setup.sh
  2022-05-13 21:58   ` Andrii Nakryiko
@ 2022-05-16  3:53     ` Hangbin Liu
  2022-05-18 22:36       ` Andrii Nakryiko
  0 siblings, 1 reply; 9+ messages in thread
From: Hangbin Liu @ 2022-05-16  3:53 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Networking, Shuah Khan, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Ilya Leoshkevich,
	open list:KERNEL SELFTEST FRAMEWORK, bpf

On Fri, May 13, 2022 at 02:58:05PM -0700, Andrii Nakryiko wrote:
> > -TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \
> > -                      ima_setup.sh                                     \
> > +TRUNNER_EXTRA_BUILD := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \
> >                        $(wildcard progs/btf_dump_test_case_*.c)
> 
> 
> note that progs/btf_dump_test_case_*.c are not built, they are just
> copied over (C source files), so I don't think this fix is necessary.
> 
> btw, I tried running `OUTPUT="/tmp/bpf" make test_progs` and it didn't
> error out. But tbh, I'd recommend building everything instead of
> building individual targets.

After update the code to latest bpf-next. It works this time, the ima_setup.sh
was copied to target folder correctly. 

  EXT-COPY [test_progs] urandom_read bpf_testmod.ko liburandom_read.so ima_setup.sh 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
  BINARY   test_progs

Not sure why the previous kernel doesn't work. But anyway I will drop this patch.

On the other hand, when I build with latest bpf-next. I got error like:

"""
# OUTPUT="/tmp/bpf" make test_progs
  BINARY   urandom_read                                                                                                                                                       gcc -g -O0 -rdynamic -Wall -Werror -DHAVE_GENHDR  -I/home/net/tools/testing/selftests/bpf -I/tmp/bpf/tools/include -I/home/net/include/generated -I/home/net/tools/lib -I/home/net/tools/include -I/home/net/tools/include/uapi -I/tmp/bpf  urandom_read.c urandom_read_aux.c  \
          liburandom_read.so -lelf -lz -lrt -lpthread   \
          -Wl,-rpath=. -Wl,--build-id=sha1 -o /tmp/bpf/urandom_read
/usr/bin/ld: cannot find liburandom_read.so: No such file or directory                                                                                                        collect2: error: ld returned 1 exit status
make: *** [Makefile:177: /tmp/bpf/urandom_read] Error 1

# ls /tmp/bpf/liburandom_read.so
/tmp/bpf/liburandom_read.so
"""

after I copy to liburandom_read.so back to tools/testing/selftests/bpf the build
success.

"""
# cp /tmp/bpf/liburandom_read.so /home/net/tools/testing/selftests/bpf/
# gcc -g -O0 -rdynamic -Wall -Werror -DHAVE_GENHDR -I/home/net/tools/testing/selftests/bpf -I/tmp/bpf/tools/include -I/home/net/include/generated -I/home/net/tools/lib -I/home/net/tools/include -I/home/net/tools/include/uapi -I/tmp/bpf  urandom_read.c urandom_read_aux.c liburandom_read.so -lelf -lz -lrt -lpthread -Wl,-rpath=. -Wl,--build-id=sha1 -o /tmp/bpf/urandom_read
# echo $?
0
"""

Do you know why this happens?

Thanks
Hangbin

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net 1/2] selftests/bpf: Fix build error with ima_setup.sh
  2022-05-16  3:53     ` Hangbin Liu
@ 2022-05-18 22:36       ` Andrii Nakryiko
  2022-05-19  2:44         ` Hangbin Liu
  0 siblings, 1 reply; 9+ messages in thread
From: Andrii Nakryiko @ 2022-05-18 22:36 UTC (permalink / raw)
  To: Hangbin Liu
  Cc: Networking, Shuah Khan, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Ilya Leoshkevich,
	open list:KERNEL SELFTEST FRAMEWORK, bpf

On Sun, May 15, 2022 at 8:53 PM Hangbin Liu <liuhangbin@gmail.com> wrote:
>
> On Fri, May 13, 2022 at 02:58:05PM -0700, Andrii Nakryiko wrote:
> > > -TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \
> > > -                      ima_setup.sh                                     \
> > > +TRUNNER_EXTRA_BUILD := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \
> > >                        $(wildcard progs/btf_dump_test_case_*.c)
> >
> >
> > note that progs/btf_dump_test_case_*.c are not built, they are just
> > copied over (C source files), so I don't think this fix is necessary.
> >
> > btw, I tried running `OUTPUT="/tmp/bpf" make test_progs` and it didn't
> > error out. But tbh, I'd recommend building everything instead of
> > building individual targets.
>
> After update the code to latest bpf-next. It works this time, the ima_setup.sh
> was copied to target folder correctly.
>
>   EXT-COPY [test_progs] urandom_read bpf_testmod.ko liburandom_read.so ima_setup.sh 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
>   BINARY   test_progs
>
> Not sure why the previous kernel doesn't work. But anyway I will drop this patch.
>
> On the other hand, when I build with latest bpf-next. I got error like:
>
> """
> # OUTPUT="/tmp/bpf" make test_progs
>   BINARY   urandom_read                                                                                                                                                       gcc -g -O0 -rdynamic -Wall -Werror -DHAVE_GENHDR  -I/home/net/tools/testing/selftests/bpf -I/tmp/bpf/tools/include -I/home/net/include/generated -I/home/net/tools/lib -I/home/net/tools/include -I/home/net/tools/include/uapi -I/tmp/bpf  urandom_read.c urandom_read_aux.c  \
>           liburandom_read.so -lelf -lz -lrt -lpthread   \
>           -Wl,-rpath=. -Wl,--build-id=sha1 -o /tmp/bpf/urandom_read

we assume liburandom_read.so is going to be under selftests/bpf here,
but it's actually under $(OUTPUT)/

Can you try $(OUTPUT)/liburandom_read.so? I suspect this might break
-rpath=., though, but let's try this first?


> /usr/bin/ld: cannot find liburandom_read.so: No such file or directory                                                                                                        collect2: error: ld returned 1 exit status
> make: *** [Makefile:177: /tmp/bpf/urandom_read] Error 1
>
> # ls /tmp/bpf/liburandom_read.so
> /tmp/bpf/liburandom_read.so
> """
>
> after I copy to liburandom_read.so back to tools/testing/selftests/bpf the build
> success.
>
> """
> # cp /tmp/bpf/liburandom_read.so /home/net/tools/testing/selftests/bpf/
> # gcc -g -O0 -rdynamic -Wall -Werror -DHAVE_GENHDR -I/home/net/tools/testing/selftests/bpf -I/tmp/bpf/tools/include -I/home/net/include/generated -I/home/net/tools/lib -I/home/net/tools/include -I/home/net/tools/include/uapi -I/tmp/bpf  urandom_read.c urandom_read_aux.c liburandom_read.so -lelf -lz -lrt -lpthread -Wl,-rpath=. -Wl,--build-id=sha1 -o /tmp/bpf/urandom_read
> # echo $?
> 0
> """
>
> Do you know why this happens?
>
> Thanks
> Hangbin

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net 1/2] selftests/bpf: Fix build error with ima_setup.sh
  2022-05-18 22:36       ` Andrii Nakryiko
@ 2022-05-19  2:44         ` Hangbin Liu
  2022-05-20 22:58           ` Andrii Nakryiko
  0 siblings, 1 reply; 9+ messages in thread
From: Hangbin Liu @ 2022-05-19  2:44 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Networking, Shuah Khan, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Ilya Leoshkevich,
	open list:KERNEL SELFTEST FRAMEWORK, bpf

On Wed, May 18, 2022 at 03:36:53PM -0700, Andrii Nakryiko wrote:
> > On Fri, May 13, 2022 at 02:58:05PM -0700, Andrii Nakryiko wrote:
> > > > -TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \
> > > > -                      ima_setup.sh                                     \
> > > > +TRUNNER_EXTRA_BUILD := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \
> > > >                        $(wildcard progs/btf_dump_test_case_*.c)
> > >
> > >
> > > note that progs/btf_dump_test_case_*.c are not built, they are just
> > > copied over (C source files), so I don't think this fix is necessary.
> > >
> > > btw, I tried running `OUTPUT="/tmp/bpf" make test_progs` and it didn't
> > > error out. But tbh, I'd recommend building everything instead of
> > > building individual targets.
> >
> > After update the code to latest bpf-next. It works this time, the ima_setup.sh
> > was copied to target folder correctly.
> >
> >   EXT-COPY [test_progs] urandom_read bpf_testmod.ko liburandom_read.so ima_setup.sh 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
> >   BINARY   test_progs
> >
> > Not sure why the previous kernel doesn't work. But anyway I will drop this patch.
> >
> > On the other hand, when I build with latest bpf-next. I got error like:
> >
> > """
> > # OUTPUT="/tmp/bpf" make test_progs
> >   BINARY   urandom_read                                                                                                                                                       gcc -g -O0 -rdynamic -Wall -Werror -DHAVE_GENHDR  -I/home/net/tools/testing/selftests/bpf -I/tmp/bpf/tools/include -I/home/net/include/generated -I/home/net/tools/lib -I/home/net/tools/include -I/home/net/tools/include/uapi -I/tmp/bpf  urandom_read.c urandom_read_aux.c  \
> >           liburandom_read.so -lelf -lz -lrt -lpthread   \
> >           -Wl,-rpath=. -Wl,--build-id=sha1 -o /tmp/bpf/urandom_read
> 
> we assume liburandom_read.so is going to be under selftests/bpf here,
> but it's actually under $(OUTPUT)/
> 
> Can you try $(OUTPUT)/liburandom_read.so? I suspect this might break
> -rpath=., though, but let's try this first?

Sigh.. After rebase to latest bpf-next, to make clean and re-do
`OUTPUT="/tmp/bpf" make test_progs`, There is no liburandom_read.so build
issue but the ima_setup.sh error come up again...

  LINK     resolve_btfids
  LIB      liburandom_read.so
  BINARY   urandom_read
  MOD      bpf_testmod.ko
  CC [M]  /home/net/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.o
  MODPOST /home/net/tools/testing/selftests/bpf/bpf_testmod/Module.symvers
  CC [M]  /home/net/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.mod.o
  LD [M]  /home/net/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.ko
  BTF [M] /home/net/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.ko
make: *** No rule to make target '/tmp/bpf/ima_setup.sh', needed by 'ima_setup.sh'.  Stop.

Not sure if it's a build environment setup issue or others.

Hangbin

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net 1/2] selftests/bpf: Fix build error with ima_setup.sh
  2022-05-19  2:44         ` Hangbin Liu
@ 2022-05-20 22:58           ` Andrii Nakryiko
  0 siblings, 0 replies; 9+ messages in thread
From: Andrii Nakryiko @ 2022-05-20 22:58 UTC (permalink / raw)
  To: Hangbin Liu
  Cc: Networking, Shuah Khan, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Ilya Leoshkevich,
	open list:KERNEL SELFTEST FRAMEWORK, bpf

On Wed, May 18, 2022 at 7:44 PM Hangbin Liu <liuhangbin@gmail.com> wrote:
>
> On Wed, May 18, 2022 at 03:36:53PM -0700, Andrii Nakryiko wrote:
> > > On Fri, May 13, 2022 at 02:58:05PM -0700, Andrii Nakryiko wrote:
> > > > > -TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \
> > > > > -                      ima_setup.sh                                     \
> > > > > +TRUNNER_EXTRA_BUILD := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \
> > > > >                        $(wildcard progs/btf_dump_test_case_*.c)
> > > >
> > > >
> > > > note that progs/btf_dump_test_case_*.c are not built, they are just
> > > > copied over (C source files), so I don't think this fix is necessary.
> > > >
> > > > btw, I tried running `OUTPUT="/tmp/bpf" make test_progs` and it didn't
> > > > error out. But tbh, I'd recommend building everything instead of
> > > > building individual targets.
> > >
> > > After update the code to latest bpf-next. It works this time, the ima_setup.sh
> > > was copied to target folder correctly.
> > >
> > >   EXT-COPY [test_progs] urandom_read bpf_testmod.ko liburandom_read.so ima_setup.sh 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
> > >   BINARY   test_progs
> > >
> > > Not sure why the previous kernel doesn't work. But anyway I will drop this patch.
> > >
> > > On the other hand, when I build with latest bpf-next. I got error like:
> > >
> > > """
> > > # OUTPUT="/tmp/bpf" make test_progs
> > >   BINARY   urandom_read                                                                                                                                                       gcc -g -O0 -rdynamic -Wall -Werror -DHAVE_GENHDR  -I/home/net/tools/testing/selftests/bpf -I/tmp/bpf/tools/include -I/home/net/include/generated -I/home/net/tools/lib -I/home/net/tools/include -I/home/net/tools/include/uapi -I/tmp/bpf  urandom_read.c urandom_read_aux.c  \
> > >           liburandom_read.so -lelf -lz -lrt -lpthread   \
> > >           -Wl,-rpath=. -Wl,--build-id=sha1 -o /tmp/bpf/urandom_read
> >
> > we assume liburandom_read.so is going to be under selftests/bpf here,
> > but it's actually under $(OUTPUT)/
> >
> > Can you try $(OUTPUT)/liburandom_read.so? I suspect this might break
> > -rpath=., though, but let's try this first?
>
> Sigh.. After rebase to latest bpf-next, to make clean and re-do
> `OUTPUT="/tmp/bpf" make test_progs`, There is no liburandom_read.so build
> issue but the ima_setup.sh error come up again...
>
>   LINK     resolve_btfids
>   LIB      liburandom_read.so
>   BINARY   urandom_read
>   MOD      bpf_testmod.ko
>   CC [M]  /home/net/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.o
>   MODPOST /home/net/tools/testing/selftests/bpf/bpf_testmod/Module.symvers
>   CC [M]  /home/net/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.mod.o
>   LD [M]  /home/net/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.ko
>   BTF [M] /home/net/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.ko
> make: *** No rule to make target '/tmp/bpf/ima_setup.sh', needed by 'ima_setup.sh'.  Stop.
>
> Not sure if it's a build environment setup issue or others.

I don't use OUTPUT when building selftests and see no issues, so this
must be related. If you care about OUTPUT working please try to debug
and figure this out.

>
> Hangbin

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-05-20 22:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12  7:18 [PATCH net 0/2] selftests/bpf: fix ima_setup.sh missing issue Hangbin Liu
2022-05-12  7:18 ` [PATCH net 1/2] selftests/bpf: Fix build error with ima_setup.sh Hangbin Liu
2022-05-13 21:58   ` Andrii Nakryiko
2022-05-16  3:53     ` Hangbin Liu
2022-05-18 22:36       ` Andrii Nakryiko
2022-05-19  2:44         ` Hangbin Liu
2022-05-20 22:58           ` Andrii Nakryiko
2022-05-12  7:18 ` [PATCH net 2/2] selftests/bpf: add missed ima_setup.sh in Makefile Hangbin Liu
2022-05-12 14:02 ` [PATCH net 0/2] selftests/bpf: fix ima_setup.sh missing issue Alexei Starovoitov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.