Commit Graph

199 Commits

Author SHA1 Message Date
Jens Axboe 7476d1204c Add IOPOLL potential leak test case
Setup ring and issue an IOPOLL read, exit process without reaping
completions.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-09-23 14:42:22 -06:00
Dylan Yudaken 0689e82366 add a defer-taskrun test
Add a test specifically for IORING_SETUP_DEFER_TASKRUN

Signed-off-by: Dylan Yudaken <dylany@fb.com>
Tested-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> # Build
Link: https://lore.kernel.org/r/20220905132258.1858915-7-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-09-05 11:41:24 -06:00
Ankit Kumar 5dda1cd30c test: add io_uring passthrough test
Add a way to test uring passthrough commands, which was added
with 5.19 kernel. This requires nvme-ns character device (/dev/ngXnY)
as filename argument. It runs a combination of read/write tests with
sqthread poll, vectored and non-vectored commands, fixed I/O buffers.

Tested-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
Link: https://lore.kernel.org/r/20220728093327.32580-5-ankit.kumar@samsung.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-07-28 07:07:00 -06:00
Pavel Begunkov 40bdeef165 tests: add tests for zerocopy send and notifications
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/57b1db13da1fb86bcaf8e9a5c93d6d22aef8fc4b.1658748624.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-07-25 09:46:23 -06:00
Pavel Begunkov 723b3c8c40 tests: test IORING_SETUP_SINGLE_ISSUER
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/54af31b0b34fea289dc82ac228ec0cabed408cb6.1658484803.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-07-22 09:20:47 -06:00
Ammar Faizi ea621a9688 Delete src/syscall.c and get back to use __sys_io_uring* functions
Back when I was adding nolibc support for liburing, I added new
wrapper functions for io_uring system calls. They are ____sys_io_uring*
functions (with 4 underscores), all defined as an inline function.

I left __sys_uring* functions (with 2 underscores) live in syscall.c
because I thought it might break the user if we delete them. But it
turned out that I was wrong, no user should use these functions
because we don't export them. This situation is reflected in
liburing.map and liburing.h which don't have those functions.

Do these:

  1) Delete src/syscall.c.
  2) Rename ____sys_io_uring* to __sys_io_uring*.
  3) Fix tests that still depend on libc `errno` for checking
     __sys_io_uring* functions error code.

to:

  1) Reduce the burden of maintaining syscall.c.
  2) Simplify the Makefile, no need extra branch to compile syscall.c
     with a specific condition.
  3) Simplify function naming and kill the confusion of deciding
     using __sys_uring* or ____sys_io_uring* when adding a new test that
     directly calls them. Because now we always use __sys_io_uring*.
     ____sys_io_uring* functions no longer exist.

After this patch, __sys_io_uring* functions now return -errno instead
of -1 when fails.

Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Link: https://lore.kernel.org/r/20220721090443.733104-1-ammarfaizi2@gnuweeb.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-07-21 09:32:28 -06:00
Ammar Faizi 1ce7dce8ca test: Add nolibc test
Test liburing nolibc functionality. The first use case of this test is
to test get_page_size() function as we don't seem to have a test that
tests this path. This is especially important for aarch64 because we
rely on reading /proc/self/auxv rather than hard coding it like what we
do for x86 and x86-64. We may add more nolibc tests in this file in the
future.

