Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Convert sockopt_multi test to ASSERT_* macros

Convert the selftest to use the preferred ASSERT_* macros instead of the
deprecated CHECK().

Signed-off-by: Wang Yufen <wangyufen@huawei.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/1664169131-32405-6-git-send-email-wangyufen@huawei.com

authored by

Wang Yufen and committed by
Andrii Nakryiko
a605a6bb 675bc8ab

+5 -5
+5 -5
tools/testing/selftests/bpf/prog_tests/sockopt_multi.c
··· 303 303 int err = -1; 304 304 305 305 cg_parent = test__join_cgroup("/parent"); 306 - if (CHECK_FAIL(cg_parent < 0)) 306 + if (!ASSERT_GE(cg_parent, 0, "join_cgroup /parent")) 307 307 goto out; 308 308 309 309 cg_child = test__join_cgroup("/parent/child"); 310 - if (CHECK_FAIL(cg_child < 0)) 310 + if (!ASSERT_GE(cg_child, 0, "join_cgroup /parent/child")) 311 311 goto out; 312 312 313 313 obj = bpf_object__open_file("sockopt_multi.bpf.o", NULL); ··· 319 319 goto out; 320 320 321 321 sock_fd = socket(AF_INET, SOCK_STREAM, 0); 322 - if (CHECK_FAIL(sock_fd < 0)) 322 + if (!ASSERT_GE(sock_fd, 0, "socket")) 323 323 goto out; 324 324 325 - CHECK_FAIL(run_getsockopt_test(obj, cg_parent, cg_child, sock_fd)); 326 - CHECK_FAIL(run_setsockopt_test(obj, cg_parent, cg_child, sock_fd)); 325 + ASSERT_OK(run_getsockopt_test(obj, cg_parent, cg_child, sock_fd), "getsockopt_test"); 326 + ASSERT_OK(run_setsockopt_test(obj, cg_parent, cg_child, sock_fd), "setsockopt_test"); 327 327 328 328 out: 329 329 close(sock_fd);