Skip to content

Commit

Permalink
selftests/bpf: correct the check of join cgroup
Browse files Browse the repository at this point in the history
Use ASSERT_OK_FD to check the return value of join cgroup,
or else this test will pass even if the fd < 0. ASSERT_OK_FD
can print the error message to the console.

Link: https://lore.kernel.org/all/[email protected]/
Suggested-by: Martin KaFai Lau <[email protected]>
Signed-off-by: Jason Xing <[email protected]>
  • Loading branch information
JasonXing authored and Kernel Patches Daemon committed Feb 4, 2025
1 parent ab4839c commit 0827f7a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/prog_tests/setget_sockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static void test_nonstandard_opt(int family)
void test_setget_sockopt(void)
{
cg_fd = test__join_cgroup(CG_NAME);
if (cg_fd < 0)
if (!ASSERT_OK_FD(cg_fd, "join cgroup"))
return;

if (create_netns())
Expand Down

0 comments on commit 0827f7a

Please sign in to comment.