mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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
This commit is contained in:
parent
5981881d21
commit
bad2e478af
56 changed files with 347 additions and 425 deletions
|
@ -48,8 +48,7 @@ static void test_hashmap_generic(void)
|
|||
struct hashmap *map;
|
||||
|
||||
map = hashmap__new(hash_fn, equal_fn, NULL);
|
||||
if (CHECK(IS_ERR(map), "hashmap__new",
|
||||
"failed to create map: %ld\n", PTR_ERR(map)))
|
||||
if (!ASSERT_OK_PTR(map, "hashmap__new"))
|
||||
return;
|
||||
|
||||
for (i = 0; i < ELEM_CNT; i++) {
|
||||
|
@ -267,8 +266,7 @@ static void test_hashmap_multimap(void)
|
|||
|
||||
/* force collisions */
|
||||
map = hashmap__new(collision_hash_fn, equal_fn, NULL);
|
||||
if (CHECK(IS_ERR(map), "hashmap__new",
|
||||
"failed to create map: %ld\n", PTR_ERR(map)))
|
||||
if (!ASSERT_OK_PTR(map, "hashmap__new"))
|
||||
return;
|
||||
|
||||
/* set up multimap:
|
||||
|
@ -339,8 +337,7 @@ static void test_hashmap_empty()
|
|||
|
||||
/* force collisions */
|
||||
map = hashmap__new(hash_fn, equal_fn, NULL);
|
||||
if (CHECK(IS_ERR(map), "hashmap__new",
|
||||
"failed to create map: %ld\n", PTR_ERR(map)))
|
||||
if (!ASSERT_OK_PTR(map, "hashmap__new"))
|
||||
goto cleanup;
|
||||
|
||||
if (CHECK(hashmap__size(map) != 0, "hashmap__size",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue