Skip to contentSkip to conversation

selftests/bpf: Fix cd_flavor_subdir() of test_progs

PATCH Applied Yuntao Wang 3 participants 3 messages Apr 3, 2022 – Apr 4, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

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
index 2ecb73a65206..0a4b45d7b515 100644
@@ -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
#1 lore raw
Quoted 3 lines · 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

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_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 -3
index 2ecb73a65206..0a4b45d7b515 100644
@@ -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

#2 lore raw
In reply to Yuntao Wang
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_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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html