blob: f78fe22ae7056547fc3ef3364b5b47420fc7905f [file] [log] [blame]
Jens Axboee5024352020-02-11 20:34:12 -07001/* SPDX-License-Identifier: MIT */
Jens Axboe4bc1af02019-11-19 15:28:43 -07002#include <stdint.h>
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6#include <sys/syscall.h>
7#include <sys/types.h>
8#include <sys/wait.h>
9#include <unistd.h>
Jens Axboe2d8dcd22019-11-20 13:47:05 -070010#include <errno.h>
Jens Axboe4bc1af02019-11-19 15:28:43 -070011
12#include "liburing.h"
13
14static void loop(void)
15{
Jens Axboe2d8dcd22019-11-20 13:47:05 -070016 int i, ret = 0;
Jens Axboe4bc1af02019-11-19 15:28:43 -070017
Jens Axboe2d8dcd22019-11-20 13:47:05 -070018 for (i = 0; i < 100; i++) {
Jens Axboe4bc1af02019-11-19 15:28:43 -070019 struct io_uring ring;
20 int fd;
21
22 memset(&ring, 0, sizeof(ring));
23 fd = io_uring_queue_init(0xa4, &ring, 0);
Jens Axboe2d8dcd22019-11-20 13:47:05 -070024 if (fd >= 0) {
Jens Axboe4bc1af02019-11-19 15:28:43 -070025 close(fd);
Jens Axboe2d8dcd22019-11-20 13:47:05 -070026 continue;
27 }
28 if (fd != -ENOMEM)
29 ret++;
Jens Axboe4bc1af02019-11-19 15:28:43 -070030 }
Jens Axboe2d8dcd22019-11-20 13:47:05 -070031 exit(ret);
Jens Axboe4bc1af02019-11-19 15:28:43 -070032}
33
Jens Axboea2141fc2020-05-19 17:36:19 -060034int main(int argc, char *argv[])
Jens Axboe4bc1af02019-11-19 15:28:43 -070035{
Jens Axboe2d8dcd22019-11-20 13:47:05 -070036 int i, ret, status;
Jens Axboe4bc1af02019-11-19 15:28:43 -070037
Jens Axboea2141fc2020-05-19 17:36:19 -060038 if (argc > 1)
39 return 0;
40
Jens Axboe4bc1af02019-11-19 15:28:43 -070041 for (i = 0; i < 12; i++) {
42 if (!fork()) {
43 loop();
44 break;
45 }
46 }
47
Jens Axboe2d8dcd22019-11-20 13:47:05 -070048 ret = 0;
49 for (i = 0; i < 12; i++) {
50 if (waitpid(-1, &status, 0) < 0) {
51 perror("waitpid");
52 return 1;
53 }
54 if (WEXITSTATUS(status))
55 ret++;
56 }
57
58 return ret;
Jens Axboe4bc1af02019-11-19 15:28:43 -070059}