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

Function main

test/ringbuf-read.c:133–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133int main(int argc, char *argv[])
134{
135 char buf[BUF_SIZE];
136 char fname[80];
137 int ret, fd, i, do_unlink;
138
139 if (argc > 1) {
140 snprintf(fname, sizeof(fname), "%s", argv[1]);
141 do_unlink = 0;
142 } else {
143 sprintf(fname, ".ringbuf-read.%d", getpid());
144 t_create_file(fname, FSIZE);
145 do_unlink = 1;
146 }
147
148 fd = open(fname, O_WRONLY);
149 if (fd < 0) {
150 if (errno == EPERM || errno == EACCES)
151 return T_EXIT_SKIP;
152 perror("open");
153 goto err;
154 }
155 for (i = 0; i < NR_BUFS; i++) {
156 memset(buf, i + 1, BUF_SIZE);
157 ret = write(fd, buf, BUF_SIZE);
158 if (ret != BUF_SIZE) {
159 fprintf(stderr, "bad file prep write\n");
160 close(fd);
161 goto err;
162 }
163 }
164 close(fd);
165
166 ret = test(fname, 1, 0);
167 if (ret == T_EXIT_FAIL) {
168 fprintf(stderr, "dio test failed\n");
169 goto err;
170 }
171 if (no_buf_ring)
172 goto pass;
173
174 ret = test(fname, 0, 0);
175 if (ret) {
176 fprintf(stderr, "buffered test failed\n");
177 goto err;
178 }
179
180 ret = test(fname, 1, 1);
181 if (ret == T_EXIT_FAIL) {
182 fprintf(stderr, "dio async test failed\n");
183 goto err;
184 }
185
186 ret = test(fname, 0, 1);
187 if (ret == T_EXIT_FAIL) {
188 fprintf(stderr, "buffered async test failed\n");
189 goto err;
190 }

Callers

nothing calls this directly

Calls 2

t_create_fileFunction · 0.85
testFunction · 0.70

Tested by

no test coverage detected