selftests/bpf: Fix cd_flavor_subdir() of test_progs
Subsystems (5)
PATCH 1/1 selftests/bpf: Fix cd_flavor_subdir() of test_progs
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.
--- tools/testing/selftests/bpf/test_progs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/test_progs.c +4 -2
@@ -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 ;
Signature · 1 line
2.35.1
Quoted 3 lines · Yuntao Wang
Currently, when we run
test_progswith 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.
Quoted 32 lines
if
test_progsis 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 <[email protected]>--- tools/testing/selftests/bpf/test_progs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)tools/testing/selftests/bpf/test_progs.c +4
-3@@ -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
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Quoted 10 lines · On Sun, 3 Apr 2022 21:52:45 +0800 you wrote:
Currently, when we run
test_progswith just executable file name, for example 'PATH=. test_progs-no_alu32',cd_flavor_subdir()will not check iftest_progsis 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html