These are skipped because they are not applicable if files/devices are
provided for a special test run. Note this in the return status.
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
For maintainability and clarity, eschew the use of integer literals in
reporting test statuses. Instead, use a helper enum which contains
various values from the GNU exitcode protocol. Returning 0 or 1 is
obvious, and in the previous commit the ability to read "skip" (77) was
implemented. The final exit status is 99, which indicates some kind of
error in running the test itself.
A partial migration of existing pass/fail values in test sources is
included.
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Trivial memory leak fix.
This commit also adds a new macro helper `ARRAY_SIZE`. Defined as:
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
Signed-off-by: Ammar Faizi <ammarfaizi2@gmail.com>
As brought up in an issue, this makes it confusing as to what could
potentially be liburing functions. Make it clear that these are test
helpers, hence use the t_ prefix for them.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
cleanup: add io_uring_create_file() helper,
and replace create_file() with io_uring_calloc() in tests.
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
As axboe said, Right now a lot of basic stuff is duplicated,
and it makes the tests bigger than they should be.
Here, we try to add helpers.h which will contains various
utilities that tests could use, then that'd help make tests simpler.
In this patch, we just add one helper io_uring_malloc(), which
will call assert() if allocating memory fails.
We will add more helpers in subsequent patches
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Just call it and check that it doesn't hang and returns success.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
If we don't support drain with fsync, that is signalled through the
cqe->res return code, not from submit. Remove the check.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
It is not possible to install barrier.h and compat.h into the top-level
/usr/include directly since they are likely to conflict with other
software. io_uring.h could be confused with the system's kernel header
file.
Put liburing headers into <liburing/*.h> so there is no chance of
conflicts or confusion.
Existing applications continue to build successfully since the location
of <liburing.h> is unchanged. In-tree examples and tests require
modification because src/liburing.h is moved to src/include/liburing.h.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
We have io_uring_get_sqe() on the submission side, yet the completion
side is named _completion. Rename as follows:
io_uring_get_completion() io_uring_peek_cqe()
iO_uring_wait_completion() io_uring_wait_cqe()
This better tells the user what the _get variant does by calling it
_peek instead, and we move to using _cqe() as the postfix instead
of _completion.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
There's a failure case where an application gets a cqe entry, but
the kernel can then overwrite it before the application is done
reading it. This can happen since the io_uring_{get,wait}_completion()
interface both returns a CQE pointer AND increments the ring index.
If the kernel reuses this entry before the applications is done reading
it, the contents may be corrupted.
Remove the CQ head increment from the CQE retrieval, and put it into
a separate helper, io_uring_cqe_seen(). The application must call this
helper when it got a new CQE entry through one of the above calls, and
it's now done reading it.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Also changes the fsync prep helper to require passing in the actual
flag, not just a boolean for fsync vs fdatasync.
Signed-off-by: Jens Axboe <axboe@kernel.dk>