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

Function test_vec

test/vec-regbuf.c:266–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264}
265
266static int test_vec(struct buf_desc *bd, struct iovec *vecs, int nr_vec,
267 bool expect_fail, int *cqe_ret)
268{
269 struct sockaddr_storage addr;
270 int sock_server, sock_client;
271 struct verify_data vd;
272 size_t total_len;
273 int i, ret;
274 void *verify_res;
275 pthread_t th;
276
277 ret = t_create_socketpair_ip(&addr, &sock_client, &sock_server,
278 true, true, false, true, "::1");
279 if (ret) {
280 fprintf(stderr, "sock prep failed %d\n", ret);
281 return 1;
282 }
283
284 for (i = 0; i < bd->size; i++)
285 bd->buf_wr[i] = i;
286 memset(bd->buf_rd, 0, bd->size);
287 total_len = t_iovec_data_length(vecs, nr_vec);
288
289 vd.bd = bd;
290 vd.vecs = vecs;
291 vd.nr_vec = nr_vec;
292 vd.fd = sock_server;
293
294 if (!expect_fail) {
295 ret = pthread_create(&th, NULL, verify_thread_cb, &vd);
296 if (ret) {
297 fprintf(stderr, "pthread_create failed %i\n", ret);
298 return ret;
299 }
300 }
301
302 if (bd->rw)
303 ret = test_rw(bd, vecs, nr_vec, sock_client);
304 else
305 ret = test_sendzc(bd, vecs, nr_vec, sock_client);
306
307 *cqe_ret = ret;
308
309 if (!expect_fail && ret != total_len) {
310 fprintf(stderr, "invalid cqe %i, expected %lu\n",
311 ret, (unsigned long)total_len);
312 return 1;
313 }
314
315 if (!expect_fail) {
316 pthread_join(th, &verify_res);
317 ret = (int)(unsigned long)verify_res;
318 if (ret) {
319 fprintf(stderr, "verify failed %i\n", ret);
320 return 1;
321 }
322 }
323 close(sock_client);

Callers 2

test_sequenceFunction · 0.85
test_failFunction · 0.85

Calls 4

t_create_socketpair_ipFunction · 0.85
t_iovec_data_lengthFunction · 0.85
test_sendzcFunction · 0.85
test_rwFunction · 0.70

Tested by

no test coverage detected