22 Commits

Author SHA1 Message Date
Eli Schwartz dd35f16b1d tests: emit a skip exit code if invoked with additional argv
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>
2022-06-28 10:37:33 -04:00
Eli Schwartz 3467e7ac6d tests: migrate some tests to use enum-based exit codes
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>
2022-06-28 10:37:33 -04:00
Pavel Begunkov f4017e98b5 tests: file create/unlink cleanup
Unlink earlier if possible right after getting an fd, so tests don't
leave files when exited abnormally. Also, improve test file naming in a
couple of cases.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/abbcfa9fa56fde7e740a2c887afef74a779bf36f.1630082134.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-08-27 12:11:20 -06:00
Ammar Faizi 1ab6023040 test/fsync: clean up t_malloc() before return
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>
2021-08-09 18:30:21 +07:00
Jens Axboe d7463a4746 helpers: prefix any helper with t_ instead of io_uring_
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>
2021-02-24 07:12:47 -07:00
Zhiqiang Liu 7679234637 helpers: add io_uring_create_file() helper
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>
2021-02-23 20:10:26 +08:00
Zhiqiang Liu 7bd307c836 tests: add helpers.h to harden the tests
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>
2021-02-23 10:10:18 +08:00
Jens Axboe fd1afc4f2b test/fsync: use new io_uring_prep_sync_file_range() helper
We open coded it before, use the new helper.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-02-17 12:36:40 -07:00
Jens Axboe 6c32e92bb0 test: add potential argument, ignore if unused
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-05-19 17:36:19 -06:00
Pavel Begunkov ff7cda19f8 test/sfr: basic test for sync_file_range
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>
2020-05-01 08:48:25 -06:00
Jens Axboe e502435779 Add SPDX license identifiers
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-02-11 20:34:12 -07:00
Jens Axboe 1468e7dfbb test/fsync: use 'stderr' for errors, and remove bogus EINVAL check
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>
2019-12-04 09:13:34 -07:00
Jeff Moyer e1420b89cd test: fix up dead code bugs
Coverity pointed out some dead code.  Fix it.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-11-12 17:12:51 -07:00
Stefan Hajnoczi c31c7ec4bc src/Makefile: keep private headers in <liburing/*.h>
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>
2019-07-24 09:11:44 -06:00
Jens Axboe b422aa11cc test/fsync: use io_uring_sqe_set_flags()
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-27 14:57:04 -06:00
Jens Axboe ce8e2bc298 Update tests for 'sqe submit always posts a cqe'
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-30 14:50:36 -06:00
Jens Axboe 39e0ebd4fc Rename completion helpers
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>
2019-04-18 08:38:08 -06:00
Jens Axboe 76b61ebf1b Add io_uring_cqe_seen()
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>
2019-04-17 09:42:23 -06:00
Jens Axboe 093e902c28 test/fsync: error out if we submit less than we wanted
This failure is expected on kernels that don't support the DRAIN
primitive.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-11 09:00:47 -06:00
Jens Axboe 9864409788 test/fsync: update for IOSQE_IO_DRAIN approach
I generalized the barrier flag to be applicable to all commands, so
let's drop the fsync special flag.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-10 21:56:54 -06:00
Jens Axboe 61c27f73f8 Add barrier fsync test case
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>
2019-04-06 21:50:15 -06:00
Jens Axboe 6726376f32 test/fsync: add simple fsync tester
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-08 21:02:00 -07:00