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

Function test

test/submit-and-wait.c:19–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include "test.h"
18
19static int test(struct io_uring *ring)
20{
21 struct io_uring_cqe *cqe;
22 struct io_uring_sqe *sqe;
23 struct __kernel_timespec ts;
24 struct timeval tv;
25 int ret, i;
26
27 for (i = 0; i < 1; i++) {
28 sqe = io_uring_get_sqe(ring);
29 if (!sqe) {
30 fprintf(stderr, "get sqe failed at %d\n", i);
31 goto err;
32 }
33 io_uring_prep_nop(sqe);
34 }
35
36 ts.tv_sec = 1;
37 ts.tv_nsec = 0;
38 gettimeofday(&tv, NULL);
39 ret = io_uring_submit_and_wait_timeout(ring, &cqe, 2, &ts, NULL);
40 if (ret < 0) {
41 fprintf(stderr, "submit_and_wait_timeout: %d\n", ret);
42 goto err;
43 }
44 ret = mtime_since_now(&tv);
45 /* allow some slack, should be around 1s */
46 if (ret > 1200) {
47 fprintf(stderr, "wait took too long: %d\n", ret);
48 goto err;
49 }
50 return 0;
51err:
52 return 1;
53}
54
55static int test_ring(void)
56{

Callers 1

test_ringFunction · 0.70

Calls 3

mtime_since_nowFunction · 0.70
io_uring_get_sqeFunction · 0.50

Tested by 1

test_ringFunction · 0.56