diff options
author | Yuntao Wang <ytcoode@gmail.com> | 2022-04-03 21:52:45 +0800 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2022-04-03 17:01:48 -0700 |
commit | 9bbad6dab8279905c4593be69b06704b77b31403 (patch) | |
tree | d77e4cb1aa0c25a5bb68c1c31f62ca498d98b3dc | |
parent | f6d60facd9b65614594f1feaa4eee18ac60a9a18 (diff) | |
download | lwn-9bbad6dab8279905c4593be69b06704b77b31403.tar.gz lwn-9bbad6dab8279905c4593be69b06704b77b31403.zip |
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.
Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220403135245.1713283-1-ytcoode@gmail.com
-rw-r--r-- | tools/testing/selftests/bpf/test_progs.c | 6 |
1 files 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; |