42 Commits

Author SHA1 Message Date
ohci1 4b8f3098a5 update configure info for 2.14
Co-authored-by: Pavel Begunkov<asml.silence@gmail.com>
Co-authored-by: Guillem Jover<guillem@hadrons.org>
Co-authored-by: Jens Axboe<axboe@kernel.dk>
Co-authored-by: Khem Raj<raj.khem@gmail.com>
Co-authored-by: Michael de Lang<kingoipo@gmail.com>
Co-authored-by: David Disseldorp<ddiss@suse.de>
Co-authored-by: Ming Lei<ming.lei@redhat.com>
2026-04-24 09:24:13 +08:00
fangzhiyi18 0ae77b95ef 升级2.7
Signed-off-by: fangzhiyi18 <fangzhiyi1@huawei.com>
2024-10-21 02:53:20 +00:00
Ammar Faizi eeb33bea98 t/connect: Don't use a static port number
Don't use a static port number. It might already be in use, resulting
in a test failure. Use an ephemeral port to make this test reliable.

Cc: Dylan Yudaken <dylany@fb.com>
Cc: Facebook Kernel Team <kernel-team@fb.com>
Cc: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Tested-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Link: https://lore.kernel.org/r/20220902071153.3168814-9-ammar.faizi@intel.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-09-02 05:56:14 -06:00
Caleb Sander b360a23d41 liburing: cache ring sizes and masks
Avoid an additional pointer indirection to ring_mask and ring_entries,
since their values can't change after the ring is created.
The fields kring_mask and kring_entries are no longer needed,
but kept for backwards compatibility since liburing.h exposes them.
They can be removed in a future major release, saving 8 bytes per queue.

Signed-off-by: Caleb Sander <csander@purestorage.com>
2022-08-28 13:24:23 -06:00
Eli Schwartz 4475e75034 tests: more work on updating exit codes to use enum-based status reporting
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Link: https://lore.kernel.org/r/20220706034059.2817423-4-eschwartz93@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-07-06 06:44:52 -06:00
Dylan Yudaken 44e247b9c5 add accept with overflow test
add test to exercise the overflow codepath for multishot accept.
this doesn't actually fail previously, but does at least exerceise
the codepath and ensure that some invariants hold wrt flags and
IORING_CQE_F_MORE.

Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220630164918.3958710-8-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-30 14:19:28 -06:00
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
Hao Xu 993f71a132 test/accept: clean code of accept test
This does three things:
 - change multishot_mask from uint to uint32_t
 - change multishot_mask != UINT_MAX check to ~multishot_mask != 0

The above two avoid compiler and arch influence. Make the logic more robost.

 - other cleaning to make code clearer.

Signed-off-by: Hao Xu <howeyxu@tencent.com>
Link: https://lore.kernel.org/r/20220617143603.179277-4-hao.xu@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-17 08:41:45 -06:00
Hao Xu b5fcfaab46 test/accept: fix minus one error when calculating multishot_mask
We don't need to minus one for the s_fd[i] since the returned cqe.res
is already the fixed file table slot which is indexed from zero.

Fixes: 828b363184 ("test/accept.c: add test for multishot mode accept")
Signed-off-by: Hao Xu <howeyxu@tencent.com>
Link: https://lore.kernel.org/r/20220617143603.179277-3-hao.xu@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-17 08:41:45 -06:00
Donald Hunter 47546655b9 Fix incorrect close in test for multishot accept
This fixes a bug in accept_conn handling in the accept tests that caused it
to incorrectly skip the multishot tests and also lose the warning message
to a closed stdout. This can be seen in the strace output below.