Reviewed-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Link: https://lore.kernel.org/r/20220705073920.367794-9-ammar.faizi@intel.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-07-05 08:25:28 -06:00
Dylan Yudaken 883037314f add poll overflow test
Add a test that when CQE overflows, multishot poll doesn't give
out of order completions.

Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220630164918.3958710-7-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-30 14:19:28 -06:00
Dylan Yudaken 927bb020ef add recv-multishot test
add a test for multishot receive functionality

Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220630164918.3958710-6-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-30 14:19:28 -06:00
Jens Axboe e1b6f7697c Enable -O3 for liburing compilation
I use this for testing all the time and have been for ages, let's
just make it the default.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-29 10:22:14 -06:00
Jens Axboe 4a4fe3febf test/sync-cancel: add test case for sync cancelation API
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-29 10:16:39 -06:00
Jens Axboe d2c66b5033 test/fd-pass: add test case for direct descriptor passing
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-29 10:16:16 -06:00
Jens Axboe fd73d30521 test/Makefile: ensure statx is only added once
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-19 12:05:56 -06:00
Jens Axboe ebafb0e343 test/ringbuf-read: add provided ring buffer read test case
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-15 20:17:49 -06:00
Jens Axboe 2b90897b3a Remove IORING_CLOSE_FD_AND_FILE_SLOT
We dropped this from 5.19, prune it from liburing as well for now.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-15 09:54:17 -06:00
Xiaoguang Wang 87de496e03 Let IORING_OP_FILES_UPDATE support to choose fixed file slots
Allocate available direct descriptors instead of having the
application pass free fixed file slots. To use it, pass
IORING_FILE_INDEX_ALLOC to io_uring_prep_files_update(), then
io_uring in kernel will store picked fixed file slots in fd
array and let cqe return the number of slots allocated.

Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Link: https://lore.kernel.org/r/20220530173604.38000-1-xiaoguang.wang@linux.alibaba.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-05-30 16:48:05 -06:00
Jens Axboe 6cadb715ec test/socKet: add socket test case
Tests both normal and direct descriptors, and the latter with
allocation as well.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-05-26 17:36:49 -06:00
Jens Axboe 19cbb0b03c Add basic buffer ring test case
send_recvmsg uses it for actual IO, this one is more about just
testing the various cases for registration and mixing with classic
buffers that should not work.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-05-18 16:26:57 -06:00
Jens Axboe a4252e99d6 Add regression test case for IO submit before exit
Impacts 5.15 and earlier.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-05-18 09:10:42 -06:00
Jens Axboe 0a622c18ca Merge branch 'xattr'
* xattr:
  32-bit build warning cleanups
  test/xattr: don't fail on kernels not supporting the feature
  test/xattr: style fixups
  test/xattr: specify file mode with O_CREAT
  liburing: Add new test program to verify xattr support
  liburing: Add helper functions for fgetxattr and getxattr
  liburing: add helper functions for setxattr and fsetxattr
  liburing: Update io_uring in liburing

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-05-16 09:22:43 -06:00
Jens Axboe e88c123a8f test/open-direct-pick.c: add test case for open direct with alloc
Test case that tests the basic functionality of openat with direct
descriptors and asking io_uring to allocate the descriptors.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-05-14 15:07:19 -06:00
Jens Axboe 038d0bc35f Merge branch 'cancel-fd-all'
* cancel-fd-all:
  test/poll-cancel-all: add async read test case
  test/poll-cancel-all: test IORING_ASYNC_CANCEL_ANY
  io_uring.h: add IORING_ASYNC_CANCEL_ANY
  test/poll-cancel-all: abort test if cancel flags not supported
  test/poll-cancel-all: add test case canceling a subset of pending
  test/poll-cancel-all: test issuing CANCEL_ALL | CANCEL_FD
  liburing.h: add io_uring_prep_cancel_fd()
  io_uring: add new cancel flags
2022-05-14 09:45:21 -06:00
Ammar Faizi c1d712f537 test/Makefile: Sort the test file list alphabetically
Make it easy to manage and find by sorting it alphabetically. Also, add
a comment to remind us to keep it sorted alphabetically.

Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-04-22 15:15:24 -06:00
Ammar Faizi 52dc94adec test/Makefile: Remove .PHONY variable
What we want is a .PHONY build target that depends on runtests-parallel,
not a .PHONY variable. This variable doesn't do anything. Remove it.

Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-04-22 15:15:23 -06:00
Dylan Yudaken a33e908d86 test: add make targets for each test
Add a make target runtests-parallel which can run tests in parallel.
This is very useful to quickly run all the tests locally with
  $ make -j runtests-parallel

Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220422160132.2891927-7-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-04-22 11:18:08 -06:00
Jens Axboe 1f06dc5e3b test/poll-cancel-all: test issuing CANCEL_ALL | CANCEL_FD
Not complete yet, but tests the basic functionality of canceling based
on a file descriptor and canceling all requests pending with just a
single cancelation request.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-04-15 19:44:17 -06:00
Jens Axboe fa74fdb781 test/Makefile: fixup sq-full-cpp target
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-04-03 17:18:30 -06:00
Jens Axboe 4f1b60237e test/Makefile
statx target is now statx.t, make sure it's correct in all_targets.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-04-03 17:17:08 -06:00
Ammar Faizi e2ada03c9d test/Makefile: Append .t to the test binary
When adding a new test, we often forget to add the new test binary to
`.gitignore`. Append `.t` to the test binary filename, this way we can
use a wildcard matching "test/*.t" in `.gitignore` to ignore all
test binary files.

