aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/liburing/test/sq-full-cpp.cc
blob: f825596bdf1a5e99bae5d1b20ae0e31f2200ff7e (plain) (blame)
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
#include "../config-host.h"
/* SPDX-License-Identifier: MIT */
/*
 * Description: test SQ queue full condition
 *
 */
#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_sqe *sqe;
	struct io_uring ring;
	int ret, i;

	if (argc > 1)
		return 0;

	ret = io_uring_queue_init(8, &ring, 0);
	if (ret) {
		fprintf(stderr, "ring setup failed: %d\n", ret);
		return 1;

	}

	i = 0;
	while ((sqe = io_uring_get_sqe(&ring)) != NULL)
		i++;

	if (i != 8) {
		fprintf(stderr, "Got %d SQEs, wanted 8\n", i);
		goto err;
	}

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