Files
third_party_liburing/test/sq-full-cpp.cc
Bart Van Assche ebc7ceef54 Add a C++ unit test
Since the liburing header files support C++ compilers, add a C++ unit test.
This helps to verify C++ compatibility of the liburing header files.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-06-28 14:03:56 -06:00

46 lines
711 B
C++

/* 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;
}