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

Function test_sync

test/sq-space_left.c:54–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54static int test_sync(void)
55{
56 struct io_uring_sqe *sqe;
57 struct io_uring ring;
58 int ret, i;
59
60 ret = io_uring_queue_init(32, &ring, 0);
61 if (ret) {
62 fprintf(stderr, "ring setup failed: %d\n", ret);
63 return 1;
64
65 }
66
67 /* prep 8 NOPS */
68 for (i = 0; i < 8; i++) {
69 sqe = io_uring_get_sqe(&ring);
70 if (!sqe) {
71 fprintf(stderr, "get sqe failed\n");
72 goto err;
73 }
74 io_uring_prep_nop(sqe);
75 }
76
77 /* prep known bad command, this should terminate submission */
78 sqe = io_uring_get_sqe(&ring);
79 if (!sqe) {
80 fprintf(stderr, "get sqe failed\n");
81 goto err;
82 }
83 io_uring_prep_nop(sqe);
84 sqe->opcode = 0xfe;
85
86 /* prep 8 NOPS */
87 for (i = 0; i < 8; i++) {
88 sqe = io_uring_get_sqe(&ring);
89 if (!sqe) {
90 fprintf(stderr, "get sqe failed\n");
91 goto err;
92 }
93 io_uring_prep_nop(sqe);
94 }
95
96 /* we should have 8 + 1 + 8 pending now */
97 ret = io_uring_sq_ready(&ring);
98 if (ret != 17) {
99 fprintf(stderr, "%d ready, wanted 17\n", ret);
100 goto err;
101 }
102
103 ret = io_uring_submit(&ring);
104
105 /* should submit 8 successfully, then error #9 and stop */
106 if (ret != 9) {
107 fprintf(stderr, "submitted %d, wanted 9\n", ret);
108 goto err;
109 }
110
111 /* should now have 8 ready, with 9 gone */

Callers 1

mainFunction · 0.85

Calls 5

io_uring_queue_initFunction · 0.85
io_uring_sq_readyFunction · 0.85
io_uring_submitFunction · 0.85
io_uring_queue_exitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected