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

Function test_inc

test/read-mshot.c:44–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44static int test_inc(int use_mshot, int flags)
45{
46 struct io_uring_buf_ring *br;
47 struct io_uring_params p = { };
48 struct io_uring_cqe *cqe;
49 struct io_uring ring;
50 int nbytes = 65536;
51 int ret, fds[2], i;
52 char tmp[31];
53 char *buf;
54 void *ptr;
55 int bid = -1;
56 int bid_bytes;
57
58 if (no_buf_ring)
59 return 0;
60
61 p.flags = flags;
62 ret = io_uring_queue_init_params(64, &ring, &p);
63 if (ret) {
64 fprintf(stderr, "ring setup failed: %d\n", ret);
65 return 1;
66 }
67
68 if (pipe(fds) < 0) {
69 perror("pipe");
70 return 1;
71 }
72
73 if (posix_memalign((void **) &buf, 4096, 65536))
74 return 1;
75
76 br = io_uring_setup_buf_ring(&ring, 32, BUF_BGID, IOU_PBUF_RING_INC, &ret);
77 if (!br) {
78 if (ret == -EINVAL) {
79 no_buf_ring_inc = 1;
80 free(buf);
81 return 0;
82 }
83 fprintf(stderr, "Buffer ring register failed %d\n", ret);
84 return 1;
85 }
86
87 ptr = buf;
88 buf = ptr + 65536 - 2048;
89 for (i = 0; i < 32; i++) {
90 io_uring_buf_ring_add(br, buf, 2048, i, 31, i);
91 buf -= 2048;
92 }
93 io_uring_buf_ring_advance(br, 32);
94
95 memset(tmp, 0x5a, sizeof(tmp));
96
97 arm_read(&ring, fds[0], use_mshot);
98
99 bid_bytes = 0;
100 do {
101 int write_size = sizeof(tmp);

Callers 1

mainFunction · 0.85

Calls 6

io_uring_setup_buf_ringFunction · 0.85
io_uring_get_eventsFunction · 0.85
io_uring_free_buf_ringFunction · 0.85
io_uring_queue_exitFunction · 0.85
arm_readFunction · 0.70

Tested by

no test coverage detected