polyphony 0.94 → 0.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +3 -3
- data/.github/workflows/test_io_uring.yml +4 -4
- data/.gitignore +3 -3
- data/CHANGELOG.md +19 -0
- data/docs/api-reference/fiber.md +2 -2
- data/docs/api-reference/object.md +3 -3
- data/docs/main-concepts/exception-handling.md +2 -2
- data/examples/adapters/redis_blpop.rb +4 -3
- data/examples/adapters/redis_channels.rb +16 -7
- data/examples/core/await.rb +1 -1
- data/examples/io/readline.rb +19 -0
- data/ext/polyphony/backend_common.c +25 -3
- data/ext/polyphony/backend_io_uring.c +18 -16
- data/ext/polyphony/backend_libev.c +2 -2
- data/ext/polyphony/event.c +1 -1
- data/ext/polyphony/extconf.rb +5 -3
- data/ext/polyphony/fiber.c +5 -13
- data/ext/polyphony/io_extensions.c +1 -1
- data/ext/polyphony/pipe.c +1 -1
- data/ext/polyphony/polyphony.c +1 -1
- data/ext/polyphony/polyphony_ext.c +1 -1
- data/ext/polyphony/queue.c +1 -1
- data/ext/polyphony/ring_buffer.c +1 -0
- data/ext/polyphony/socket_extensions.c +1 -1
- data/ext/polyphony/thread.c +1 -1
- data/lib/polyphony/adapters/readline.rb +6 -4
- data/lib/polyphony/adapters/redis.rb +28 -87
- data/lib/polyphony/core/channel.rb +15 -0
- data/lib/polyphony/core/sync.rb +4 -0
- data/lib/polyphony/debugger.rb +2 -2
- data/lib/polyphony/extensions/socket.rb +2 -0
- data/lib/polyphony/version.rb +1 -1
- data/lib/polyphony.rb +4 -0
- data/polyphony.gemspec +10 -10
- data/test/helper.rb +0 -5
- data/test/test_backend.rb +5 -1
- data/test/test_enumerator.rb +46 -0
- data/test/test_ext.rb +63 -0
- data/test/test_io.rb +241 -216
- data/test/test_socket.rb +1 -1
- data/test/test_thread_pool.rb +5 -5
- data/vendor/liburing/.github/workflows/build.yml +51 -5
- data/vendor/liburing/.github/workflows/shellcheck.yml +1 -1
- data/vendor/liburing/.gitignore +6 -123
- data/vendor/liburing/CHANGELOG +35 -0
- data/vendor/liburing/CITATION.cff +11 -0
- data/vendor/liburing/LICENSE +16 -3
- data/vendor/liburing/Makefile +3 -1
- data/vendor/liburing/Makefile.common +1 -0
- data/vendor/liburing/README +14 -2
- data/vendor/liburing/SECURITY.md +6 -0
- data/vendor/liburing/configure +16 -15
- data/vendor/liburing/examples/Makefile +4 -1
- data/vendor/liburing/examples/io_uring-udp.c +395 -0
- data/vendor/liburing/examples/poll-bench.c +101 -0
- data/vendor/liburing/examples/send-zerocopy.c +339 -0
- data/vendor/liburing/liburing.spec +1 -1
- data/vendor/liburing/man/io_uring.7 +38 -11
- data/vendor/liburing/man/io_uring_buf_ring_add.3 +53 -0
- data/vendor/liburing/man/io_uring_buf_ring_advance.3 +31 -0
- data/vendor/liburing/man/io_uring_buf_ring_cq_advance.3 +41 -0
- data/vendor/liburing/man/io_uring_buf_ring_init.3 +30 -0
- data/vendor/liburing/man/io_uring_buf_ring_mask.3 +27 -0
- data/vendor/liburing/man/io_uring_cq_advance.3 +29 -15
- data/vendor/liburing/man/io_uring_cq_has_overflow.3 +25 -0
- data/vendor/liburing/man/io_uring_cq_ready.3 +9 -8
- data/vendor/liburing/man/io_uring_cqe_get_data.3 +32 -13
- data/vendor/liburing/man/io_uring_cqe_get_data64.3 +1 -0
- data/vendor/liburing/man/io_uring_cqe_seen.3 +22 -12
- data/vendor/liburing/man/io_uring_enter.2 +249 -32
- data/vendor/liburing/man/io_uring_enter2.2 +1 -0
- data/vendor/liburing/man/io_uring_free_probe.3 +11 -8
- data/vendor/liburing/man/io_uring_get_events.3 +33 -0
- data/vendor/liburing/man/io_uring_get_probe.3 +9 -8
- data/vendor/liburing/man/io_uring_get_sqe.3 +29 -10
- data/vendor/liburing/man/io_uring_opcode_supported.3 +11 -10
- data/vendor/liburing/man/io_uring_peek_cqe.3 +38 -0
- data/vendor/liburing/man/io_uring_prep_accept.3 +197 -0
- data/vendor/liburing/man/io_uring_prep_accept_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_cancel.3 +118 -0
- data/vendor/liburing/man/io_uring_prep_cancel64.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_close.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_close_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_connect.3 +66 -0
- data/vendor/liburing/man/io_uring_prep_fadvise.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_fallocate.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_files_update.3 +92 -0
- data/vendor/liburing/man/io_uring_prep_fsync.3 +70 -0
- data/vendor/liburing/man/io_uring_prep_link.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_linkat.3 +91 -0
- data/vendor/liburing/man/io_uring_prep_madvise.3 +56 -0
- data/vendor/liburing/man/io_uring_prep_mkdir.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_mkdirat.3 +83 -0
- data/vendor/liburing/man/io_uring_prep_msg_ring.3 +39 -25
- data/vendor/liburing/man/io_uring_prep_multishot_accept.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_multishot_accept_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_nop.3 +28 -0
- data/vendor/liburing/man/io_uring_prep_openat.3 +117 -0
- data/vendor/liburing/man/io_uring_prep_openat2.3 +117 -0
- data/vendor/liburing/man/io_uring_prep_openat2_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_openat_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_poll_add.3 +72 -0
- data/vendor/liburing/man/io_uring_prep_poll_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_poll_remove.3 +55 -0
- data/vendor/liburing/man/io_uring_prep_poll_update.3 +89 -0
- data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +131 -0
- data/vendor/liburing/man/io_uring_prep_read.3 +33 -14
- data/vendor/liburing/man/io_uring_prep_read_fixed.3 +39 -21
- data/vendor/liburing/man/io_uring_prep_readv.3 +49 -15
- data/vendor/liburing/man/io_uring_prep_readv2.3 +49 -17
- data/vendor/liburing/man/io_uring_prep_recv.3 +105 -0
- data/vendor/liburing/man/io_uring_prep_recv_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_recvmsg.3 +124 -0
- data/vendor/liburing/man/io_uring_prep_recvmsg_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_remove_buffers.3 +52 -0
- data/vendor/liburing/man/io_uring_prep_rename.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_renameat.3 +96 -0
- data/vendor/liburing/man/io_uring_prep_send.3 +57 -0
- data/vendor/liburing/man/io_uring_prep_send_zc.3 +64 -0
- data/vendor/liburing/man/io_uring_prep_sendmsg.3 +69 -0
- data/vendor/liburing/man/io_uring_prep_shutdown.3 +53 -0
- data/vendor/liburing/man/io_uring_prep_socket.3 +118 -0
- data/vendor/liburing/man/io_uring_prep_socket_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_socket_direct_alloc.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_splice.3 +80 -0
- data/vendor/liburing/man/io_uring_prep_statx.3 +74 -0
- data/vendor/liburing/man/io_uring_prep_symlink.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_symlinkat.3 +85 -0
- data/vendor/liburing/man/io_uring_prep_sync_file_range.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_tee.3 +74 -0
- data/vendor/liburing/man/io_uring_prep_timeout.3 +95 -0
- data/vendor/liburing/man/io_uring_prep_timeout_remove.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_timeout_update.3 +98 -0
- data/vendor/liburing/man/io_uring_prep_unlink.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_unlinkat.3 +82 -0
- data/vendor/liburing/man/io_uring_prep_write.3 +32 -15
- data/vendor/liburing/man/io_uring_prep_write_fixed.3 +39 -21
- data/vendor/liburing/man/io_uring_prep_writev.3 +50 -16
- data/vendor/liburing/man/io_uring_prep_writev2.3 +50 -17
- data/vendor/liburing/man/io_uring_queue_exit.3 +3 -4
- data/vendor/liburing/man/io_uring_queue_init.3 +58 -13
- data/vendor/liburing/man/io_uring_queue_init_params.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_cmsg_firsthdr.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_cmsg_nexthdr.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_name.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_out.3 +78 -0
- data/vendor/liburing/man/io_uring_recvmsg_payload.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_payload_length.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_validate.3 +1 -0
- data/vendor/liburing/man/io_uring_register.2 +153 -13
- data/vendor/liburing/man/io_uring_register_buf_ring.3 +140 -0
- data/vendor/liburing/man/io_uring_register_buffers.3 +32 -12
- data/vendor/liburing/man/io_uring_register_eventfd.3 +51 -0
- data/vendor/liburing/man/io_uring_register_eventfd_async.3 +1 -0
- data/vendor/liburing/man/io_uring_register_file_alloc_range.3 +52 -0
- data/vendor/liburing/man/io_uring_register_files.3 +33 -11
- data/vendor/liburing/man/io_uring_register_files_sparse.3 +1 -0
- data/vendor/liburing/man/io_uring_register_iowq_aff.3 +61 -0
- data/vendor/liburing/man/io_uring_register_iowq_max_workers.3 +71 -0
- data/vendor/liburing/man/io_uring_register_ring_fd.3 +49 -0
- data/vendor/liburing/man/io_uring_register_sync_cancel.3 +71 -0
- data/vendor/liburing/man/io_uring_setup.2 +119 -13
- data/vendor/liburing/man/io_uring_sq_ready.3 +14 -8
- data/vendor/liburing/man/io_uring_sq_space_left.3 +9 -9
- data/vendor/liburing/man/io_uring_sqe_set_data.3 +29 -11
- data/vendor/liburing/man/io_uring_sqe_set_data64.3 +1 -0
- data/vendor/liburing/man/io_uring_sqe_set_flags.3 +38 -11
- data/vendor/liburing/man/io_uring_sqring_wait.3 +13 -9
- data/vendor/liburing/man/io_uring_submit.3 +29 -12
- data/vendor/liburing/man/io_uring_submit_and_get_events.3 +31 -0
- data/vendor/liburing/man/io_uring_submit_and_wait.3 +16 -12
- data/vendor/liburing/man/io_uring_submit_and_wait_timeout.3 +30 -23
- data/vendor/liburing/man/io_uring_unregister_buf_ring.3 +30 -0
- data/vendor/liburing/man/io_uring_unregister_buffers.3 +11 -10
- data/vendor/liburing/man/io_uring_unregister_eventfd.3 +1 -0
- data/vendor/liburing/man/io_uring_unregister_files.3 +11 -10
- data/vendor/liburing/man/io_uring_unregister_iowq_aff.3 +1 -0
- data/vendor/liburing/man/io_uring_unregister_ring_fd.3 +32 -0
- data/vendor/liburing/man/io_uring_wait_cqe.3 +19 -12
- data/vendor/liburing/man/io_uring_wait_cqe_nr.3 +21 -14
- data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +27 -13
- data/vendor/liburing/man/io_uring_wait_cqes.3 +24 -14
- data/vendor/liburing/src/Makefile +8 -7
- data/vendor/liburing/src/arch/aarch64/lib.h +48 -0
- data/vendor/liburing/src/arch/aarch64/syscall.h +0 -4
- data/vendor/liburing/src/arch/generic/lib.h +0 -4
- data/vendor/liburing/src/arch/generic/syscall.h +29 -16
- data/vendor/liburing/src/arch/syscall-defs.h +41 -14
- data/vendor/liburing/src/arch/x86/lib.h +0 -21
- data/vendor/liburing/src/arch/x86/syscall.h +146 -10
- data/vendor/liburing/src/include/liburing/io_uring.h +245 -5
- data/vendor/liburing/src/include/liburing.h +468 -35
- data/vendor/liburing/src/int_flags.h +1 -0
- data/vendor/liburing/src/lib.h +20 -16
- data/vendor/liburing/src/liburing.map +16 -0
- data/vendor/liburing/src/nolibc.c +1 -1
- data/vendor/liburing/src/queue.c +87 -55
- data/vendor/liburing/src/register.c +129 -53
- data/vendor/liburing/src/setup.c +65 -28
- data/vendor/liburing/src/syscall.c +14 -32
- data/vendor/liburing/src/syscall.h +12 -64
- data/vendor/liburing/test/{232c93d07b74-test.c → 232c93d07b74.c} +8 -9
- data/vendor/liburing/test/{35fa71a030ca-test.c → 35fa71a030ca.c} +4 -4
- data/vendor/liburing/test/{500f9fbadef8-test.c → 500f9fbadef8.c} +7 -7
- data/vendor/liburing/test/{7ad0e4b2f83c-test.c → 7ad0e4b2f83c.c} +8 -7
- data/vendor/liburing/test/{8a9973408177-test.c → 8a9973408177.c} +4 -3
- data/vendor/liburing/test/{917257daa0fe-test.c → 917257daa0fe.c} +3 -2
- data/vendor/liburing/test/Makefile +60 -62
- data/vendor/liburing/test/{a0908ae19763-test.c → a0908ae19763.c} +3 -2
- data/vendor/liburing/test/{a4c0b3decb33-test.c → a4c0b3decb33.c} +3 -2
- data/vendor/liburing/test/accept-link.c +5 -4
- data/vendor/liburing/test/accept-reuse.c +17 -16
- data/vendor/liburing/test/accept-test.c +14 -10
- data/vendor/liburing/test/accept.c +529 -107
- data/vendor/liburing/test/across-fork.c +7 -6
- data/vendor/liburing/test/{b19062a56726-test.c → b19062a56726.c} +3 -2
- data/vendor/liburing/test/{b5837bd5311d-test.c → b5837bd5311d.c} +10 -9
- data/vendor/liburing/test/buf-ring.c +420 -0
- data/vendor/liburing/test/{ce593a6c480a-test.c → ce593a6c480a.c} +15 -12
- data/vendor/liburing/test/connect.c +8 -7
- data/vendor/liburing/test/cq-full.c +5 -4
- data/vendor/liburing/test/cq-overflow.c +242 -12
- data/vendor/liburing/test/cq-peek-batch.c +5 -4
- data/vendor/liburing/test/cq-ready.c +5 -4
- data/vendor/liburing/test/cq-size.c +5 -4
- data/vendor/liburing/test/{d4ae271dfaae-test.c → d4ae271dfaae.c} +2 -2
- data/vendor/liburing/test/{d77a67ed5f27-test.c → d77a67ed5f27.c} +6 -6
- data/vendor/liburing/test/defer-taskrun.c +336 -0
- data/vendor/liburing/test/defer.c +26 -14
- data/vendor/liburing/test/double-poll-crash.c +15 -5
- data/vendor/liburing/test/drop-submit.c +5 -3
- data/vendor/liburing/test/{eeed8b54e0df-test.c → eeed8b54e0df.c} +7 -6
- data/vendor/liburing/test/empty-eownerdead.c +4 -4
- data/vendor/liburing/test/eventfd-disable.c +48 -20
- data/vendor/liburing/test/eventfd-reg.c +10 -9
- data/vendor/liburing/test/eventfd-ring.c +13 -12
- data/vendor/liburing/test/eventfd.c +13 -12
- data/vendor/liburing/test/exit-no-cleanup.c +1 -1
- data/vendor/liburing/test/fadvise.c +3 -3
- data/vendor/liburing/test/fallocate.c +16 -9
- data/vendor/liburing/test/{fc2a85cb02ef-test.c → fc2a85cb02ef.c} +4 -3
- data/vendor/liburing/test/fd-pass.c +187 -0
- data/vendor/liburing/test/file-register.c +302 -36
- data/vendor/liburing/test/file-update.c +62 -4
- data/vendor/liburing/test/file-verify.c +6 -2
- data/vendor/liburing/test/files-exit-hang-poll.c +11 -25
- data/vendor/liburing/test/files-exit-hang-timeout.c +13 -10
- data/vendor/liburing/test/fixed-buf-iter.c +115 -0
- data/vendor/liburing/test/fixed-link.c +10 -10
- data/vendor/liburing/test/fixed-reuse.c +160 -0
- data/vendor/liburing/test/fpos.c +6 -3
- data/vendor/liburing/test/fsync.c +3 -3
- data/vendor/liburing/test/hardlink.c +10 -6
- data/vendor/liburing/test/helpers.c +137 -4
- data/vendor/liburing/test/helpers.h +27 -0
- data/vendor/liburing/test/io-cancel.c +16 -11
- data/vendor/liburing/test/io_uring_enter.c +46 -81
- data/vendor/liburing/test/io_uring_passthrough.c +451 -0
- data/vendor/liburing/test/io_uring_register.c +59 -229
- data/vendor/liburing/test/io_uring_setup.c +24 -29
- data/vendor/liburing/test/iopoll-leak.c +85 -0
- data/vendor/liburing/test/iopoll.c +16 -9
- data/vendor/liburing/test/lfs-openat-write.c +3 -1
- data/vendor/liburing/test/link-timeout.c +4 -3
- data/vendor/liburing/test/link.c +8 -7
- data/vendor/liburing/test/madvise.c +2 -2
- data/vendor/liburing/test/mkdir.c +9 -5
- data/vendor/liburing/test/msg-ring.c +46 -20
- data/vendor/liburing/test/multicqes_drain.c +51 -12
- data/vendor/liburing/test/nolibc.c +60 -0
- data/vendor/liburing/test/nop.c +78 -16
- data/vendor/liburing/test/nvme.h +168 -0
- data/vendor/liburing/test/open-direct-link.c +188 -0
- data/vendor/liburing/test/open-direct-pick.c +180 -0
- data/vendor/liburing/test/openat2.c +3 -3
- data/vendor/liburing/test/poll-cancel-all.c +472 -0
- data/vendor/liburing/test/poll-link.c +9 -18
- data/vendor/liburing/test/poll-mshot-overflow.c +162 -0
- data/vendor/liburing/test/poll-mshot-update.c +83 -33
- data/vendor/liburing/test/pollfree.c +2 -2
- data/vendor/liburing/test/read-before-exit.c +112 -0
- data/vendor/liburing/test/read-write.c +83 -1
- data/vendor/liburing/test/recv-msgall-stream.c +398 -0
- data/vendor/liburing/test/recv-msgall.c +265 -0
- data/vendor/liburing/test/recv-multishot.c +505 -0
- data/vendor/liburing/test/rename.c +2 -5
- data/vendor/liburing/test/ring-leak.c +97 -0
- data/vendor/liburing/test/ringbuf-read.c +200 -0
- data/vendor/liburing/test/rsrc_tags.c +25 -13
- data/vendor/liburing/test/runtests-quiet.sh +11 -0
- data/vendor/liburing/test/runtests.sh +18 -20
- data/vendor/liburing/test/rw_merge_test.c +3 -2
- data/vendor/liburing/test/send-zerocopy.c +684 -0
- data/vendor/liburing/test/send_recv.c +49 -2
- data/vendor/liburing/test/send_recvmsg.c +165 -55
- data/vendor/liburing/test/shutdown.c +3 -4
- data/vendor/liburing/test/sigfd-deadlock.c +22 -8
- data/vendor/liburing/test/single-issuer.c +171 -0
- data/vendor/liburing/test/socket-rw-eagain.c +2 -12
- data/vendor/liburing/test/socket-rw-offset.c +2 -11
- data/vendor/liburing/test/socket-rw.c +2 -11
- data/vendor/liburing/test/socket.c +409 -0
- data/vendor/liburing/test/sq-poll-dup.c +1 -1
- data/vendor/liburing/test/sq-poll-share.c +1 -1
- data/vendor/liburing/test/statx.c +2 -2
- data/vendor/liburing/test/submit-and-wait.c +108 -0
- data/vendor/liburing/test/submit-link-fail.c +5 -3
- data/vendor/liburing/test/submit-reuse.c +0 -2
- data/vendor/liburing/test/sync-cancel.c +235 -0
- data/vendor/liburing/test/test.h +35 -0
- data/vendor/liburing/test/timeout-overflow.c +11 -11
- data/vendor/liburing/test/timeout.c +7 -7
- data/vendor/liburing/test/tty-write-dpoll.c +60 -0
- data/vendor/liburing/test/unlink.c +1 -1
- data/vendor/liburing/test/xattr.c +425 -0
- metadata +160 -52
- data/Gemfile.lock +0 -78
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
#include <unistd.h>
|
|
16
16
|
|
|
17
17
|
#include "liburing.h"
|
|
18
|
+
#include "helpers.h"
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
struct forktestmem
|
|
@@ -141,13 +142,13 @@ int main(int argc, char *argv[])
|
|
|
141
142
|
pid_t p;
|
|
142
143
|
|
|
143
144
|
if (argc > 1)
|
|
144
|
-
return
|
|
145
|
+
return T_EXIT_SKIP;
|
|
145
146
|
|
|
146
147
|
shmem = mmap(0, sizeof(struct forktestmem), PROT_READ|PROT_WRITE,
|
|
147
148
|
MAP_SHARED | MAP_ANONYMOUS, 0, 0);
|
|
148
149
|
if (!shmem) {
|
|
149
150
|
fprintf(stderr, "mmap failed\n");
|
|
150
|
-
exit(
|
|
151
|
+
exit(T_EXIT_FAIL);
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
pthread_barrierattr_init(&shmem->barrierattr);
|
|
@@ -157,12 +158,12 @@ int main(int argc, char *argv[])
|
|
|
157
158
|
ret = io_uring_queue_init(10, &shmem->ring, 0);
|
|
158
159
|
if (ret < 0) {
|
|
159
160
|
fprintf(stderr, "queue init failed\n");
|
|
160
|
-
exit(
|
|
161
|
+
exit(T_EXIT_FAIL);
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
if (mkdtemp(tmpdir) == NULL) {
|
|
164
165
|
fprintf(stderr, "temp directory creation failed\n");
|
|
165
|
-
exit(
|
|
166
|
+
exit(T_EXIT_FAIL);
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
shared_fd = open_tempfile(tmpdir, "shared");
|
|
@@ -275,9 +276,9 @@ int main(int argc, char *argv[])
|
|
|
275
276
|
goto errcleanup;
|
|
276
277
|
|
|
277
278
|
cleanup(tmpdir);
|
|
278
|
-
exit(
|
|
279
|
+
exit(T_EXIT_PASS);
|
|
279
280
|
|
|
280
281
|
errcleanup:
|
|
281
282
|
cleanup(tmpdir);
|
|
282
|
-
exit(
|
|
283
|
+
exit(T_EXIT_FAIL);
|
|
283
284
|
}
|
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
#include <unistd.h>
|
|
12
12
|
|
|
13
13
|
#include "liburing.h"
|
|
14
|
+
#include "helpers.h"
|
|
14
15
|
#include "../src/syscall.h"
|
|
15
16
|
|
|
16
17
|
int main(int argc, char *argv[])
|
|
17
18
|
{
|
|
18
19
|
if (argc > 1)
|
|
19
|
-
return
|
|
20
|
+
return T_EXIT_SKIP;
|
|
20
21
|
|
|
21
22
|
mmap((void *) 0x20000000, 0x1000000, 3, 0x32, -1, 0);
|
|
22
23
|
|
|
@@ -49,5 +50,5 @@ int main(int argc, char *argv[])
|
|
|
49
50
|
*(uint32_t*)0x2000026c = 0;
|
|
50
51
|
*(uint64_t*)0x20000270 = 0;
|
|
51
52
|
__sys_io_uring_setup(0xc9f, (struct io_uring_params *) 0x20000200);
|
|
52
|
-
return
|
|
53
|
+
return T_EXIT_PASS;
|
|
53
54
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
#include <stdio.h>
|
|
6
6
|
#include "liburing.h"
|
|
7
|
+
#include "helpers.h"
|
|
7
8
|
|
|
8
9
|
int main(int argc, char *argv[])
|
|
9
10
|
{
|
|
@@ -17,11 +18,11 @@ int main(int argc, char *argv[])
|
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
if (argc > 1)
|
|
20
|
-
return
|
|
21
|
+
return T_EXIT_SKIP;
|
|
21
22
|
|
|
22
23
|
if (io_uring_queue_init(4, &ring, 0) != 0) {
|
|
23
24
|
fprintf(stderr, "ring setup failed\n");
|
|
24
|
-
return
|
|
25
|
+
return T_EXIT_FAIL;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
/*
|
|
@@ -31,14 +32,14 @@ int main(int argc, char *argv[])
|
|
|
31
32
|
sqe = io_uring_get_sqe(&ring);
|
|
32
33
|
if (!sqe) {
|
|
33
34
|
fprintf(stderr, "get sqe failed\n");
|
|
34
|
-
return
|
|
35
|
+
return T_EXIT_FAIL;
|
|
35
36
|
}
|
|
36
37
|
io_uring_prep_timeout(sqe, &ts, (unsigned)-1, 0);
|
|
37
38
|
|
|
38
39
|
ret = io_uring_submit(&ring);
|
|
39
40
|
if (ret != 1) {
|
|
40
41
|
fprintf(stderr, "Got submit %d, expected 1\n", ret);
|
|
41
|
-
return
|
|
42
|
+
return T_EXIT_FAIL;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
/*
|
|
@@ -50,28 +51,28 @@ int main(int argc, char *argv[])
|
|
|
50
51
|
sqe = io_uring_get_sqe(&ring);
|
|
51
52
|
if (!sqe) {
|
|
52
53
|
fprintf(stderr, "get sqe failed\n");
|
|
53
|
-
return
|
|
54
|
+
return T_EXIT_FAIL;
|
|
54
55
|
}
|
|
55
56
|
io_uring_prep_nop(sqe);
|
|
56
57
|
|
|
57
58
|
ret = io_uring_submit_and_wait(&ring, 2);
|
|
58
59
|
if (ret != 1) {
|
|
59
60
|
fprintf(stderr, "Got submit %d, expected 1\n", ret);
|
|
60
|
-
return
|
|
61
|
+
return T_EXIT_FAIL;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
if (io_uring_peek_cqe(&ring, &cqe) != 0) {
|
|
64
65
|
fprintf(stderr, "Unable to peek cqe!\n");
|
|
65
|
-
return
|
|
66
|
+
return T_EXIT_FAIL;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
io_uring_cqe_seen(&ring, cqe);
|
|
69
70
|
|
|
70
71
|
if (io_uring_peek_cqe(&ring, &cqe) != 0) {
|
|
71
72
|
fprintf(stderr, "Unable to peek cqe!\n");
|
|
72
|
-
return
|
|
73
|
+
return T_EXIT_FAIL;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
io_uring_queue_exit(&ring);
|
|
76
|
-
return
|
|
77
|
+
return T_EXIT_PASS;
|
|
77
78
|
}
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Description: run various shared buffer ring sanity checks
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
#include <errno.h>
|
|
7
|
+
#include <stdio.h>
|
|
8
|
+
#include <unistd.h>
|
|
9
|
+
#include <stdlib.h>
|
|
10
|
+
#include <string.h>
|
|
11
|
+
#include <fcntl.h>
|
|
12
|
+
|
|
13
|
+
#include "liburing.h"
|
|
14
|
+
#include "helpers.h"
|
|
15
|
+
|
|
16
|
+
static int no_buf_ring;
|
|
17
|
+
|
|
18
|
+
/* test trying to register classic group when ring group exists */
|
|
19
|
+
static int test_mixed_reg2(int bgid)
|
|
20
|
+
{
|
|
21
|
+
struct io_uring_buf_reg reg = { };
|
|
22
|
+
struct io_uring_sqe *sqe;
|
|
23
|
+
struct io_uring_cqe *cqe;
|
|
24
|
+
struct io_uring ring;
|
|
25
|
+
void *ptr, *bufs;
|
|
26
|
+
int ret;
|
|
27
|
+
|
|
28
|
+
ret = t_create_ring(1, &ring, 0);
|
|
29
|
+
if (ret == T_SETUP_SKIP)
|
|
30
|
+
return 0;
|
|
31
|
+
else if (ret != T_SETUP_OK)
|
|
32
|
+
return 1;
|
|
33
|
+
|
|
34
|
+
if (posix_memalign(&ptr, 4096, 4096))
|
|
35
|
+
return 1;
|
|
36
|
+
|
|
37
|
+
reg.ring_addr = (unsigned long) ptr;
|
|
38
|
+
reg.ring_entries = 32;
|
|
39
|
+
reg.bgid = bgid;
|
|
40
|
+
|
|
41
|
+
ret = io_uring_register_buf_ring(&ring, ®, 0);
|
|
42
|
+
if (ret) {
|
|
43
|
+
fprintf(stderr, "Buffer ring register failed %d\n", ret);
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* provide classic buffers, group 1 */
|
|
48
|
+
bufs = malloc(8 * 1024);
|
|
49
|
+
sqe = io_uring_get_sqe(&ring);
|
|
50
|
+
io_uring_prep_provide_buffers(sqe, bufs, 1024, 8, bgid, 0);
|
|
51
|
+
io_uring_submit(&ring);
|
|
52
|
+
ret = io_uring_wait_cqe(&ring, &cqe);
|
|
53
|
+
if (ret) {
|
|
54
|
+
fprintf(stderr, "wait_cqe %d\n", ret);
|
|
55
|
+
return 1;
|
|
56
|
+
}
|
|
57
|
+
if (cqe->res != -EEXIST && cqe->res != -EINVAL) {
|
|
58
|
+
fprintf(stderr, "cqe res %d\n", cqe->res);
|
|
59
|
+
return 1;
|
|
60
|
+
}
|
|
61
|
+
io_uring_cqe_seen(&ring, cqe);
|
|
62
|
+
|
|
63
|
+
io_uring_queue_exit(&ring);
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* test trying to register ring group when classic group exists */
|
|
68
|
+
static int test_mixed_reg(int bgid)
|
|
69
|
+
{
|
|
70
|
+
struct io_uring_buf_reg reg = { };
|
|
71
|
+
struct io_uring_sqe *sqe;
|
|
72
|
+
struct io_uring_cqe *cqe;
|
|
73
|
+
struct io_uring ring;
|
|
74
|
+
void *ptr, *bufs;
|
|
75
|
+
int ret;
|
|
76
|
+
|
|
77
|
+
ret = t_create_ring(1, &ring, 0);
|
|
78
|
+
if (ret == T_SETUP_SKIP)
|
|
79
|
+
return 0;
|
|
80
|
+
else if (ret != T_SETUP_OK)
|
|
81
|
+
return 1;
|
|
82
|
+
|
|
83
|
+
/* provide classic buffers, group 1 */
|
|
84
|
+
bufs = malloc(8 * 1024);
|
|
85
|
+
sqe = io_uring_get_sqe(&ring);
|
|
86
|
+
io_uring_prep_provide_buffers(sqe, bufs, 1024, 8, bgid, 0);
|
|
87
|
+
io_uring_submit(&ring);
|
|
88
|
+
ret = io_uring_wait_cqe(&ring, &cqe);
|
|
89
|
+
if (ret) {
|
|
90
|
+
fprintf(stderr, "wait_cqe %d\n", ret);
|
|
91
|
+
return 1;
|
|
92
|
+
}
|
|
93
|
+
if (cqe->res) {
|
|
94
|
+
fprintf(stderr, "cqe res %d\n", cqe->res);
|
|
95
|
+
return 1;
|
|
96
|
+
}
|
|
97
|
+
io_uring_cqe_seen(&ring, cqe);
|
|
98
|
+
|
|
99
|
+
if (posix_memalign(&ptr, 4096, 4096))
|
|
100
|
+
return 1;
|
|
101
|
+
|
|
102
|
+
reg.ring_addr = (unsigned long) ptr;
|
|
103
|
+
reg.ring_entries = 32;
|
|
104
|
+
reg.bgid = bgid;
|
|
105
|
+
|
|
106
|
+
ret = io_uring_register_buf_ring(&ring, ®, 0);
|
|
107
|
+
if (ret != -EEXIST) {
|
|
108
|
+
fprintf(stderr, "Buffer ring register failed %d\n", ret);
|
|
109
|
+
return 1;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
io_uring_queue_exit(&ring);
|
|
113
|
+
return 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static int test_double_reg_unreg(int bgid)
|
|
117
|
+
{
|
|
118
|
+
struct io_uring_buf_reg reg = { };
|
|
119
|
+
struct io_uring ring;
|
|
120
|
+
void *ptr;
|
|
121
|
+
int ret;
|
|
122
|
+
|
|
123
|
+
ret = t_create_ring(1, &ring, 0);
|
|
124
|
+
if (ret == T_SETUP_SKIP)
|
|
125
|
+
return 0;
|
|
126
|
+
else if (ret != T_SETUP_OK)
|
|
127
|
+
return 1;
|
|
128
|
+
|
|
129
|
+
if (posix_memalign(&ptr, 4096, 4096))
|
|
130
|
+
return 1;
|
|
131
|
+
|
|
132
|
+
reg.ring_addr = (unsigned long) ptr;
|
|
133
|
+
reg.ring_entries = 32;
|
|
134
|
+
reg.bgid = bgid;
|
|
135
|
+
|
|
136
|
+
ret = io_uring_register_buf_ring(&ring, ®, 0);
|
|
137
|
+
if (ret) {
|
|
138
|
+
fprintf(stderr, "Buffer ring register failed %d\n", ret);
|
|
139
|
+
return 1;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* check that 2nd register with same bgid fails */
|
|
143
|
+
reg.ring_addr = (unsigned long) ptr;
|
|
144
|
+
reg.ring_entries = 32;
|
|
145
|
+
reg.bgid = bgid;
|
|
146
|
+
|
|
147
|
+
ret = io_uring_register_buf_ring(&ring, ®, 0);
|
|
148
|
+
if (ret != -EEXIST) {
|
|
149
|
+
fprintf(stderr, "Buffer ring register failed %d\n", ret);
|
|
150
|
+
return 1;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
ret = io_uring_unregister_buf_ring(&ring, bgid);
|
|
154
|
+
if (ret) {
|
|
155
|
+
fprintf(stderr, "Buffer ring register failed %d\n", ret);
|
|
156
|
+
return 1;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
ret = io_uring_unregister_buf_ring(&ring, bgid);
|
|
160
|
+
if (ret != -EINVAL && ret != -ENOENT) {
|
|
161
|
+
fprintf(stderr, "Buffer ring register failed %d\n", ret);
|
|
162
|
+
return 1;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
io_uring_queue_exit(&ring);
|
|
166
|
+
return 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
static int test_reg_unreg(int bgid)
|
|
170
|
+
{
|
|
171
|
+
struct io_uring_buf_reg reg = { };
|
|
172
|
+
struct io_uring ring;
|
|
173
|
+
void *ptr;
|
|
174
|
+
int ret;
|
|
175
|
+
|
|
176
|
+
ret = t_create_ring(1, &ring, 0);
|
|
177
|
+
if (ret == T_SETUP_SKIP)
|
|
178
|
+
return 0;
|
|
179
|
+
else if (ret != T_SETUP_OK)
|
|
180
|
+
return 1;
|
|
181
|
+
|
|
182
|
+
if (posix_memalign(&ptr, 4096, 4096))
|
|
183
|
+
return 1;
|
|
184
|
+
|
|
185
|
+
reg.ring_addr = (unsigned long) ptr;
|
|
186
|
+
reg.ring_entries = 32;
|
|
187
|
+
reg.bgid = bgid;
|
|
188
|
+
|
|
189
|
+
ret = io_uring_register_buf_ring(&ring, ®, 0);
|
|
190
|
+
if (ret) {
|
|
191
|
+
if (ret == -EINVAL) {
|
|
192
|
+
no_buf_ring = 1;
|
|
193
|
+
return 0;
|
|
194
|
+
}
|
|
195
|
+
fprintf(stderr, "Buffer ring register failed %d\n", ret);
|
|
196
|
+
return 1;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
ret = io_uring_unregister_buf_ring(&ring, bgid);
|
|
200
|
+
if (ret) {
|
|
201
|
+
fprintf(stderr, "Buffer ring register failed %d\n", ret);
|
|
202
|
+
return 1;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
io_uring_queue_exit(&ring);
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
static int test_bad_reg(int bgid)
|
|
210
|
+
{
|
|
211
|
+
struct io_uring ring;
|
|
212
|
+
int ret;
|
|
213
|
+
struct io_uring_buf_reg reg = { };
|
|
214
|
+
|
|
215
|
+
ret = t_create_ring(1, &ring, 0);
|
|
216
|
+
if (ret == T_SETUP_SKIP)
|
|
217
|
+
return 0;
|
|
218
|
+
else if (ret != T_SETUP_OK)
|
|
219
|
+
return 1;
|
|
220
|
+
|
|
221
|
+
reg.ring_addr = 4096;
|
|
222
|
+
reg.ring_entries = 32;
|
|
223
|
+
reg.bgid = bgid;
|
|
224
|
+
|
|
225
|
+
ret = io_uring_register_buf_ring(&ring, ®, 0);
|
|
226
|
+
if (!ret)
|
|
227
|
+
fprintf(stderr, "Buffer ring register worked unexpectedly\n");
|
|
228
|
+
|
|
229
|
+
io_uring_queue_exit(&ring);
|
|
230
|
+
return !ret;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
static int test_one_read(int fd, int bgid, struct io_uring *ring)
|
|
234
|
+
{
|
|
235
|
+
int ret;
|
|
236
|
+
struct io_uring_cqe *cqe;
|
|
237
|
+
struct io_uring_sqe *sqe;
|
|
238
|
+
|
|
239
|
+
sqe = io_uring_get_sqe(ring);
|
|
240
|
+
if (!sqe) {
|
|
241
|
+
fprintf(stderr, "get sqe failed\n");
|
|
242
|
+
return -1;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
io_uring_prep_read(sqe, fd, NULL, 1, 0);
|
|
246
|
+
sqe->flags |= IOSQE_BUFFER_SELECT;
|
|
247
|
+
sqe->buf_group = bgid;
|
|
248
|
+
ret = io_uring_submit(ring);
|
|
249
|
+
if (ret <= 0) {
|
|
250
|
+
fprintf(stderr, "sqe submit failed: %d\n", ret);
|
|
251
|
+
return -1;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
|
255
|
+
if (ret < 0) {
|
|
256
|
+
fprintf(stderr, "wait completion %d\n", ret);
|
|
257
|
+
return -1;
|
|
258
|
+
}
|
|
259
|
+
ret = cqe->res;
|
|
260
|
+
io_uring_cqe_seen(ring, cqe);
|
|
261
|
+
|
|
262
|
+
if (ret == -ENOBUFS)
|
|
263
|
+
return ret;
|
|
264
|
+
|
|
265
|
+
if (ret != 1) {
|
|
266
|
+
fprintf(stderr, "read result %d\n", ret);
|
|
267
|
+
return -1;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return cqe->flags >> 16;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
static int test_running(int bgid, int entries, int loops)
|
|
274
|
+
{
|
|
275
|
+
struct io_uring_buf_reg reg = { };
|
|
276
|
+
struct io_uring ring;
|
|
277
|
+
void *ptr;
|
|
278
|
+
char buffer[8];
|
|
279
|
+
int ret;
|
|
280
|
+
int ring_size = (entries * sizeof(struct io_uring_buf) + 4095) & (~4095);
|
|
281
|
+
int ring_mask = io_uring_buf_ring_mask(entries);
|
|
282
|
+
|
|
283
|
+
int loop, idx;
|
|
284
|
+
bool *buffers;
|
|
285
|
+
struct io_uring_buf_ring *br;
|
|
286
|
+
int read_fd;
|
|
287
|
+
|
|
288
|
+
ret = t_create_ring(1, &ring, 0);
|
|
289
|
+
if (ret == T_SETUP_SKIP)
|
|
290
|
+
return 0;
|
|
291
|
+
else if (ret != T_SETUP_OK)
|
|
292
|
+
return 1;
|
|
293
|
+
|
|
294
|
+
if (posix_memalign(&ptr, 4096, ring_size))
|
|
295
|
+
return 1;
|
|
296
|
+
|
|
297
|
+
br = (struct io_uring_buf_ring *)ptr;
|
|
298
|
+
io_uring_buf_ring_init(br);
|
|
299
|
+
|
|
300
|
+
buffers = malloc(sizeof(bool) * entries);
|
|
301
|
+
if (!buffers)
|
|
302
|
+
return 1;
|
|
303
|
+
|
|
304
|
+
read_fd = open("/dev/zero", O_RDONLY);
|
|
305
|
+
if (read_fd < 0)
|
|
306
|
+
return 1;
|
|
307
|
+
|
|
308
|
+
reg.ring_addr = (unsigned long) ptr;
|
|
309
|
+
reg.ring_entries = entries;
|
|
310
|
+
reg.bgid = bgid;
|
|
311
|
+
|
|
312
|
+
ret = io_uring_register_buf_ring(&ring, ®, 0);
|
|
313
|
+
if (ret) {
|
|
314
|
+
/* by now should have checked if this is supported or not */
|
|
315
|
+
fprintf(stderr, "Buffer ring register failed %d\n", ret);
|
|
316
|
+
return 1;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
for (loop = 0; loop < loops; loop++) {
|
|
320
|
+
memset(buffers, 0, sizeof(bool) * entries);
|
|
321
|
+
for (idx = 0; idx < entries; idx++)
|
|
322
|
+
io_uring_buf_ring_add(br, buffer, sizeof(buffer), idx, ring_mask, idx);
|
|
323
|
+
io_uring_buf_ring_advance(br, entries);
|
|
324
|
+
|
|
325
|
+
for (idx = 0; idx < entries; idx++) {
|
|
326
|
+
memset(buffer, 1, sizeof(buffer));
|
|
327
|
+
ret = test_one_read(read_fd, bgid, &ring);
|
|
328
|
+
if (ret < 0) {
|
|
329
|
+
fprintf(stderr, "bad run %d/%d = %d\n", loop, idx, ret);
|
|
330
|
+
return ret;
|
|
331
|
+
}
|
|
332
|
+
if (buffers[ret]) {
|
|
333
|
+
fprintf(stderr, "reused buffer %d/%d = %d!\n", loop, idx, ret);
|
|
334
|
+
return 1;
|
|
335
|
+
}
|
|
336
|
+
if (buffer[0] != 0) {
|
|
337
|
+
fprintf(stderr, "unexpected read %d %d/%d = %d!\n",
|
|
338
|
+
(int)buffer[0], loop, idx, ret);
|
|
339
|
+
return 1;
|
|
340
|
+
}
|
|
341
|
+
if (buffer[1] != 1) {
|
|
342
|
+
fprintf(stderr, "unexpected spilled read %d %d/%d = %d!\n",
|
|
343
|
+
(int)buffer[1], loop, idx, ret);
|
|
344
|
+
return 1;
|
|
345
|
+
}
|
|
346
|
+
buffers[ret] = true;
|
|
347
|
+
}
|
|
348
|
+
ret = test_one_read(read_fd, bgid, &ring);
|
|
349
|
+
if (ret != -ENOBUFS) {
|
|
350
|
+
fprintf(stderr, "expected enobufs run %d = %d\n", loop, ret);
|
|
351
|
+
return 1;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
ret = io_uring_unregister_buf_ring(&ring, bgid);
|
|
357
|
+
if (ret) {
|
|
358
|
+
fprintf(stderr, "Buffer ring register failed %d\n", ret);
|
|
359
|
+
return 1;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
close(read_fd);
|
|
363
|
+
io_uring_queue_exit(&ring);
|
|
364
|
+
free(buffers);
|
|
365
|
+
return 0;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
int main(int argc, char *argv[])
|
|
369
|
+
{
|
|
370
|
+
int bgids[] = { 1, 127, -1 };
|
|
371
|
+
int entries[] = {1, 32768, 4096, -1 };
|
|
372
|
+
int ret, i;
|
|
373
|
+
|
|
374
|
+
if (argc > 1)
|
|
375
|
+
return T_EXIT_SKIP;
|
|
376
|
+
|
|
377
|
+
for (i = 0; bgids[i] != -1; i++) {
|
|
378
|
+
ret = test_reg_unreg(bgids[i]);
|
|
379
|
+
if (ret) {
|
|
380
|
+
fprintf(stderr, "test_reg_unreg failed\n");
|
|
381
|
+
return T_EXIT_FAIL;
|
|
382
|
+
}
|
|
383
|
+
if (no_buf_ring)
|
|
384
|
+
break;
|
|
385
|
+
|
|
386
|
+
ret = test_bad_reg(bgids[i]);
|
|
387
|
+
if (ret) {
|
|
388
|
+
fprintf(stderr, "test_bad_reg failed\n");
|
|
389
|
+
return T_EXIT_FAIL;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
ret = test_double_reg_unreg(bgids[i]);
|
|
393
|
+
if (ret) {
|
|
394
|
+
fprintf(stderr, "test_double_reg_unreg failed\n");
|
|
395
|
+
return T_EXIT_FAIL;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
ret = test_mixed_reg(bgids[i]);
|
|
399
|
+
if (ret) {
|
|
400
|
+
fprintf(stderr, "test_mixed_reg failed\n");
|
|
401
|
+
return T_EXIT_FAIL;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
ret = test_mixed_reg2(bgids[i]);
|
|
405
|
+
if (ret) {
|
|
406
|
+
fprintf(stderr, "test_mixed_reg2 failed\n");
|
|
407
|
+
return T_EXIT_FAIL;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
for (i = 0; !no_buf_ring && entries[i] != -1; i++) {
|
|
412
|
+
ret = test_running(2, entries[i], 3);
|
|
413
|
+
if (ret) {
|
|
414
|
+
fprintf(stderr, "test_running(%d) failed\n", entries[i]);
|
|
415
|
+
return T_EXIT_FAIL;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return T_EXIT_PASS;
|
|
420
|
+
}
|
|
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
|
|
|
46
46
|
pthread_t tid;
|
|
47
47
|
|
|
48
48
|
if (argc > 1)
|
|
49
|
-
return
|
|
49
|
+
return T_EXIT_SKIP;
|
|
50
50
|
|
|
51
51
|
/* Create an eventfd to be registered with the loop to be
|
|
52
52
|
* notified of events being ready
|
|
@@ -54,14 +54,14 @@ int main(int argc, char *argv[])
|
|
|
54
54
|
loop_fd = eventfd(0, EFD_CLOEXEC);
|
|
55
55
|
if (loop_fd == -1) {
|
|
56
56
|
fprintf(stderr, "eventfd errno=%d\n", errno);
|
|
57
|
-
return
|
|
57
|
+
return T_EXIT_FAIL;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/* Create an eventfd that can create events */
|
|
61
61
|
use_fd = other_fd = eventfd(0, EFD_CLOEXEC);
|
|
62
62
|
if (other_fd == -1) {
|
|
63
63
|
fprintf(stderr, "eventfd errno=%d\n", errno);
|
|
64
|
-
return
|
|
64
|
+
return T_EXIT_FAIL;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
if (use_sqpoll)
|
|
@@ -70,21 +70,21 @@ int main(int argc, char *argv[])
|
|
|
70
70
|
/* Setup the ring with a registered event fd to be notified on events */
|
|
71
71
|
ret = t_create_ring_params(8, &ring, &p);
|
|
72
72
|
if (ret == T_SETUP_SKIP)
|
|
73
|
-
return
|
|
73
|
+
return T_EXIT_PASS;
|
|
74
74
|
else if (ret < 0)
|
|
75
75
|
return ret;
|
|
76
76
|
|
|
77
77
|
ret = io_uring_register_eventfd(&ring, loop_fd);
|
|
78
78
|
if (ret < 0) {
|
|
79
79
|
fprintf(stderr, "register_eventfd=%d\n", ret);
|
|
80
|
-
return
|
|
80
|
+
return T_EXIT_FAIL;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
if (use_sqpoll) {
|
|
84
84
|
ret = io_uring_register_files(&ring, &other_fd, 1);
|
|
85
85
|
if (ret < 0) {
|
|
86
86
|
fprintf(stderr, "register_files=%d\n", ret);
|
|
87
|
-
return
|
|
87
|
+
return T_EXIT_FAIL;
|
|
88
88
|
}
|
|
89
89
|
use_fd = 0;
|
|
90
90
|
}
|
|
@@ -98,7 +98,7 @@ int main(int argc, char *argv[])
|
|
|
98
98
|
ret = io_uring_submit(&ring);
|
|
99
99
|
if (ret != 1) {
|
|
100
100
|
fprintf(stderr, "submit=%d\n", ret);
|
|
101
|
-
return
|
|
101
|
+
return T_EXIT_FAIL;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/*
|
|
@@ -111,13 +111,16 @@ int main(int argc, char *argv[])
|
|
|
111
111
|
(void*) (intptr_t) other_fd);
|
|
112
112
|
|
|
113
113
|
/* Wait on the event fd for an event to be ready */
|
|
114
|
-
|
|
114
|
+
do {
|
|
115
|
+
ret = read(loop_fd, buf, 8);
|
|
116
|
+
} while (ret < 0 && errno == EINTR);
|
|
117
|
+
|
|
115
118
|
if (ret < 0) {
|
|
116
119
|
perror("read");
|
|
117
|
-
return
|
|
120
|
+
return T_EXIT_FAIL;
|
|
118
121
|
} else if (ret != 8) {
|
|
119
122
|
fprintf(stderr, "Odd-sized eventfd read: %d\n", ret);
|
|
120
|
-
return
|
|
123
|
+
return T_EXIT_FAIL;
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
|
|
@@ -128,9 +131,9 @@ int main(int argc, char *argv[])
|
|
|
128
131
|
}
|
|
129
132
|
if (cqe->res < 0) {
|
|
130
133
|
fprintf(stderr, "cqe->res=%d\n", cqe->res);
|
|
131
|
-
return
|
|
134
|
+
return T_EXIT_FAIL;
|
|
132
135
|
}
|
|
133
136
|
|
|
134
137
|
io_uring_cqe_seen(&ring, cqe);
|
|
135
|
-
return
|
|
138
|
+
return T_EXIT_PASS;
|
|
136
139
|
}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
#include <arpa/inet.h>
|
|
18
18
|
|
|
19
19
|
#include "liburing.h"
|
|
20
|
+
#include "helpers.h"
|
|
20
21
|
|
|
21
22
|
static int no_connect;
|
|
22
23
|
static unsigned short use_port;
|
|
@@ -360,12 +361,12 @@ int main(int argc, char *argv[])
|
|
|
360
361
|
int ret;
|
|
361
362
|
|
|
362
363
|
if (argc > 1)
|
|
363
|
-
return
|
|
364
|
+
return T_EXIT_SKIP;
|
|
364
365
|
|
|
365
366
|
ret = io_uring_queue_init(8, &ring, 0);
|
|
366
367
|
if (ret) {
|
|
367
368
|
fprintf(stderr, "io_uring_queue_setup() = %d\n", ret);
|
|
368
|
-
return
|
|
369
|
+
return T_EXIT_FAIL;
|
|
369
370
|
}
|
|
370
371
|
|
|
371
372
|
srand(getpid());
|
|
@@ -376,23 +377,23 @@ int main(int argc, char *argv[])
|
|
|
376
377
|
ret = test_connect_with_no_peer(&ring);
|
|
377
378
|
if (ret == -1) {
|
|
378
379
|
fprintf(stderr, "test_connect_with_no_peer(): failed\n");
|
|
379
|
-
return
|
|
380
|
+
return T_EXIT_FAIL;
|
|
380
381
|
}
|
|
381
382
|
if (no_connect)
|
|
382
|
-
return
|
|
383
|
+
return T_EXIT_SKIP;
|
|
383
384
|
|
|
384
385
|
ret = test_connect(&ring);
|
|
385
386
|
if (ret == -1) {
|
|
386
387
|
fprintf(stderr, "test_connect(): failed\n");
|
|
387
|
-
return
|
|
388
|
+
return T_EXIT_FAIL;
|
|
388
389
|
}
|
|
389
390
|
|
|
390
391
|
ret = test_connect_timeout(&ring);
|
|
391
392
|
if (ret == -1) {
|
|
392
393
|
fprintf(stderr, "test_connect_timeout(): failed\n");
|
|
393
|
-
return
|
|
394
|
+
return T_EXIT_FAIL;
|
|
394
395
|
}
|
|
395
396
|
|
|
396
397
|
io_uring_queue_exit(&ring);
|
|
397
|
-
return
|
|
398
|
+
return T_EXIT_PASS;
|
|
398
399
|
}
|