diff options
author | 2021-05-24 20:59:32 -0700 | |
---|---|---|
committer | 2021-05-25 17:32:35 -0700 | |
commit | bad2e478af3b4df9fd84b4db7779ea91bd618c16 (patch) | |
tree | b2739a3cb481bc0f9ea4745ba21393e02924a32e /tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c | |
parent | libbpf: Add libbpf_set_strict_mode() API to turn on libbpf 1.0 behaviors (diff) | |
download | linux-bad2e478af3b4df9fd84b4db7779ea91bd618c16.tar.gz linux-bad2e478af3b4df9fd84b4db7779ea91bd618c16.tar.bz2 linux-bad2e478af3b4df9fd84b4db7779ea91bd618c16.zip |
selftests/bpf: Turn on libbpf 1.0 mode and fix all IS_ERR checks
Turn ony libbpf 1.0 mode. Fix all the explicit IS_ERR checks that now will be
broken because libbpf returns NULL on error (and sets errno). Fix
ASSERT_OK_PTR and ASSERT_ERR_PTR to work for both old mode and new modes and
use them throughout selftests. This is trivial to do by using
libbpf_get_error() API that all libbpf users are supposed to use, instead of
IS_ERR checks.
A bunch of checks also did explicit -1 comparison for various fd-returning
APIs. Such checks are replaced with >= 0 or < 0 cases.
There were also few misuses of bpf_object__find_map_by_name() in test_maps.
Those are fixed in this patch as well.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20210525035935.1461796-3-andrii@kernel.org
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c')
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c b/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c index 11a769e18f5d..0a91d8d9954b 100644 --- a/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c +++ b/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c @@ -62,8 +62,7 @@ retry: skel->links.oncpu = bpf_program__attach_perf_event(skel->progs.oncpu, pmu_fd); - if (CHECK(IS_ERR(skel->links.oncpu), "attach_perf_event", - "err %ld\n", PTR_ERR(skel->links.oncpu))) { + if (!ASSERT_OK_PTR(skel->links.oncpu, "attach_perf_event")) { close(pmu_fd); goto cleanup; } |