MCPcopy Create free account
hub / github.com/axboe/liburing / test

Function test

test/recv-multishot.c:55–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55static int test(struct args *args)
56{
57 int const N = 8;
58 int const N_BUFFS = N * 64;
59 int const N_CQE_OVERFLOW = 4;
60 int const min_cqes = args->early_error ? 2 : 8;
61 int const NAME_LEN = sizeof(struct sockaddr_storage);
62 int const CONTROL_LEN = CMSG_ALIGN(sizeof(struct sockaddr_storage))
63 + sizeof(struct cmsghdr);
64 struct io_uring ring;
65 struct io_uring_cqe *cqe;
66 struct io_uring_sqe *sqe;
67 int fds[2], ret, i, j;
68 int total_sent_bytes = 0, total_recv_bytes = 0, total_dropped_bytes = 0;
69 int send_buff[256];
70 int *sent_buffs[N_BUFFS];
71 int *recv_buffs[N_BUFFS];
72 int *at;
73 struct io_uring_cqe recv_cqe[N_BUFFS];
74 int recv_cqes = 0;
75 bool early_error = false;
76 bool early_error_started = false;
77 struct __kernel_timespec timeout = {
78 .tv_sec = 1,
79 };
80 struct msghdr msg;
81 struct io_uring_params params = { };
82 int n_sqe = 32;
83
84 memset(recv_buffs, 0, sizeof(recv_buffs));
85
86 if (args->defer)
87 params.flags |= IORING_SETUP_SINGLE_ISSUER |
88 IORING_SETUP_DEFER_TASKRUN;
89
90 if (args->early_error == ERROR_EARLY_OVERFLOW) {
91 params.flags |= IORING_SETUP_CQSIZE;
92 params.cq_entries = N_CQE_OVERFLOW;
93 n_sqe = N_CQE_OVERFLOW;
94 }
95
96 ret = io_uring_queue_init_params(n_sqe, &ring, &params);
97 if (ret) {
98 fprintf(stderr, "queue init failed: %d\n", ret);
99 return ret;
100 }
101
102 ret = t_create_socket_pair(fds, args->stream);
103 if (ret) {
104 fprintf(stderr, "t_create_socket_pair failed: %d\n", ret);
105 return ret;
106 }
107
108 if (!args->stream) {
109 bool val = true;
110
111 /* force some cmsgs to come back to us */
112 ret = setsockopt(fds[0], IPPROTO_IP, IP_RECVORIGDSTADDR, &val,

Callers 1

mainFunction · 0.70

Calls 14

t_create_socket_pairFunction · 0.85
io_uring_submitFunction · 0.85
io_uring_get_eventsFunction · 0.85
io_uring_wait_cqesFunction · 0.85
check_sockaddrFunction · 0.85
io_uring_recvmsg_nameFunction · 0.85
io_uring_recvmsg_payloadFunction · 0.85

Tested by

no test coverage detected