Skip to contentSkip to conversation

selftests/bpf: correct the check of join cgroup

PATCH Applied Jason Xing 3 participants 3 messages Feb 4, 2025 – Feb 7, 2025

Subsystems (3)
lore
Share & tools
lore

Jason Xing

author
#0 lore raw

PATCH 1/1 selftests/bpf: correct the check of join cgroup

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.

---
 tools/testing/selftests/bpf/prog_tests/setget_sockopt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/setget_sockopt.c +1 -1
index e12255121c15..e4dac529d424 100644
@@ -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())
Signature · 1 line
2.43.5
#2 lore raw
In reply to Jason Xing
This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Quoted 9 lines · On Tue, 4 Feb 2025 13:11:54 +0800 you wrote:

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.

[...]

Here is the summary with links:
- [bpf-next,v1] selftests/bpf: correct the check of join cgroup

    https://git.kernel.org/bpf/bpf-next/c/003be25ab99c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html