bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: Fix cd_flavor_subdir() of test_progs
@ 2022-04-03 13:52 Yuntao Wang
  2022-04-04  0:02 ` Andrii Nakryiko
  2022-04-04  0:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Yuntao Wang @ 2022-04-03 13:52 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Shuah Khan, netdev, bpf, linux-kernel, linux-kselftest,
	Yuntao Wang

Currently, when we run test_progs with just executable file name, for
example 'PATH=. test_progs-no_alu32', cd_flavor_subdir() will not check
if test_progs is running as a flavored test runner and switch into
corresponding sub-directory.

This will cause test_progs-no_alu32 executed by the
'PATH=. test_progs-no_alu32' command to run in the wrong directory and
load the wrong BPF objects.

Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
---
 tools/testing/selftests/bpf/test_progs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index 2ecb73a65206..0a4b45d7b515 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -761,8 +761,10 @@ int cd_flavor_subdir(const char *exec_name)
 	const char *flavor = strrchr(exec_name, '/');
 
 	if (!flavor)
-		return 0;
-	flavor++;
+		flavor = exec_name;
+	else
+		flavor++;
+
 	flavor = strrchr(flavor, '-');
 	if (!flavor)
 		return 0;
-- 
2.35.1


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

* Re: [PATCH bpf-next] selftests/bpf: Fix cd_flavor_subdir() of test_progs
  2022-04-03 13:52 [PATCH bpf-next] selftests/bpf: Fix cd_flavor_subdir() of test_progs Yuntao Wang
@ 2022-04-04  0:02 ` Andrii Nakryiko
  2022-04-04  0:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2022-04-04  0:02 UTC (permalink / raw)
  To: Yuntao Wang
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Shuah Khan, Networking, bpf, open list,
	open list:KERNEL SELFTEST FRAMEWORK

On Sun, Apr 3, 2022 at 6:53 AM Yuntao Wang <ytcoode@gmail.com> wrote:
>
> Currently, when we run test_progs with just executable file name, for
> example 'PATH=. test_progs-no_alu32', cd_flavor_subdir() will not check

First time seeing this PATH=. trick just to avoid
./test_progs-no_alu32, but sure, the fix makes sense. Applied to
bpf-next.

> if test_progs is running as a flavored test runner and switch into
> corresponding sub-directory.
>
> This will cause test_progs-no_alu32 executed by the
> 'PATH=. test_progs-no_alu32' command to run in the wrong directory and
> load the wrong BPF objects.
>
> Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
> ---
>  tools/testing/selftests/bpf/test_progs.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> index 2ecb73a65206..0a4b45d7b515 100644
> --- a/tools/testing/selftests/bpf/test_progs.c
> +++ b/tools/testing/selftests/bpf/test_progs.c
> @@ -761,8 +761,10 @@ int cd_flavor_subdir(const char *exec_name)
>         const char *flavor = strrchr(exec_name, '/');
>
>         if (!flavor)
> -               return 0;
> -       flavor++;
> +               flavor = exec_name;
> +       else
> +               flavor++;
> +
>         flavor = strrchr(flavor, '-');
>         if (!flavor)
>                 return 0;
> --
> 2.35.1
>

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

* Re: [PATCH bpf-next] selftests/bpf: Fix cd_flavor_subdir() of test_progs
  2022-04-03 13:52 [PATCH bpf-next] selftests/bpf: Fix cd_flavor_subdir() of test_progs Yuntao Wang
  2022-04-04  0:02 ` Andrii Nakryiko
@ 2022-04-04  0:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-04  0:10 UTC (permalink / raw)
  To: Yuntao Wang
  Cc: ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
	kpsingh, shuah, netdev, bpf, linux-kernel, linux-kselftest

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Sun,  3 Apr 2022 21:52:45 +0800 you wrote:
> Currently, when we run test_progs with just executable file name, for
> example 'PATH=. test_progs-no_alu32', cd_flavor_subdir() will not check
> if test_progs is running as a flavored test runner and switch into
> corresponding sub-directory.
> 
> This will cause test_progs-no_alu32 executed by the
> 'PATH=. test_progs-no_alu32' command to run in the wrong directory and
> load the wrong BPF objects.
> 
> [...]

Here is the summary with links:
  - [bpf-next] selftests/bpf: Fix cd_flavor_subdir() of test_progs
    https://git.kernel.org/bpf/bpf-next/c/9bbad6dab827

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-04-04  0:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-03 13:52 [PATCH bpf-next] selftests/bpf: Fix cd_flavor_subdir() of test_progs Yuntao Wang
2022-04-04  0:02 ` Andrii Nakryiko
2022-04-04  0:10 ` patchwork-bot+netdevbpf

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).