summaryrefslogtreecommitdiff
path: root/test/cq-size.c
blob: 9b55322da7614c006c479e0ed1eaeb86b3dc04bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * Description: test CQ ring sizing
 */
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>

#include "liburing.h"

int main(int argc, char *argv[])
{
	struct io_uring_params p;
	struct io_uring ring;
	int ret;

	memset(&p, 0, sizeof(p));
	p.flags = IORING_SETUP_CQSIZE;
	p.cq_entries = 64;

	ret = io_uring_queue_init_params(4, &ring, &p);
	if (ret) {
		if (ret == -EINVAL) {
			printf("Skipped, not supported on this kernel\n");
			goto done;
		}
		printf("ring setup failed\n");
		return 1;
	}

	if (p.cq_entries < 64) {
		printf("cq entries invalid (%d)\n", p.cq_entries);
		goto err;
	}
	io_uring_queue_exit(&ring);

	memset(&p, 0, sizeof(p));
	p.flags = IORING_SETUP_CQSIZE;
	p.cq_entries = 0;

	ret = io_uring_queue_init_params(4, &ring, &p);
	if (ret >= 0 || errno != EINVAL) {
		printf("zero sized cq ring succeeded\n");
		goto err;
	}

done:
	return 0;
err:
	io_uring_queue_exit(&ring);
	return 1;
}