uringmachine 0.3 → 0.4
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/CHANGELOG.md +9 -0
- data/README.md +85 -0
- data/TODO.md +5 -0
- data/examples/echo_server.rb +18 -40
- data/examples/inout.rb +19 -0
- data/examples/nc.rb +36 -0
- data/ext/um/extconf.rb +6 -15
- data/ext/um/um.c +245 -53
- data/ext/um/um.h +21 -9
- data/ext/um/um_class.c +74 -87
- data/ext/um/um_const.c +184 -0
- data/ext/um/um_op.c +10 -13
- data/ext/um/um_utils.c +48 -3
- data/lib/uringmachine/version.rb +1 -1
- data/lib/uringmachine.rb +12 -0
- data/test/helper.rb +8 -0
- data/test/test_um.rb +227 -7
- data/vendor/liburing/.github/workflows/build.yml +29 -1
- data/vendor/liburing/.gitignore +1 -0
- data/vendor/liburing/CHANGELOG +15 -0
- data/vendor/liburing/CONTRIBUTING.md +165 -0
- data/vendor/liburing/configure +32 -0
- data/vendor/liburing/examples/Makefile +8 -1
- data/vendor/liburing/examples/kdigest.c +405 -0
- data/vendor/liburing/examples/proxy.c +75 -8
- data/vendor/liburing/liburing.pc.in +1 -1
- data/vendor/liburing/src/Makefile +16 -2
- data/vendor/liburing/src/include/liburing/io_uring.h +31 -0
- data/vendor/liburing/src/include/liburing/sanitize.h +39 -0
- data/vendor/liburing/src/include/liburing.h +31 -4
- data/vendor/liburing/src/liburing-ffi.map +5 -0
- data/vendor/liburing/src/liburing.map +1 -0
- data/vendor/liburing/src/queue.c +3 -0
- data/vendor/liburing/src/register.c +36 -0
- data/vendor/liburing/src/sanitize.c +176 -0
- data/vendor/liburing/src/setup.c +1 -1
- data/vendor/liburing/test/35fa71a030ca.c +7 -0
- data/vendor/liburing/test/500f9fbadef8.c +2 -0
- data/vendor/liburing/test/7ad0e4b2f83c.c +0 -25
- data/vendor/liburing/test/917257daa0fe.c +7 -0
- data/vendor/liburing/test/Makefile +31 -4
- data/vendor/liburing/test/a0908ae19763.c +7 -0
- data/vendor/liburing/test/a4c0b3decb33.c +7 -0
- data/vendor/liburing/test/accept.c +14 -4
- data/vendor/liburing/test/b19062a56726.c +7 -0
- data/vendor/liburing/test/bind-listen.c +2 -2
- data/vendor/liburing/test/buf-ring-nommap.c +10 -3
- data/vendor/liburing/test/buf-ring.c +2 -0
- data/vendor/liburing/test/coredump.c +7 -0
- data/vendor/liburing/test/cq-overflow.c +13 -1
- data/vendor/liburing/test/d4ae271dfaae.c +11 -3
- data/vendor/liburing/test/defer-taskrun.c +2 -2
- data/vendor/liburing/test/defer-tw-timeout.c +4 -1
- data/vendor/liburing/test/defer.c +2 -2
- data/vendor/liburing/test/double-poll-crash.c +1 -1
- data/vendor/liburing/test/eeed8b54e0df.c +2 -0
- data/vendor/liburing/test/eventfd.c +0 -1
- data/vendor/liburing/test/exit-no-cleanup.c +11 -0
- data/vendor/liburing/test/fadvise.c +9 -26
- data/vendor/liburing/test/fdinfo.c +9 -1
- data/vendor/liburing/test/file-register.c +14 -2
- data/vendor/liburing/test/file-update.c +1 -1
- data/vendor/liburing/test/file-verify.c +27 -16
- data/vendor/liburing/test/files-exit-hang-timeout.c +1 -2
- data/vendor/liburing/test/fixed-buf-iter.c +3 -1
- data/vendor/liburing/test/fixed-hugepage.c +12 -1
- data/vendor/liburing/test/fsnotify.c +1 -0
- data/vendor/liburing/test/futex.c +16 -4
- data/vendor/liburing/test/helpers.c +47 -0
- data/vendor/liburing/test/helpers.h +6 -0
- data/vendor/liburing/test/init-mem.c +5 -3
- data/vendor/liburing/test/io-cancel.c +0 -24
- data/vendor/liburing/test/io_uring_passthrough.c +2 -0
- data/vendor/liburing/test/io_uring_register.c +25 -6
- data/vendor/liburing/test/iopoll-leak.c +4 -0
- data/vendor/liburing/test/iopoll-overflow.c +1 -1
- data/vendor/liburing/test/iopoll.c +3 -3
- data/vendor/liburing/test/kallsyms.c +203 -0
- data/vendor/liburing/test/link-timeout.c +159 -0
- data/vendor/liburing/test/linked-defer-close.c +224 -0
- data/vendor/liburing/test/madvise.c +12 -25
- data/vendor/liburing/test/min-timeout-wait.c +0 -25
- data/vendor/liburing/test/min-timeout.c +0 -25
- data/vendor/liburing/test/mkdir.c +6 -0
- data/vendor/liburing/test/msg-ring.c +8 -2
- data/vendor/liburing/test/napi-test.c +15 -2
- data/vendor/liburing/test/no-mmap-inval.c +2 -0
- data/vendor/liburing/test/nop.c +44 -0
- data/vendor/liburing/test/ooo-file-unreg.c +1 -1
- data/vendor/liburing/test/open-close.c +40 -0
- data/vendor/liburing/test/openat2.c +37 -14
- data/vendor/liburing/test/poll-many.c +13 -7
- data/vendor/liburing/test/poll-mshot-update.c +17 -10
- data/vendor/liburing/test/poll-v-poll.c +6 -3
- data/vendor/liburing/test/pollfree.c +148 -0
- data/vendor/liburing/test/read-mshot-empty.c +156 -153
- data/vendor/liburing/test/read-mshot.c +276 -27
- data/vendor/liburing/test/read-write.c +78 -13
- data/vendor/liburing/test/recv-msgall-stream.c +3 -0
- data/vendor/liburing/test/recv-msgall.c +5 -0
- data/vendor/liburing/test/recvsend_bundle-inc.c +680 -0
- data/vendor/liburing/test/recvsend_bundle.c +92 -29
- data/vendor/liburing/test/reg-fd-only.c +14 -4
- data/vendor/liburing/test/regbuf-clone.c +187 -0
- data/vendor/liburing/test/regbuf-merge.c +7 -0
- data/vendor/liburing/test/register-restrictions.c +86 -85
- data/vendor/liburing/test/rename.c +59 -1
- data/vendor/liburing/test/ringbuf-read.c +5 -0
- data/vendor/liburing/test/ringbuf-status.c +5 -1
- data/vendor/liburing/test/runtests.sh +16 -1
- data/vendor/liburing/test/send-zerocopy.c +59 -0
- data/vendor/liburing/test/short-read.c +1 -0
- data/vendor/liburing/test/socket.c +43 -0
- data/vendor/liburing/test/splice.c +3 -1
- data/vendor/liburing/test/sq-poll-dup.c +1 -1
- data/vendor/liburing/test/sq-poll-share.c +2 -0
- data/vendor/liburing/test/sqpoll-disable-exit.c +8 -0
- data/vendor/liburing/test/sqpoll-exit-hang.c +1 -25
- data/vendor/liburing/test/sqpoll-sleep.c +1 -25
- data/vendor/liburing/test/statx.c +89 -0
- data/vendor/liburing/test/stdout.c +2 -0
- data/vendor/liburing/test/submit-and-wait.c +1 -25
- data/vendor/liburing/test/submit-reuse.c +4 -26
- data/vendor/liburing/test/symlink.c +12 -1
- data/vendor/liburing/test/sync-cancel.c +48 -21
- data/vendor/liburing/test/thread-exit.c +5 -0
- data/vendor/liburing/test/timeout-new.c +1 -26
- data/vendor/liburing/test/timeout.c +12 -26
- data/vendor/liburing/test/unlink.c +94 -1
- data/vendor/liburing/test/uring_cmd_ublk.c +1252 -0
- data/vendor/liburing/test/waitid.c +62 -8
- data/vendor/liburing/test/wq-aff.c +35 -0
- data/vendor/liburing/test/xfail_prep_link_timeout_out_of_scope.c +46 -0
- data/vendor/liburing/test/xfail_register_buffers_out_of_scope.c +51 -0
- metadata +17 -4
- data/examples/event_loop.rb +0 -69
- data/examples/fibers.rb +0 -105
|
@@ -114,9 +114,12 @@ run_test()
|
|
|
114
114
|
elif [ "$status" -eq 77 ]; then
|
|
115
115
|
echo "Skipped"
|
|
116
116
|
SKIPPED+=("<$test_string>")
|
|
117
|
-
elif [ "$status" -ne 0 ]; then
|
|
117
|
+
elif [[ $test_string != xfail* ]] && [ "$status" -ne 0 ]; then
|
|
118
118
|
echo "Test $test_name failed with ret $status"
|
|
119
119
|
FAILED+=("<$test_string>")
|
|
120
|
+
elif [[ $test_string == xfail* ]] && [ "$status" -ne 1 ]; then
|
|
121
|
+
echo "Test $test_name expected fail status 1 but returned $status"
|
|
122
|
+
FAILED+=("<$test_string>")
|
|
120
123
|
elif ! _check_dmesg "$dmesg_marker" "$test_name"; then
|
|
121
124
|
echo "Test $test_name failed dmesg check"
|
|
122
125
|
FAILED+=("<$test_string>")
|
|
@@ -153,10 +156,22 @@ for tst in "${TESTS[@]}"; do
|
|
|
153
156
|
fi
|
|
154
157
|
done
|
|
155
158
|
|
|
159
|
+
if [ "$DO_KMSG" -eq "1" ]; then
|
|
160
|
+
for dmesg_file in *.dmesg; do
|
|
161
|
+
if [ -f "$dmesg_file" ]; then
|
|
162
|
+
echo "Found dmesg file $dmesg_file, outputting:"
|
|
163
|
+
cat "$dmesg_file"
|
|
164
|
+
fi
|
|
165
|
+
done
|
|
166
|
+
fi
|
|
167
|
+
|
|
156
168
|
if [ "${#TIMED_OUT[*]}" -ne 0 ]; then
|
|
157
169
|
echo "Tests timed out (${#TIMED_OUT[*]}): ${TIMED_OUT[*]}"
|
|
158
170
|
fi
|
|
159
171
|
|
|
172
|
+
KVER=$(uname -rv)
|
|
173
|
+
echo "Test run complete, kernel: $KVER"
|
|
174
|
+
|
|
160
175
|
if [ "${#FAILED[*]}" -ne 0 ]; then
|
|
161
176
|
echo "Tests failed (${#FAILED[*]}): ${FAILED[*]}"
|
|
162
177
|
exit 1
|
|
@@ -739,6 +739,59 @@ static int test_async_addr(struct io_uring *ring)
|
|
|
739
739
|
return 0;
|
|
740
740
|
}
|
|
741
741
|
|
|
742
|
+
static int test_sendzc_report(struct io_uring *ring)
|
|
743
|
+
{
|
|
744
|
+
struct io_uring_sqe *sqe;
|
|
745
|
+
struct io_uring_cqe *cqe;
|
|
746
|
+
struct sockaddr_storage addr;
|
|
747
|
+
int sock_tx, sock_rx;
|
|
748
|
+
int ret;
|
|
749
|
+
|
|
750
|
+
ret = create_socketpair_ip(&addr, &sock_tx, &sock_rx, true, true, false, true);
|
|
751
|
+
if (ret) {
|
|
752
|
+
fprintf(stderr, "sock prep failed %d\n", ret);
|
|
753
|
+
return 1;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
sqe = io_uring_get_sqe(ring);
|
|
757
|
+
io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, 1, 0,
|
|
758
|
+
IORING_SEND_ZC_REPORT_USAGE);
|
|
759
|
+
ret = io_uring_submit(ring);
|
|
760
|
+
if (ret != 1) {
|
|
761
|
+
fprintf(stderr, "io_uring_submit failed %i\n", ret);
|
|
762
|
+
return 1;
|
|
763
|
+
}
|
|
764
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
|
765
|
+
if (ret) {
|
|
766
|
+
fprintf(stderr, "io_uring_wait_cqe failed %i\n", ret);
|
|
767
|
+
return 1;
|
|
768
|
+
}
|
|
769
|
+
if (cqe->res != 1 && cqe->res != -EINVAL) {
|
|
770
|
+
fprintf(stderr, "sendzc report failed %u\n", cqe->res);
|
|
771
|
+
return 1;
|
|
772
|
+
}
|
|
773
|
+
if (!(cqe->flags & IORING_CQE_F_MORE)) {
|
|
774
|
+
fprintf(stderr, "expected notification %i\n", cqe->res);
|
|
775
|
+
return 1;
|
|
776
|
+
}
|
|
777
|
+
io_uring_cqe_seen(ring, cqe);
|
|
778
|
+
|
|
779
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
|
780
|
+
if (ret) {
|
|
781
|
+
fprintf(stderr, "io_uring_wait_cqe failed %i\n", ret);
|
|
782
|
+
return 1;
|
|
783
|
+
}
|
|
784
|
+
if (cqe->flags & IORING_CQE_F_MORE) {
|
|
785
|
+
fprintf(stderr, "F_MORE after notification\n");
|
|
786
|
+
return 1;
|
|
787
|
+
}
|
|
788
|
+
io_uring_cqe_seen(ring, cqe);
|
|
789
|
+
|
|
790
|
+
close(sock_tx);
|
|
791
|
+
close(sock_rx);
|
|
792
|
+
return 0;
|
|
793
|
+
}
|
|
794
|
+
|
|
742
795
|
/* see also send_recv.c:test_invalid */
|
|
743
796
|
static int test_invalid_zc(int fds[2])
|
|
744
797
|
{
|
|
@@ -833,6 +886,12 @@ static int run_basic_tests(void)
|
|
|
833
886
|
return T_EXIT_FAIL;
|
|
834
887
|
}
|
|
835
888
|
|
|
889
|
+
ret = test_sendzc_report(&ring);
|
|
890
|
+
if (ret) {
|
|
891
|
+
fprintf(stderr, "test_sendzc_report() failed\n");
|
|
892
|
+
return T_EXIT_FAIL;
|
|
893
|
+
}
|
|
894
|
+
|
|
836
895
|
io_uring_queue_exit(&ring);
|
|
837
896
|
}
|
|
838
897
|
|
|
@@ -365,6 +365,43 @@ static int test(int use_sqthread, int regfiles, int socket_direct, int alloc)
|
|
|
365
365
|
return (intptr_t)retval;
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
+
static int test_bad_socket(void)
|
|
369
|
+
{
|
|
370
|
+
struct io_uring ring;
|
|
371
|
+
struct io_uring_cqe *cqe;
|
|
372
|
+
struct io_uring_sqe *sqe;
|
|
373
|
+
int ret;
|
|
374
|
+
|
|
375
|
+
ret = io_uring_queue_init(1, &ring, 0);
|
|
376
|
+
if (ret) {
|
|
377
|
+
fprintf(stderr, "queue init failed: %d\n", ret);
|
|
378
|
+
return 1;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
sqe = io_uring_get_sqe(&ring);
|
|
382
|
+
io_uring_prep_socket(sqe, -1, SOCK_DGRAM, 0, 0);
|
|
383
|
+
ret = io_uring_submit(&ring);
|
|
384
|
+
if (ret != 1) {
|
|
385
|
+
fprintf(stderr, "socket submit: %d\n", ret);
|
|
386
|
+
goto err;
|
|
387
|
+
}
|
|
388
|
+
ret = io_uring_wait_cqe(&ring, &cqe);
|
|
389
|
+
if (ret) {
|
|
390
|
+
fprintf(stderr, "wait_cqe: %d\n", ret);
|
|
391
|
+
goto err;
|
|
392
|
+
}
|
|
393
|
+
if (cqe->res != -EAFNOSUPPORT) {
|
|
394
|
+
fprintf(stderr, "socket res: %d\n", cqe->res);
|
|
395
|
+
goto err;
|
|
396
|
+
}
|
|
397
|
+
io_uring_cqe_seen(&ring, cqe);
|
|
398
|
+
io_uring_queue_exit(&ring);
|
|
399
|
+
return 0;
|
|
400
|
+
err:
|
|
401
|
+
io_uring_queue_exit(&ring);
|
|
402
|
+
return 1;
|
|
403
|
+
}
|
|
404
|
+
|
|
368
405
|
int main(int argc, char *argv[])
|
|
369
406
|
{
|
|
370
407
|
int ret;
|
|
@@ -404,5 +441,11 @@ int main(int argc, char *argv[])
|
|
|
404
441
|
return ret;
|
|
405
442
|
}
|
|
406
443
|
|
|
444
|
+
ret = test_bad_socket();
|
|
445
|
+
if (ret) {
|
|
446
|
+
fprintf(stderr, "test bad socket failed\n");
|
|
447
|
+
return 1;
|
|
448
|
+
}
|
|
449
|
+
|
|
407
450
|
return 0;
|
|
408
451
|
}
|
|
@@ -191,7 +191,7 @@ static int do_splice(struct io_uring *ring,
|
|
|
191
191
|
IORING_OP_SPLICE);
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
static int do_tee(struct io_uring *ring, int fd_in, int fd_out,
|
|
194
|
+
static int do_tee(struct io_uring *ring, int fd_in, int fd_out,
|
|
195
195
|
unsigned int len)
|
|
196
196
|
{
|
|
197
197
|
return do_splice_op(ring, fd_in, 0, fd_out, 0, len, IORING_OP_TEE);
|
|
@@ -504,6 +504,8 @@ int main(int argc, char *argv[])
|
|
|
504
504
|
splice_flags = SPLICE_F_FD_IN_FIXED;
|
|
505
505
|
sqe_flags = IOSQE_FIXED_FILE;
|
|
506
506
|
ret = test_splice(&ring, &ctx);
|
|
507
|
+
free(ctx.buf_in);
|
|
508
|
+
free(ctx.buf_out);
|
|
507
509
|
if (ret) {
|
|
508
510
|
fprintf(stderr, "registered fds splice tests failed\n");
|
|
509
511
|
return ret;
|
|
@@ -22,8 +22,10 @@
|
|
|
22
22
|
#include <unistd.h>
|
|
23
23
|
|
|
24
24
|
#include "liburing.h"
|
|
25
|
+
#include "helpers.h"
|
|
25
26
|
#include "../src/syscall.h"
|
|
26
27
|
|
|
28
|
+
#ifndef CONFIG_USE_SANITIZER
|
|
27
29
|
static void sleep_ms(uint64_t ms)
|
|
28
30
|
{
|
|
29
31
|
usleep(ms * 1000);
|
|
@@ -194,3 +196,9 @@ int main(void)
|
|
|
194
196
|
loop();
|
|
195
197
|
return 0;
|
|
196
198
|
}
|
|
199
|
+
#else
|
|
200
|
+
int main(int argc, char *argv[])
|
|
201
|
+
{
|
|
202
|
+
return T_EXIT_SKIP;
|
|
203
|
+
}
|
|
204
|
+
#endif
|
|
@@ -10,31 +10,7 @@
|
|
|
10
10
|
#include <sys/time.h>
|
|
11
11
|
#include <poll.h>
|
|
12
12
|
#include "liburing.h"
|
|
13
|
-
|
|
14
|
-
static unsigned long long mtime_since(const struct timeval *s,
|
|
15
|
-
const struct timeval *e)
|
|
16
|
-
{
|
|
17
|
-
long long sec, usec;
|
|
18
|
-
|
|
19
|
-
sec = e->tv_sec - s->tv_sec;
|
|
20
|
-
usec = (e->tv_usec - s->tv_usec);
|
|
21
|
-
if (sec > 0 && usec < 0) {
|
|
22
|
-
sec--;
|
|
23
|
-
usec += 1000000;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
sec *= 1000;
|
|
27
|
-
usec /= 1000;
|
|
28
|
-
return sec + usec;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static unsigned long long mtime_since_now(struct timeval *tv)
|
|
32
|
-
{
|
|
33
|
-
struct timeval end;
|
|
34
|
-
|
|
35
|
-
gettimeofday(&end, NULL);
|
|
36
|
-
return mtime_since(tv, &end);
|
|
37
|
-
}
|
|
13
|
+
#include "helpers.h"
|
|
38
14
|
|
|
39
15
|
int main(int argc, char *argv[])
|
|
40
16
|
{
|
|
@@ -9,31 +9,7 @@
|
|
|
9
9
|
#include <unistd.h>
|
|
10
10
|
#include <sys/time.h>
|
|
11
11
|
#include "liburing.h"
|
|
12
|
-
|
|
13
|
-
static unsigned long long mtime_since(const struct timeval *s,
|
|
14
|
-
const struct timeval *e)
|
|
15
|
-
{
|
|
16
|
-
long long sec, usec;
|
|
17
|
-
|
|
18
|
-
sec = e->tv_sec - s->tv_sec;
|
|
19
|
-
usec = (e->tv_usec - s->tv_usec);
|
|
20
|
-
if (sec > 0 && usec < 0) {
|
|
21
|
-
sec--;
|
|
22
|
-
usec += 1000000;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
sec *= 1000;
|
|
26
|
-
usec /= 1000;
|
|
27
|
-
return sec + usec;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static unsigned long long mtime_since_now(struct timeval *tv)
|
|
31
|
-
{
|
|
32
|
-
struct timeval end;
|
|
33
|
-
|
|
34
|
-
gettimeofday(&end, NULL);
|
|
35
|
-
return mtime_since(tv, &end);
|
|
36
|
-
}
|
|
12
|
+
#include "helpers.h"
|
|
37
13
|
|
|
38
14
|
int main(int argc, char *argv[])
|
|
39
15
|
{
|
|
@@ -36,6 +36,81 @@ static int statx_syscall_supported(void)
|
|
|
36
36
|
return errno == ENOSYS ? 0 : -1;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
static int test_statx_invalid_buf(struct io_uring *ring, const char *path)
|
|
40
|
+
{
|
|
41
|
+
struct io_uring_cqe *cqe;
|
|
42
|
+
struct io_uring_sqe *sqe;
|
|
43
|
+
struct statx *x = (struct statx *) (uintptr_t) 0x1234;
|
|
44
|
+
int ret;
|
|
45
|
+
|
|
46
|
+
sqe = io_uring_get_sqe(ring);
|
|
47
|
+
if (!sqe) {
|
|
48
|
+
fprintf(stderr, "get sqe failed\n");
|
|
49
|
+
goto err;
|
|
50
|
+
}
|
|
51
|
+
io_uring_prep_statx(sqe, -1, path, 0, STATX_ALL, x);
|
|
52
|
+
|
|
53
|
+
ret = io_uring_submit(ring);
|
|
54
|
+
if (ret <= 0) {
|
|
55
|
+
fprintf(stderr, "sqe submit failed: %d\n", ret);
|
|
56
|
+
goto err;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
|
60
|
+
if (ret < 0) {
|
|
61
|
+
fprintf(stderr, "wait completion %d\n", ret);
|
|
62
|
+
goto err;
|
|
63
|
+
}
|
|
64
|
+
ret = cqe->res;
|
|
65
|
+
io_uring_cqe_seen(ring, cqe);
|
|
66
|
+
if (ret != -EFAULT) {
|
|
67
|
+
fprintf(stderr, "Invalid address didn't fail\n");
|
|
68
|
+
goto err;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return 0;
|
|
72
|
+
err:
|
|
73
|
+
return -1;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static int test_statx_invalid_path(struct io_uring *ring)
|
|
77
|
+
{
|
|
78
|
+
const char *path = (const char *) (uintptr_t) 0x1234;
|
|
79
|
+
struct io_uring_cqe *cqe;
|
|
80
|
+
struct io_uring_sqe *sqe;
|
|
81
|
+
struct statx x1 = { };
|
|
82
|
+
int ret;
|
|
83
|
+
|
|
84
|
+
sqe = io_uring_get_sqe(ring);
|
|
85
|
+
if (!sqe) {
|
|
86
|
+
fprintf(stderr, "get sqe failed\n");
|
|
87
|
+
goto err;
|
|
88
|
+
}
|
|
89
|
+
io_uring_prep_statx(sqe, -1, path, 0, STATX_ALL, &x1);
|
|
90
|
+
|
|
91
|
+
ret = io_uring_submit(ring);
|
|
92
|
+
if (ret <= 0) {
|
|
93
|
+
fprintf(stderr, "sqe submit failed: %d\n", ret);
|
|
94
|
+
goto err;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
|
98
|
+
if (ret < 0) {
|
|
99
|
+
fprintf(stderr, "wait completion %d\n", ret);
|
|
100
|
+
goto err;
|
|
101
|
+
}
|
|
102
|
+
ret = cqe->res;
|
|
103
|
+
io_uring_cqe_seen(ring, cqe);
|
|
104
|
+
if (ret != -EFAULT) {
|
|
105
|
+
fprintf(stderr, "Invalid address didn't fail\n");
|
|
106
|
+
goto err;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return 0;
|
|
110
|
+
err:
|
|
111
|
+
return -1;
|
|
112
|
+
}
|
|
113
|
+
|
|
39
114
|
static int test_statx(struct io_uring *ring, const char *path)
|
|
40
115
|
{
|
|
41
116
|
struct io_uring_cqe *cqe;
|
|
@@ -86,6 +161,8 @@ static int test_statx_fd(struct io_uring *ring, const char *path)
|
|
|
86
161
|
|
|
87
162
|
fd = open(path, O_RDONLY);
|
|
88
163
|
if (fd < 0) {
|
|
164
|
+
if (errno == EPERM || errno == EACCES)
|
|
165
|
+
return 0;
|
|
89
166
|
perror("open");
|
|
90
167
|
return 1;
|
|
91
168
|
}
|
|
@@ -156,6 +233,18 @@ int main(int argc, char *argv[])
|
|
|
156
233
|
goto err;
|
|
157
234
|
}
|
|
158
235
|
|
|
236
|
+
ret = test_statx_invalid_path(&ring);
|
|
237
|
+
if (ret) {
|
|
238
|
+
fprintf(stderr, "test_statx_invalid_path failed: %d\n", ret);
|
|
239
|
+
goto err;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
ret = test_statx_invalid_buf(&ring, fname);
|
|
243
|
+
if (ret) {
|
|
244
|
+
fprintf(stderr, "test_statx_invalid_buf failed: %d\n", ret);
|
|
245
|
+
goto err;
|
|
246
|
+
}
|
|
247
|
+
|
|
159
248
|
ret = test_statx_fd(&ring, fname);
|
|
160
249
|
if (ret) {
|
|
161
250
|
fprintf(stderr, "test_statx_fd failed: %d\n", ret);
|
|
@@ -89,6 +89,7 @@ static int test_pipe_io_fixed(struct io_uring *ring)
|
|
|
89
89
|
io_uring_cqe_seen(ring, cqe);
|
|
90
90
|
}
|
|
91
91
|
io_uring_unregister_buffers(ring);
|
|
92
|
+
free(vecs[0].iov_base);
|
|
92
93
|
return 0;
|
|
93
94
|
err:
|
|
94
95
|
return 1;
|
|
@@ -143,6 +144,7 @@ static int test_stdout_io_fixed(struct io_uring *ring)
|
|
|
143
144
|
}
|
|
144
145
|
io_uring_cqe_seen(ring, cqe);
|
|
145
146
|
io_uring_unregister_buffers(ring);
|
|
147
|
+
free(vecs.iov_base);
|
|
146
148
|
return 0;
|
|
147
149
|
err:
|
|
148
150
|
return 1;
|
|
@@ -13,33 +13,9 @@
|
|
|
13
13
|
#include <sys/time.h>
|
|
14
14
|
|
|
15
15
|
#include "liburing.h"
|
|
16
|
+
#include "helpers.h"
|
|
16
17
|
#include "test.h"
|
|
17
18
|
|
|
18
|
-
static unsigned long long mtime_since(const struct timeval *s,
|
|
19
|
-
const struct timeval *e)
|
|
20
|
-
{
|
|
21
|
-
long long sec, usec;
|
|
22
|
-
|
|
23
|
-
sec = e->tv_sec - s->tv_sec;
|
|
24
|
-
usec = (e->tv_usec - s->tv_usec);
|
|
25
|
-
if (sec > 0 && usec < 0) {
|
|
26
|
-
sec--;
|
|
27
|
-
usec += 1000000;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
sec *= 1000;
|
|
31
|
-
usec /= 1000;
|
|
32
|
-
return sec + usec;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static unsigned long long mtime_since_now(struct timeval *tv)
|
|
36
|
-
{
|
|
37
|
-
struct timeval end;
|
|
38
|
-
|
|
39
|
-
gettimeofday(&end, NULL);
|
|
40
|
-
return mtime_since(tv, &end);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
19
|
static int test(struct io_uring *ring)
|
|
44
20
|
{
|
|
45
21
|
struct io_uring_cqe *cqe;
|
|
@@ -102,31 +102,6 @@ static int wait_nr(int nr)
|
|
|
102
102
|
return 0;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
static unsigned long long mtime_since(const struct timeval *s,
|
|
106
|
-
const struct timeval *e)
|
|
107
|
-
{
|
|
108
|
-
long long sec, usec;
|
|
109
|
-
|
|
110
|
-
sec = e->tv_sec - s->tv_sec;
|
|
111
|
-
usec = (e->tv_usec - s->tv_usec);
|
|
112
|
-
if (sec > 0 && usec < 0) {
|
|
113
|
-
sec--;
|
|
114
|
-
usec += 1000000;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
sec *= 1000;
|
|
118
|
-
usec /= 1000;
|
|
119
|
-
return sec + usec;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
static unsigned long long mtime_since_now(struct timeval *tv)
|
|
123
|
-
{
|
|
124
|
-
struct timeval end;
|
|
125
|
-
|
|
126
|
-
gettimeofday(&end, NULL);
|
|
127
|
-
return mtime_since(tv, &end);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
105
|
static int test_reuse(int argc, char *argv[], int split, int async)
|
|
131
106
|
{
|
|
132
107
|
struct thread_data data;
|
|
@@ -162,6 +137,8 @@ static int test_reuse(int argc, char *argv[], int split, int async)
|
|
|
162
137
|
if (do_unlink)
|
|
163
138
|
unlink(fname1);
|
|
164
139
|
if (fd1 < 0) {
|
|
140
|
+
if (errno == EPERM || errno == EACCES)
|
|
141
|
+
return T_EXIT_SKIP;
|
|
165
142
|
perror("open fname1");
|
|
166
143
|
goto err;
|
|
167
144
|
}
|
|
@@ -211,7 +188,6 @@ static int test_reuse(int argc, char *argv[], int split, int async)
|
|
|
211
188
|
err:
|
|
212
189
|
io_uring_queue_exit(&ring);
|
|
213
190
|
return 1;
|
|
214
|
-
|
|
215
191
|
}
|
|
216
192
|
|
|
217
193
|
int main(int argc, char *argv[])
|
|
@@ -225,6 +201,8 @@ int main(int argc, char *argv[])
|
|
|
225
201
|
async = (i & 2) != 0;
|
|
226
202
|
|
|
227
203
|
ret = test_reuse(argc, argv, split, async);
|
|
204
|
+
if (ret == T_EXIT_SKIP)
|
|
205
|
+
continue;
|
|
228
206
|
if (ret) {
|
|
229
207
|
fprintf(stderr, "test_reuse %d %d failed\n", split, async);
|
|
230
208
|
return ret;
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
#include "liburing.h"
|
|
13
13
|
|
|
14
|
-
|
|
15
14
|
static int do_symlinkat(struct io_uring *ring, const char *oldname, const char *newname)
|
|
16
15
|
{
|
|
17
16
|
int ret;
|
|
@@ -105,6 +104,18 @@ int main(int argc, char *argv[])
|
|
|
105
104
|
goto err1;
|
|
106
105
|
}
|
|
107
106
|
|
|
107
|
+
ret = do_symlinkat(&ring, target, (const char *) (uintptr_t) 0x1234);
|
|
108
|
+
if (ret != -EFAULT) {
|
|
109
|
+
fprintf(stderr, "test_symlinkat bad target failed: %d\n", ret);
|
|
110
|
+
goto err1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
ret = do_symlinkat(&ring, (const char *) (uintptr_t) 0x1234, target);
|
|
114
|
+
if (ret != -EFAULT) {
|
|
115
|
+
fprintf(stderr, "test_symlinkat bad source failed: %d\n", ret);
|
|
116
|
+
goto err1;
|
|
117
|
+
}
|
|
118
|
+
|
|
108
119
|
out:
|
|
109
120
|
unlinkat(AT_FDCWD, linkname, 0);
|
|
110
121
|
io_uring_queue_exit(&ring);
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
static int no_sync_cancel;
|
|
17
17
|
|
|
18
|
-
static int test_sync_cancel_timeout(struct io_uring *ring, int async)
|
|
18
|
+
static int test_sync_cancel_timeout(struct io_uring *ring, int async, int by_op)
|
|
19
19
|
{
|
|
20
20
|
struct io_uring_sync_cancel_reg reg = { };
|
|
21
21
|
struct io_uring_sqe *sqe;
|
|
@@ -43,7 +43,8 @@ static int test_sync_cancel_timeout(struct io_uring *ring, int async)
|
|
|
43
43
|
|
|
44
44
|
usleep(10000);
|
|
45
45
|
|
|
46
|
-
reg.
|
|
46
|
+
reg.flags = IORING_ASYNC_CANCEL_OP;
|
|
47
|
+
reg.opcode = IORING_OP_READ;
|
|
47
48
|
reg.timeout.tv_nsec = 1;
|
|
48
49
|
ret = io_uring_register_sync_cancel(ring, ®);
|
|
49
50
|
if (async) {
|
|
@@ -80,7 +81,7 @@ static int test_sync_cancel_timeout(struct io_uring *ring, int async)
|
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
static int test_sync_cancel(struct io_uring *ring, int async, int nr_all,
|
|
83
|
-
int use_fd)
|
|
84
|
+
int use_fd, int by_op)
|
|
84
85
|
{
|
|
85
86
|
struct io_uring_sync_cancel_reg reg = { };
|
|
86
87
|
struct io_uring_sqe *sqe;
|
|
@@ -168,7 +169,7 @@ int main(int argc, char *argv[])
|
|
|
168
169
|
else if (ret != T_SETUP_OK)
|
|
169
170
|
return ret;
|
|
170
171
|
|
|
171
|
-
ret = test_sync_cancel(&ring, 0, 0, 0);
|
|
172
|
+
ret = test_sync_cancel(&ring, 0, 0, 0, 0);
|
|
172
173
|
if (ret) {
|
|
173
174
|
fprintf(stderr, "test_sync_cancel 0 0 0 failed\n");
|
|
174
175
|
return T_EXIT_FAIL;
|
|
@@ -176,56 +177,82 @@ int main(int argc, char *argv[])
|
|
|
176
177
|
if (no_sync_cancel)
|
|
177
178
|
return T_EXIT_SKIP;
|
|
178
179
|
|
|
179
|
-
ret = test_sync_cancel(&ring,
|
|
180
|
+
ret = test_sync_cancel(&ring, 0, 0, 0, 1);
|
|
180
181
|
if (ret) {
|
|
181
|
-
fprintf(stderr, "test_sync_cancel
|
|
182
|
+
fprintf(stderr, "test_sync_cancel 0 0 1 failed\n");
|
|
182
183
|
return T_EXIT_FAIL;
|
|
183
184
|
}
|
|
184
185
|
|
|
185
|
-
ret = test_sync_cancel(&ring, 0,
|
|
186
|
+
ret = test_sync_cancel(&ring, 1, 0, 0, 0);
|
|
186
187
|
if (ret) {
|
|
187
|
-
fprintf(stderr, "test_sync_cancel 0
|
|
188
|
+
fprintf(stderr, "test_sync_cancel 1 0 0 0 failed\n");
|
|
188
189
|
return T_EXIT_FAIL;
|
|
189
190
|
}
|
|
190
191
|
|
|
191
|
-
ret = test_sync_cancel(&ring, 1,
|
|
192
|
+
ret = test_sync_cancel(&ring, 1, 0, 0, 1);
|
|
192
193
|
if (ret) {
|
|
193
|
-
fprintf(stderr, "test_sync_cancel 1
|
|
194
|
+
fprintf(stderr, "test_sync_cancel 1 0 0 1 failed\n");
|
|
194
195
|
return T_EXIT_FAIL;
|
|
195
196
|
}
|
|
196
197
|
|
|
197
|
-
|
|
198
|
+
|
|
199
|
+
ret = test_sync_cancel(&ring, 0, 1, 0, 0);
|
|
198
200
|
if (ret) {
|
|
199
|
-
fprintf(stderr, "test_sync_cancel 0 0
|
|
201
|
+
fprintf(stderr, "test_sync_cancel 0 1 0 0 failed\n");
|
|
202
|
+
return T_EXIT_FAIL;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
ret = test_sync_cancel(&ring, 0, 1, 0, 1);
|
|
206
|
+
if (ret) {
|
|
207
|
+
fprintf(stderr, "test_sync_cancel 0 1 0 1 failed\n");
|
|
208
|
+
return T_EXIT_FAIL;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
ret = test_sync_cancel(&ring, 1, 1, 0, 0);
|
|
213
|
+
if (ret) {
|
|
214
|
+
fprintf(stderr, "test_sync_cancel 1 1 0 0 failed\n");
|
|
215
|
+
return T_EXIT_FAIL;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
ret = test_sync_cancel(&ring, 0, 0, 1, 0);
|
|
219
|
+
if (ret) {
|
|
220
|
+
fprintf(stderr, "test_sync_cancel 0 0 1 0 failed\n");
|
|
221
|
+
return T_EXIT_FAIL;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
ret = test_sync_cancel(&ring, 1, 0, 1, 0);
|
|
225
|
+
if (ret) {
|
|
226
|
+
fprintf(stderr, "test_sync_cancel 1 0 1 0 failed\n");
|
|
200
227
|
return T_EXIT_FAIL;
|
|
201
228
|
}
|
|
202
229
|
|
|
203
|
-
ret = test_sync_cancel(&ring, 1,
|
|
230
|
+
ret = test_sync_cancel(&ring, 0, 1, 1, 0);
|
|
204
231
|
if (ret) {
|
|
205
|
-
fprintf(stderr, "test_sync_cancel 1 0
|
|
232
|
+
fprintf(stderr, "test_sync_cancel 0 1 1 0 failed\n");
|
|
206
233
|
return T_EXIT_FAIL;
|
|
207
234
|
}
|
|
208
235
|
|
|
209
|
-
ret = test_sync_cancel(&ring,
|
|
236
|
+
ret = test_sync_cancel(&ring, 1, 1, 1, 0);
|
|
210
237
|
if (ret) {
|
|
211
|
-
fprintf(stderr, "test_sync_cancel
|
|
238
|
+
fprintf(stderr, "test_sync_cancel 1 1 1 0 failed\n");
|
|
212
239
|
return T_EXIT_FAIL;
|
|
213
240
|
}
|
|
214
241
|
|
|
215
|
-
ret =
|
|
242
|
+
ret = test_sync_cancel_timeout(&ring, 0, 0);
|
|
216
243
|
if (ret) {
|
|
217
|
-
fprintf(stderr, "
|
|
244
|
+
fprintf(stderr, "test_sync_cancel_timeout 0 0\n");
|
|
218
245
|
return T_EXIT_FAIL;
|
|
219
246
|
}
|
|
220
247
|
|
|
221
|
-
ret = test_sync_cancel_timeout(&ring, 0);
|
|
248
|
+
ret = test_sync_cancel_timeout(&ring, 0, 1);
|
|
222
249
|
if (ret) {
|
|
223
|
-
fprintf(stderr, "test_sync_cancel_timeout 0\n");
|
|
250
|
+
fprintf(stderr, "test_sync_cancel_timeout 0 1\n");
|
|
224
251
|
return T_EXIT_FAIL;
|
|
225
252
|
}
|
|
226
253
|
|
|
227
254
|
/* must be last, leaves request */
|
|
228
|
-
ret = test_sync_cancel_timeout(&ring, 1);
|
|
255
|
+
ret = test_sync_cancel_timeout(&ring, 1, 0);
|
|
229
256
|
if (ret) {
|
|
230
257
|
fprintf(stderr, "test_sync_cancel_timeout 1\n");
|
|
231
258
|
return T_EXIT_FAIL;
|
|
@@ -102,6 +102,8 @@ int main(int argc, char *argv[])
|
|
|
102
102
|
if (do_unlink)
|
|
103
103
|
unlink(fname);
|
|
104
104
|
if (fd < 0) {
|
|
105
|
+
if (errno == EPERM || errno == EACCES)
|
|
106
|
+
goto skip;
|
|
105
107
|
perror("open");
|
|
106
108
|
return 1;
|
|
107
109
|
}
|
|
@@ -140,4 +142,7 @@ int main(int argc, char *argv[])
|
|
|
140
142
|
err:
|
|
141
143
|
free_g_buf();
|
|
142
144
|
return 1;
|
|
145
|
+
skip:
|
|
146
|
+
free_g_buf();
|
|
147
|
+
return T_EXIT_SKIP;
|
|
143
148
|
}
|