close(1)                                = 0
io_uring_setup(32, { ...
...
write(1, "Fixed Multishot Accept not suppo"..., 47) = -1 EINVAL

Unfortunately this exposes a a bug with gcc -O2 where multishot_mask logic
gets optimized incorrectly and "Fixed Multishot Accept misses events" is
wrongly reported. I am investigating this separately.

Fixes: 828b363184 ("test/accept.c: add test for multishot mode accept")
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/r/20220617143603.179277-2-hao.xu@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-17 08:41:45 -06:00
Jens Axboe 83972042f3 Add io_uring_prep_cancel64()
To keep things consistent between 2.1 and later versions of liburing,
make io_uring_prep_cancel() take a void * pointer again instead of a
__u64 type. Add io_uring_prep_cancel64() that takes a 64-bit type.

Link: https://github.com/axboe/liburing/discussions/601
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-06-15 14:58:58 -06:00
Jens Axboe 268664161e test/accept: don't be too verbose or fail if multishot not available
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-05-22 20:53:39 -06:00
Hao Xu 6c1250831c test/accept.c: test for multishot direct accept with wrong arg
Add a test for multishot direct accept, where don't set the file index
to IORING_FILE_INDEX_ALLOC.

Signed-off-by: Hao Xu <howeyxu@tencent.com>
Link: https://lore.kernel.org/r/20220514143534.59162-6-haoxu.linux@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-05-14 09:15:38 -06:00
Hao Xu 828b363184 test/accept.c: add test for multishot mode accept
Add an test for multishot mode accept

Signed-off-by: Hao Xu <haoxu@tencent.com>
Link: https://lore.kernel.org/r/20220514143534.59162-5-haoxu.linux@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-05-14 09:15:38 -06:00
Hao Xu c1e631310f test/accept.c: close the listen fd at the end of the test
Close the listen fd when it goes to the end, otherwise it may causes
issues for the next tests

Signed-off-by: Hao Xu <howeyxu@tencent.com>
Link: https://lore.kernel.org/r/20220514143534.59162-2-haoxu.linux@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-05-14 09:15:38 -06:00
Dylan Yudaken 7693fe19cb Add test for multiple concurrent accepts
Add tests for accept that queues multiple accepts and then ensures the
correct things happen.

Check that when connections arrive one at a time that only one CQE is
posted (in blocking and nonblocking sockets), as well as make sure that
closing the accept socket & cancellation all work as expected.

This relies on a kernel with [1] for the tests to pass.

[1]: https://lore.kernel.org/io-uring/20220325093755.4123343-1-dylany@fb.com/

Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220325094013.4132496-1-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-25 06:30:57 -06:00
Dylan Yudaken 2832b75063 add tests for nonblocking accept sockets
Add tests for accept sockets with O_NONBLOCK. Add a test for queueing the
accept both before and after connect(), which tests slightly different
code paths. After connect() has always worked, but before required changes
to the kernel.

Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220324143547.2882041-1-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-24 12:10:38 -06:00
Jens Axboe f319ab111d Don't truncate addr fields to 32-bit on 32-bit
For the commands where we use it as a lookup key, then we don't want to
rob 32-bit applications from the potential of using the full 64-bit
type. This includes commands like:

poll_remove, poll_update, prep_cancel

Also provide 64-bit u64 types of the sqe set data and the cqe get data
helpers, along with a define that allows applications to check for the
presence of it.

NOTE: this may trigger compile warnings in applications that
currently use these helpers, which is also why a few test cases had
to get adapted. The fixup is trivial, and the above define can help
applications check if one or the other is the current one.

Link: https://github.com/axboe/liburing/issues/490
Reported-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-12-04 15:57:30 -07:00
Ammar Faizi d7e251c891 test: Fix endianess issue on bind() and connect()
When we call `bind()` or `connect()`, the `addr` and `port` should be
in big endian value representation.

Portability notes:
  - Do not hard code the address with integer like this `0x0100007fU`.
    Instead, use `inet_addr("127.0.0.1")` to ensure portability for
    the machine with different endianess. It's also cleaner and more
    readable to use `inet_addr()` from `#include <arpa/inet.h>`.

  - Use `htons(port_number)` to make sure the port_number is properly
    choosen instead directly assign it with integer (still about
    endianess problem).

This commit fixes endianess issue in these files:
  test/232c93d07b74-test.c
  test/accept-link.c
  test/accept.c
  test/poll-link.c
  test/shutdown.c
  test/socket-rw-eagain.c
  test/socket-rw.c

Fixes: 08bd815170 ("Un-DOSify test/232c93d07b74-test.c")
Fixes: 4bce856d43 ("Improve reliability of poll/accept-link tests")
Fixes: 904989c0f1 ("Add nonblock empty socket read test")
Fixes: 7de6253569 ("test/accept: code reuse cleanup")
Fixes: 5068da320a ("Add IORING_OP_SHUTDOWN test case")
Fixes: 2b52a1be2d ("Moves function calls out of assert().")
Suggested-by: Louvian Lyndal <louvianlyndal@gmail.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-09-27 07:45:03 -06:00
Pavel Begunkov b9d1d712c9 tests: use helpers for direct open/accept
For the test to be less confusing, use helpers in tests that place new
files right into the fixed file table.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/d720255e0861688541efb812318f9423ee01e2a3.1630427247.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-08-31 10:59:37 -06:00
Jens Axboe 9eff8c582c test/{accept,openat2}: use sqe->file_index
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-08-25 11:58:31 -06:00
Pavel Begunkov 9937f31356 tests: test open/accept directly into fixed table
Test a new feature allowing to open/accept directly into io_uring's
fixed table bypassing normal fdtable.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/e4326cd1629f9f3c5db3aee7cd976d99df18aff9.1629560358.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-08-25 11:57:18 -06:00
Jens Axboe db8984ce31 test: use ring creation helpers where appropriate
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-02-24 07:48:36 -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 107b62048e helpers: add io_uring_calloc helper
add io_uring_calloc() helper, and replace
all calloc() with io_uring_calloc() in all tests.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
2021-02-23 14:43:57 +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
Ryan Sharpelletti 2b52a1be2d Moves function calls out of assert().
This change ensures that tests will run properly outside of debug.
2020-10-28 21:07:29 +00:00
Jens Axboe c31e34571e test/accept: fix spurious connect failure
Ensure we close the listen fd before returning.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-09-05 13:30:28 -06:00
Jens Axboe 4b022b4ac9 test/accept: expect non-failure for SQPOLL on newer kernels
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-09-05 12:00:09 -06: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
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 a80dabeabd test/accept: don't allocate send/recv data on the stack
We prep the sqe, but don't submit it. Hence we are at the mercy of
the stack not going away, which it will. This ensures the data sent
is sane.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-12-24 10:25:45 -07:00
Jens Axboe a8f853698f Always use bundled liburing.h for test cases
Don't rely on the systems version, or that the system even has one
installed.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-11-12 12:30:38 -07:00
Jens Axboe c1177124bc test/accept: add test case for lots of pending accepts at exit
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-11-10 21:23:56 -07:00
Jens Axboe 7de6253569 test/accept: code reuse cleanup
Use start_accept_listen() in test() as well.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-11-10 10:09:36 -07:00
Jens Axboe c6aa23edd2 test/accept: add test case for correct -ERESTARTSYS transformation
io_uring needs to translate -ERESTARTSYS into -EINTR.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-11-10 09:49:47 -07:00
Jens Axboe 9fca869f19 Ensure test cases work as non-root always
We have a few where we try to use SQTHREAD, which will fail if the
effective user isn't root. Just skip these tests if we're not root.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-11-10 09:48:47 -07:00
Jens Axboe d974c9fbe6 test/accept: add test to see if we cancel correctly on exit
This will exit with 0 in both the normal and failure case, but
the failure case will leave workers idle once done. We check
for that in runtests.sh now.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-10-24 13:46:58 -06:00
Jens Axboe 6b99855879 test/accept: fix a few errors
- Don't re-init the io_uring
- SQPOLL can fail with -EBADF or -EINVAL, depends on which path the
  sqe takes.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-10-18 11:12:26 -06:00
Jens Axboe a9bb08db3f test/accept: test that we -EINVAL for accept with SQPOLL
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-10-18 08:20:31 -06:00
Jens Axboe f2ee043741 Add simple IORING_OP_ACCEPT test case
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-10-17 17:21:25 -06:00