Goals:
  - Make the .gitignore simpler.
  - Avoid the burden of adding a new test to .gitignore.

Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Link: https://lore.kernel.org/r/20220403182200.259937-4-ammarfaizi2@gnuweeb.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-04-03 17:12:50 -06:00
Ammar Faizi 068dbd81a4 test/Makefile: Append -lpthread to LDFLAGS for all tests
Instead of overriding LDFLAGS one by one for tests that need pthread,
append -lpthread to LDFLAGS for all tests. This makes the Makefile
script simpler. It also saves some hassle when we add a new test
that does use pthread.

Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Link: https://lore.kernel.org/r/20220403182200.259937-3-ammarfaizi2@gnuweeb.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-04-03 17:12:50 -06:00
Ammar Faizi 5a5f62524c test: Rename [0-9a-f]-test.c to [0-9a-f].c
Simplify the test filename.

  mv -v test/232c93d07b74-test.c test/232c93d07b74.c
  mv -v test/35fa71a030ca-test.c test/35fa71a030ca.c
  mv -v test/500f9fbadef8-test.c test/500f9fbadef8.c
  mv -v test/7ad0e4b2f83c-test.c test/7ad0e4b2f83c.c
  mv -v test/8a9973408177-test.c test/8a9973408177.c
  mv -v test/917257daa0fe-test.c test/917257daa0fe.c
  mv -v test/a0908ae19763-test.c test/a0908ae19763.c
  mv -v test/a4c0b3decb33-test.c test/a4c0b3decb33.c
  mv -v test/b19062a56726-test.c test/b19062a56726.c
  mv -v test/b5837bd5311d-test.c test/b5837bd5311d.c
  mv -v test/ce593a6c480a-test.c test/ce593a6c480a.c
  mv -v test/d4ae271dfaae-test.c test/d4ae271dfaae.c
  mv -v test/d77a67ed5f27-test.c test/d77a67ed5f27.c
  mv -v test/eeed8b54e0df-test.c test/eeed8b54e0df.c
  mv -v test/fc2a85cb02ef-test.c test/fc2a85cb02ef.c

Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Link: https://lore.kernel.org/r/20220403182200.259937-2-ammarfaizi2@gnuweeb.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-04-03 17:12:50 -06:00
Stefan Roesch c23990ba2a liburing: Add new test program to verify xattr support
Summary:

This adds a new test program to test the xattr support:
- fgetxattr
- fsetxattr
- getxattr
- setxattr

It also includes test cases for failure conditions and
for passing in an invalid sqe. The test case for checking
of invalid SQE, must be enabled by defining
DESTRUCTIVE_TESTING.

Signed-off-by: Stefan Roesch <shr@fb.com>
Link: https://lore.kernel.org/r/20220323154457.3303391-5-shr@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-30 14:44:13 -06:00
Jens Axboe 65555c5e3a test/fixed-reuse: test that linked file slot reuse is correct
If we do:

<open fileX into slot 0>
<open fileY into slot 0><read slot 0><close slot 0>

this should be consistent with not having opened fileX first, and the
read should be satisfied from fileY.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-30 11:33:38 -06:00
Jens Axboe 2b2d0644f0 test/open-direct-link: add test case for linked open+read+close
Test that it works with both LINK and DRAIN.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-29 16:16:58 -06:00
Jens Axboe 9aa940446f Actually wire up recv-msgall-stream test case
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-23 16:45:58 -06:00
Jens Axboe c384902c0a Add test case for recv/recvmsg MSG_WAITALL
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-23 09:41:09 -06:00
Jens Axboe 5243e1d71a test/tty-write-dpoll: add test case for double poll write
Test case for the regression fixed by:

