Skip to content

Commit

Permalink
selftests/bpf: Replaces the usage of CHECK calls for ASSERTs in bind_…
Browse files Browse the repository at this point in the history
…perm

bind_perm uses the `CHECK` calls even though the use of
ASSERT_ series of macros is preferred in the bpf selftests.

This patch replaces all `CHECK` calls for equivalent `ASSERT_`
macro calls.

Signed-off-by: Yuran Pereira <yuran.pereira@hotmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/GV1PR10MB656314F467E075A106CA02BFE8BBA@GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM
  • Loading branch information
Yuran Pereira authored and Andrii Nakryiko committed Nov 21, 2023
1 parent b0e2a03 commit 3ec1114
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tools/testing/selftests/bpf/prog_tests/bind_perm.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include "cap_helpers.h"
#include "bind_perm.skel.h"

static int duration;

static int create_netns(void)
{
if (!ASSERT_OK(unshare(CLONE_NEWNET), "create netns"))
Expand All @@ -27,7 +25,7 @@ void try_bind(int family, int port, int expected_errno)
int fd = -1;

fd = socket(family, SOCK_STREAM, 0);
if (CHECK(fd < 0, "fd", "errno %d", errno))
if (!ASSERT_GE(fd, 0, "socket"))
goto close_socket;

if (family == AF_INET) {
Expand Down Expand Up @@ -60,7 +58,7 @@ void test_bind_perm(void)
return;

cgroup_fd = test__join_cgroup("/bind_perm");
if (CHECK(cgroup_fd < 0, "cg-join", "errno %d", errno))
if (!ASSERT_GE(cgroup_fd, 0, "test__join_cgroup"))
return;

skel = bind_perm__open_and_load();
Expand Down

0 comments on commit 3ec1114

Please sign in to comment.