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

Function test_left

test/sq-space_left.c:15–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include "liburing.h"
14
15static int test_left(void)
16{
17 struct io_uring_sqe *sqe;
18 struct io_uring ring;
19 int ret, i = 0, s;
20
21 ret = io_uring_queue_init(8, &ring, 0);
22 if (ret) {
23 fprintf(stderr, "ring setup failed: %d\n", ret);
24 return 1;
25
26 }
27
28 if ((s = io_uring_sq_space_left(&ring)) != 8) {
29 fprintf(stderr, "Got %d SQEs left, expected %d\n", s, 8);
30 goto err;
31 }
32
33 i = 0;
34 while ((sqe = io_uring_get_sqe(&ring)) != NULL) {
35 i++;
36 if ((s = io_uring_sq_space_left(&ring)) != 8 - i) {
37 fprintf(stderr, "Got %d SQEs left, expected %d\n", s, 8 - i);
38 goto err;
39 }
40 }
41
42 if (i != 8) {
43 fprintf(stderr, "Got %d SQEs, expected %d\n", i, 8);
44 goto err;
45 }
46
47 io_uring_queue_exit(&ring);
48 return 0;
49err:
50 io_uring_queue_exit(&ring);
51 return 1;
52}
53
54static int test_sync(void)
55{

Callers 1

mainFunction · 0.85

Calls 4

io_uring_queue_initFunction · 0.85
io_uring_sq_space_leftFunction · 0.85
io_uring_queue_exitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected