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

Function test

test/eventfd-ring.c:18–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#include "helpers.h"
17
18static int test(int flags)
19{
20 struct io_uring_params p = {};
21 struct io_uring ring1, ring2;
22 struct io_uring_sqe *sqe;
23 int ret, evfd1, evfd2;
24
25 p.flags = flags;
26 ret = io_uring_queue_init_params(8, &ring1, &p);
27 if (ret) {
28 if (ret == -EINVAL)
29 return T_EXIT_SKIP;
30 fprintf(stderr, "ring setup failed: %d\n", ret);
31 return T_EXIT_FAIL;
32 }
33 if (!(p.features & IORING_FEAT_CUR_PERSONALITY)) {
34 fprintf(stdout, "Skipping\n");
35 return T_EXIT_SKIP;
36 }
37 ret = io_uring_queue_init(8, &ring2, flags);
38 if (ret) {
39 fprintf(stderr, "ring setup failed: %d\n", ret);
40 return T_EXIT_FAIL;
41 }
42
43 evfd1 = eventfd(0, EFD_CLOEXEC);
44 if (evfd1 < 0) {
45 perror("eventfd");
46 return T_EXIT_FAIL;
47 }
48
49 evfd2 = eventfd(0, EFD_CLOEXEC);
50 if (evfd2 < 0) {
51 perror("eventfd");
52 return T_EXIT_FAIL;
53 }
54
55 ret = io_uring_register_eventfd(&ring1, evfd1);
56 if (ret) {
57 fprintf(stderr, "failed to register evfd: %d\n", ret);
58 return T_EXIT_FAIL;
59 }
60
61 ret = io_uring_register_eventfd(&ring2, evfd2);
62 if (ret) {
63 fprintf(stderr, "failed to register evfd: %d\n", ret);
64 return T_EXIT_FAIL;
65 }
66
67 sqe = io_uring_get_sqe(&ring1);
68 io_uring_prep_poll_add(sqe, evfd2, POLLIN);
69 sqe->user_data = 1;
70
71 sqe = io_uring_get_sqe(&ring2);
72 io_uring_prep_poll_add(sqe, evfd1, POLLIN);
73 sqe->user_data = 1;
74
75 ret = io_uring_submit(&ring1);

Callers 1

mainFunction · 0.70

Calls 5

io_uring_queue_initFunction · 0.85
io_uring_submitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected