Message ID | 06755f462ddb7bc9f734f105e18c1d77c03811cb.1720146231.git.tanggeliang@kylinos.cn (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | skip ENOTSUPP BPF selftests | expand |
On Fri, 2024-07-05 at 10:38 +0800, Geliang Tang wrote: [...] I think that this patch is an improvement independent of the patch-set. Please submit it separately. > .../selftests/bpf/prog_tests/bpf_tcp_ca.c | 16 ++++++++++++---- [...] > @@ -489,6 +494,7 @@ static void test_mixed_links(void) > ASSERT_ERR(err, "update_map"); > > bpf_link__destroy(link); > +err: Nit: there are two links in this test, but ASSERT_OK_PTR is added only for a single one. Also note that bpf_link__destroy(NULL) works just fine, so it is possible to initialize links as NULL and make a jump to cleanup block w/o peeking exact position within that block. > bpf_link__destroy(link_nl); > tcp_ca_update__destroy(skel); > } [...]
Hi Eduard, On Mon, 2024-07-08 at 12:42 -0700, Eduard Zingerman wrote: > On Fri, 2024-07-05 at 10:38 +0800, Geliang Tang wrote: > > [...] > > I think that this patch is an improvement independent of the patch- > set. > Please submit it separately. > > > .../selftests/bpf/prog_tests/bpf_tcp_ca.c | 16 > > ++++++++++++---- > > [...] > > > @@ -489,6 +494,7 @@ static void test_mixed_links(void) > > ASSERT_ERR(err, "update_map"); > > > > bpf_link__destroy(link); > > +err: > > Nit: there are two links in this test, but ASSERT_OK_PTR is added > only > for a single one. Also note that bpf_link__destroy(NULL) works > just fine, so it is possible to initialize links as NULL and > make > a jump to cleanup block w/o peeking exact position within that > block. Thanks for your review. I sent a set named "BPF selftests misc fixes" yesterday to address your comments. But reconsider it. I think here checking the first link (link_nl) is enough. We can keep the second link as it. I changed "BPF selftests misc fixes" as "Changes Requested". Thanks, -Geliang > > > bpf_link__destroy(link_nl); > > tcp_ca_update__destroy(skel); > > } > > [...] >
diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c index 5909c1f82f3b..9effdfb1a5ce 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c @@ -407,7 +407,8 @@ static void test_update_ca(void) return; link = bpf_map__attach_struct_ops(skel->maps.ca_update_1); - ASSERT_OK_PTR(link, "attach_struct_ops"); + if (!ASSERT_OK_PTR(link, "attach_struct_ops")) + goto err; do_test(&opts); saved_ca1_cnt = skel->bss->ca1_cnt; @@ -421,6 +422,7 @@ static void test_update_ca(void) ASSERT_GT(skel->bss->ca2_cnt, 0, "ca2_ca2_cnt"); bpf_link__destroy(link); +err: tcp_ca_update__destroy(skel); } @@ -443,7 +445,8 @@ static void test_update_wrong(void) return; link = bpf_map__attach_struct_ops(skel->maps.ca_update_1); - ASSERT_OK_PTR(link, "attach_struct_ops"); + if (!ASSERT_OK_PTR(link, "attach_struct_ops")) + goto err; do_test(&opts); saved_ca1_cnt = skel->bss->ca1_cnt; @@ -456,6 +459,7 @@ static void test_update_wrong(void) ASSERT_GT(skel->bss->ca1_cnt, saved_ca1_cnt, "ca2_ca1_cnt"); bpf_link__destroy(link); +err: tcp_ca_update__destroy(skel); } @@ -480,7 +484,8 @@ static void test_mixed_links(void) ASSERT_OK_PTR(link_nl, "attach_struct_ops_nl"); link = bpf_map__attach_struct_ops(skel->maps.ca_update_1); - ASSERT_OK_PTR(link, "attach_struct_ops"); + if (!ASSERT_OK_PTR(link, "attach_struct_ops")) + goto err; do_test(&opts); ASSERT_GT(skel->bss->ca1_cnt, 0, "ca1_ca1_cnt"); @@ -489,6 +494,7 @@ static void test_mixed_links(void) ASSERT_ERR(err, "update_map"); bpf_link__destroy(link); +err: bpf_link__destroy(link_nl); tcp_ca_update__destroy(skel); } @@ -532,7 +538,8 @@ static void test_link_replace(void) bpf_link__destroy(link); link = bpf_map__attach_struct_ops(skel->maps.ca_update_2); - ASSERT_OK_PTR(link, "attach_struct_ops_2nd"); + if (!ASSERT_OK_PTR(link, "attach_struct_ops_2nd")) + goto err; /* BPF_F_REPLACE with a wrong old map Fd. It should fail! * @@ -555,6 +562,7 @@ static void test_link_replace(void) bpf_link__destroy(link); +err: tcp_ca_update__destroy(skel); }