commit 6e295a664efd083ac9a5c1a8130c45be1db0cde7
Author: Jens Axboe <axboe@kernel.dk>
Date:   Tue Mar 22 13:11:28 2022 -0600

    io_uring: fix assuming triggered poll waitqueue is the single poll

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-22 19:39:30 -06:00
Jens Axboe 09f16b06c4 Add regression case for fixed buffers and non-iterator files
A previous fix broke some cases of loop iteration, add a test case
for it.

Link: https://github.com/axboe/liburing/issues/549
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-18 11:40:30 -06:00
Jens Axboe 6d5f856d30 test/drop-submit: test function of IORING_SETUP_SUBMIT_ALL flag
If the ring is created with this flag, then we expect submissions to
continue even if we hit an error in a batch. Check if that is the case
or not.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-10 17:30:18 -07:00
Jens Axboe 7e6faa6a11 test/msg-ring: add test cases for IORING_OP_MSG_RING
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-10 09:27:42 -07:00
Alviro Iskandar Setiawan 473467cf2b test/Makefile: Add liburing.a as a dependency
The test binaries statically link liburing using liburing.a file. When
liburing.a is recompiled, make sure the tests are also recompiled to
ensure changes are applied to the test binary. It makes "make clean"
command optional when making changes.

Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Link: https://lore.kernel.org/r/20220310111231.1713588-4-alviro.iskandar@gnuweeb.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-10 05:13:49 -07:00
Dylan Yudaken f75a6bb839 Test consistent file position updates
read(2)/write(2) and friends support sequential reads without giving an
explicit offset. The result of these should leave the file with an
incremented offset.

Add tests for both read and write to check that io_uring behaves
consistently in these scenarios. Expect that if you queue many
reads/writes, and set the IOSQE_IO_LINK flag, that they will behave
similarly to calling read(2)/write(2) in sequence.

Set IOSQE_ASYNC as well in a set of tests. This exacerbates the problem by
forcing work to happen in different threads to submission.

Also add tests for not setting IOSQE_IO_LINK, but allow the file offset to
progress past the end of the file.

Signed-off-by: Dylan Yudaken <dylany@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-02-23 16:39:19 -07:00
Jens Axboe fa1be17205 test/eventfd-reg.c: add basic test case to exercise reg+unreg
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-02-04 08:52:42 -07:00
Jon Kohler ec0f4c1a71 fix statx configure and build on !CONFIG_HAVE_STATX toolchains
Update configure and test/Makefile, such that if !CONFIG_HAVE_STATX will
not generate statx.c test. Without this patch, liburing fails to compile
on an older toolchain that does not have statx available.

Fixes: #516

Signed-off-by: Jon Kohler <jon@nutanix.com>
2022-01-28 09:36:15 -08:00
Jens Axboe d23efe1a9d Add pollfree test case
This is the syzbot test case, testing if POLLFREE is handled correctly.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-01-14 10:15:14 -07:00
Jens Axboe a2be75b482 Remove getdents support
There are still discussions about the API, and hence the feature will
miss the 5.17 kernel release. As the API is likely to change, remove
the getdents support for now and we can re-add it when it's finalized.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-01-05 12:21:28 -07:00
Jens Axboe 96b08215b7 Add test case for socket read with offset == -1
This should just get ignored by the kernel, so check that it is. This
is fixed by kernel commit:

commit 7b9762a5e8837b92a027d58d396a9d27f6440c36
Author: Jens Axboe <axboe@kernel.dk>
Date:   Wed Dec 22 20:26:56 2021 -0700

    io_uring: zero iocb->ki_pos for stream file types

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-12-23 09:43:40 -07:00
Stefan Roesch e0cdda7e45 liburing: Add test program for getdents call
Add test program for getdents64 call.

Signed-off-by: Stefan Roesch <shr@fb.com>
Link: https://lore.kernel.org/r/20211123180753.1598611-4-shr@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-12-22 07:16:55 -07:00
Jens Axboe 4b78f108fb Add test case for hang condition on exit without cleanup
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-12-02 20:07:52 -07:00
Pavel Begunkov 4d9830f9cf tests: add tests for IOSQE_CQE_SKIP_SUCCESS
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/64a28950287c97b4d5bd11bf288ab6fab5d45b79.1637786880.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-11-24 14:27:47 -07:00