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

Function main

test/fadvise.c:138–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138int main(int argc, char *argv[])
139{
140 struct io_uring ring;
141 int ret, i, good, bad;
142 char *fname;
143
144 if (argc > 1) {
145 fname = argv[1];
146 } else {
147 fname = ".fadvise.tmp";
148 t_create_file(fname, FILE_SIZE);
149 }
150 if (io_uring_queue_init(8, &ring, 0)) {
151 fprintf(stderr, "ring creation failed\n");
152 goto err;
153 }
154
155 good = bad = 0;
156 for (i = 0; i < LOOPS; i++) {
157 ret = test_fadvise(&ring, fname);
158 if (ret == T_EXIT_SKIP)
159 return T_EXIT_SKIP;
160 if (ret == 1) {
161 fprintf(stderr, "read_fadvise failed\n");
162 goto err;
163 } else if (!ret)
164 good++;
165 else if (ret == 2)
166 bad++;
167 if (i >= MIN_LOOPS && !bad)
168 break;
169 }
170
171 /* too hard to reliably test, just ignore */
172 if ((0) && bad > good) {
173 fprintf(stderr, "Suspicious timings\n");
174 goto err;
175 }
176
177 if (fname != argv[1])
178 unlink(fname);
179 io_uring_queue_exit(&ring);
180 return T_EXIT_PASS;
181err:
182 if (fname != argv[1])
183 unlink(fname);
184 return T_EXIT_FAIL;
185}

Callers

nothing calls this directly

Calls 4

t_create_fileFunction · 0.85
io_uring_queue_initFunction · 0.85
test_fadviseFunction · 0.85
io_uring_queue_exitFunction · 0.85

Tested by

no test coverage detected