Commit cd984b2e authored by Geliang Tang's avatar Geliang Tang Committed by Daniel Borkmann

selftests/bpf: Use start_test in test_dctcp in bpf_tcp_ca

The "if (sk_stg_map)" block in do_test() is only used by test_dctcp(),
it makes sense to move it from do_test() into test_dctcp(). Then
do_test() can be used by other tests except test_dctcp().
Signed-off-by: default avatarGeliang Tang <tanggeliang@kylinos.cn>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/9938916627b9810c877e5c03a621bc0ba5acf5c5.1717054461.git.tanggeliang@kylinos.cn
parent 224eeb55
......@@ -72,21 +72,10 @@ static void do_test(const struct network_helper_opts *opts,
const struct bpf_map *sk_stg_map)
{
int lfd = -1, fd = -1;
int err;
if (!start_test(NULL, opts, cli_opts, &lfd, &fd))
goto done;
if (sk_stg_map) {
int tmp_stg;
err = bpf_map_lookup_elem(bpf_map__fd(sk_stg_map), &fd,
&tmp_stg);
if (!ASSERT_ERR(err, "bpf_map_lookup_elem(sk_stg_map)") ||
!ASSERT_EQ(errno, ENOENT, "bpf_map_lookup_elem(sk_stg_map)"))
goto done;
}
ASSERT_OK(send_recv_data(lfd, fd, total_bytes), "send_recv_data");
done:
......@@ -163,6 +152,7 @@ static void test_dctcp(void)
.post_socket_cb = stg_post_socket_cb,
.cb_opts = &cb_opts,
};
int lfd = -1, fd = -1, tmp_stg, err;
struct bpf_dctcp *dctcp_skel;
struct bpf_link *link;
......@@ -177,11 +167,24 @@ static void test_dctcp(void)
}
cb_opts.map_fd = bpf_map__fd(dctcp_skel->maps.sk_stg_map);
do_test(&opts, &cli_opts, dctcp_skel->maps.sk_stg_map);
if (!start_test(NULL, &opts, &cli_opts, &lfd, &fd))
goto done;
err = bpf_map_lookup_elem(cb_opts.map_fd, &fd, &tmp_stg);
if (!ASSERT_ERR(err, "bpf_map_lookup_elem(sk_stg_map)") ||
!ASSERT_EQ(errno, ENOENT, "bpf_map_lookup_elem(sk_stg_map)"))
goto done;
ASSERT_OK(send_recv_data(lfd, fd, total_bytes), "send_recv_data");
ASSERT_EQ(dctcp_skel->bss->stg_result, expected_stg, "stg_result");
done:
bpf_link__destroy(link);
bpf_dctcp__destroy(dctcp_skel);
if (lfd != -1)
close(lfd);
if (fd != -1)
close(fd);
}
static char *err_str;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment