diff options
author | Jens Axboe <axboe@kernel.dk> | 2020-01-26 10:40:19 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-01-26 10:40:19 -0700 |
commit | 3508db90d8cbd70e998bdeb5e0ddad1a9f577004 (patch) | |
tree | dbc4a739fe8ea8d85cb49a573f5d7f24724e31ad | |
parent | c32b6d1de68a60e008128cab2914c6448d4b4aff (diff) | |
download | liburing-3508db90d8cbd70e998bdeb5e0ddad1a9f577004.tar.gz liburing-3508db90d8cbd70e998bdeb5e0ddad1a9f577004.tar.bz2 |
test/read-write: skip non-vectored read/write if not supported
Use the IORING_REGISTER_PROBE op to test for it.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | test/read-write.c | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/test/read-write.c b/test/read-write.c index 3204d1c..face66b 100644 --- a/test/read-write.c +++ b/test/read-write.c @@ -276,9 +276,41 @@ static int read_poll_link(const char *file) return 0; } +static int has_nonvec_read(void) +{ + struct io_uring_probe *p; + struct io_uring ring; + int ret; + + ret = io_uring_queue_init(1, &ring, 0); + if (ret) { + fprintf(stderr, "queue init: %d\n", ret); + exit(ret); + } + + p = calloc(1, sizeof(*p) + 256 * sizeof(struct io_uring_probe_op)); + ret = io_uring_register_probe(&ring, p, 256); + /* if we don't have PROBE_REGISTER, we don't have OP_READ/WRITE */ + if (ret == -EINVAL) { +out: + io_uring_queue_exit(&ring); + return 0; + } else if (ret) { + fprintf(stderr, "register_probe: %d\n", ret); + goto out; + } + + if (p->ops_len <= IORING_OP_READ) + goto out; + if (!(p->ops[IORING_OP_READ].flags & IO_URING_OP_SUPPORTED)) + goto out; + io_uring_queue_exit(&ring); + return 1; +} + int main(int argc, char *argv[]) { - int i, ret; + int i, ret, nr; if (create_file(".basic-rw")) { fprintf(stderr, "file creation failed\n"); @@ -289,8 +321,13 @@ int main(int argc, char *argv[]) goto err; } - /* 6 values, 2^6 == 64 */ - for (i = 0; i < 64; i++) { + /* if we don't have nonvec read, skip testing that */ + if (has_nonvec_read()) + nr = 64; + else + nr = 32; + + for (i = 0; i < nr; i++) { int v1, v2, v3, v4, v5, v6; v1 = (i & 1) != 0; |