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

Function __test_writes

test/min-timeout-wait.c:66–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66static int __test_writes(struct io_uring *ring, int npipes, int usec_sleep,
67 int usec_wait, int min_t, int max_t, const char *name)
68{
69 struct __kernel_timespec ts;
70 struct io_uring_cqe *cqe;
71 struct io_uring_sqe *sqe;
72 struct timeval tv;
73 int ret, i, fds[4][2];
74 pthread_t thread;
75 struct data d;
76 char buf[32];
77 void *tret;
78
79 for (i = 0; i < npipes; i++) {
80 if (pipe(fds[i]) < 0) {
81 perror("pipe");
82 return T_EXIT_FAIL;
83 }
84 d.out_fds[i] = fds[i][1];
85 }
86 d.nr_fds = npipes;
87
88 pthread_barrier_init(&d.startup, NULL, 2);
89 d.usec_sleep = usec_sleep;
90
91 pthread_create(&thread, NULL, pipe_write, &d);
92 pthread_barrier_wait(&d.startup);
93
94 for (i = 0; i < npipes; i++) {
95 sqe = io_uring_get_sqe(ring);
96 io_uring_prep_read(sqe, fds[i][0], buf, sizeof(buf), 0);
97 }
98
99 io_uring_submit(ring);
100
101 ts.tv_sec = 1;
102 ts.tv_nsec = 0;
103 gettimeofday(&tv, NULL);
104 ret = io_uring_wait_cqes_min_timeout(ring, &cqe, 4, &ts, usec_wait, NULL);
105 if (ret) {
106 fprintf(stderr, "wait_cqes: %d\n", ret);
107 return T_EXIT_FAIL;
108 }
109
110 ret = time_pass(&tv, min_t, max_t, name);
111
112 io_uring_cq_advance(ring, npipes);
113
114 pthread_join(thread, &tret);
115 for (i = 0; i < npipes; i++) {
116 close(fds[i][0]);
117 close(fds[i][1]);
118 }
119 return ret;
120}
121/*
122 * Test doing min_wait for N events, where 0 events are already available
123 * on wait enter but N/2 are posted within the min_wait window. We'll expect to

Callers 3

test_some_waitFunction · 0.85
test_post_waitFunction · 0.85
test_lateFunction · 0.85

Calls 4

io_uring_submitFunction · 0.85
time_passFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by 3

test_some_waitFunction · 0.68
test_post_waitFunction · 0.68
test_lateFunction · 0.68