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

Function test_poll

test/defer-tw-timeout.c:36–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36static int test_poll(struct io_uring *ring)
37{
38 struct io_uring_cqe *cqe;
39 struct io_uring_sqe *sqe;
40 struct __kernel_timespec ts;
41 int ret, fds[2], i;
42 pthread_t thread;
43 char buf[32];
44 struct d d;
45 void *tret;
46
47 if (pipe(fds) < 0) {
48 perror("pipe");
49 return 1;
50 }
51 d.fd = fds[1];
52
53 sqe = io_uring_get_sqe(ring);
54 io_uring_prep_read(sqe, fds[0], buf, sizeof(buf), 0);
55
56 pthread_create(&thread, NULL, thread_fn, &d);
57
58 ts.tv_sec = 1;
59 ts.tv_nsec = 0;
60
61 ret = io_uring_submit_and_wait_timeout(ring, &cqe, 2, &ts, NULL);
62 if (ret != 1) {
63 fprintf(stderr, "unexpected wait ret %d\n", ret);
64 return T_EXIT_FAIL;
65 }
66
67 for (i = 0; i < 2; i++) {
68 ret = io_uring_peek_cqe(ring, &cqe);
69 if (ret)
70 break;
71 io_uring_cqe_seen(ring, cqe);
72 }
73
74 if (i != 1) {
75 fprintf(stderr, "Got %d request, expected 1\n", i);
76 return T_EXIT_FAIL;
77 }
78
79 pthread_join(thread, &tret);
80 return T_EXIT_PASS;
81}
82
83static int test_file(struct io_uring *ring, char *__fname)
84{

Callers 1

mainFunction · 0.85

Calls 2

io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected