selftests/bpf: Fix some bugs in map_lookup_percpu_elem testcase
authorFeng Zhou <zhoufeng.zf@bytedance.com>
Wed, 18 May 2022 02:50:53 +0000 (10:50 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 20 May 2022 22:07:41 +0000 (15:07 -0700)
commit7aa424e02a04bba5ecc84afe9b58b16e9e0b34f8
treeed4c41be3b16f960b58ec727a3a4cb69a07ca463
parent834650b50ed283d9d34a32b425d668256bf2e487
selftests/bpf: Fix some bugs in map_lookup_percpu_elem testcase

comments from Andrii Nakryiko, details in here:
https://lore.kernel.org/lkml/20220511093854.411-1-zhoufeng.zf@bytedance.com/T/

use /* */ instead of //
use libbpf_num_possible_cpus() instead of sysconf(_SC_NPROCESSORS_ONLN)
use 8 bytes for value size
fix memory leak
use ASSERT_EQ instead of ASSERT_OK
add bpf_loop to fetch values on each possible CPU

Fixes: ed7c13776e20c74486b0939a3c1de984c5efb6aa ("selftests/bpf: add test case for bpf_map_lookup_percpu_elem")
Signed-off-by: Feng Zhou <zhoufeng.zf@bytedance.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20220518025053.20492-1-zhoufeng.zf@bytedance.com
tools/testing/selftests/bpf/prog_tests/map_lookup_percpu_elem.c
tools/testing/selftests/bpf/progs/test_map_lookup_percpu_elem.c