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

Function _test_io

test/read-write.c:47–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47static int _test_io(const char *file, struct io_uring *ring, int write,
48 int buffered, int sqthread, int fixed, int nonvec,
49 int buf_select, int seq, int exp_len, bool worker_offload)
50{
51 struct io_uring_sqe *sqe;
52 struct io_uring_cqe *cqe;
53 int open_flags;
54 int i, fd = -1, ret;
55 off_t offset;
56
57#ifdef VERBOSE
58 fprintf(stdout, "%s: start %d/%d/%d/%d/%d: ", __FUNCTION__, write,
59 buffered, sqthread,
60 fixed, nonvec);
61#endif
62 if (write)
63 open_flags = O_WRONLY;
64 else
65 open_flags = O_RDONLY;
66 if (!buffered)
67 open_flags |= O_DIRECT;
68
69 if (fixed == 1) {
70 ret = t_register_buffers(ring, vecs, BUFFERS);
71 if (ret == T_SETUP_SKIP)
72 return 0;
73 if (ret != T_SETUP_OK) {
74 fprintf(stderr, "buffer reg failed: %d\n", ret);
75 goto err;
76 }
77 }
78
79 fd = open(file, open_flags);
80 if (fd < 0) {
81 if (errno == EINVAL || errno == EPERM || errno == EACCES)
82 return 0;
83 perror("file open");
84 goto err;
85 }
86
87 if (sqthread) {
88 ret = io_uring_register_files(ring, &fd, 1);
89 if (ret) {
90 fprintf(stderr, "file reg failed: %d\n", ret);
91 goto err;
92 }
93 }
94
95 offset = 0;
96 for (i = 0; i < BUFFERS; i++) {
97 sqe = io_uring_get_sqe(ring);
98 if (!sqe) {
99 fprintf(stderr, "sqe get failed\n");
100 goto err;
101 }
102 if (!seq)
103 offset = BS * (rand() % BUFFERS);
104 if (write) {

Callers 1

__test_ioFunction · 0.85

Calls 5

t_register_buffersFunction · 0.85
io_uring_register_filesFunction · 0.85
io_uring_submitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected