summaryrefslogtreecommitdiff
path: root/test/read-write.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-01-24 23:08:25 -0700
committerJens Axboe <axboe@kernel.dk>2020-01-24 23:08:25 -0700
commit5c0772a5b840f562206a40a548615c1a40e864aa (patch)
treec4738066023ddc4729b4bef71317c2c60cf2bfe5 /test/read-write.c
parentb769750865618d56cc8f201f2eb65f157315004f (diff)
downloadliburing-5c0772a5b840f562206a40a548615c1a40e864aa.tar.gz
liburing-5c0772a5b840f562206a40a548615c1a40e864aa.tar.bz2
test/read-write: add non-vectored read/write testing
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'test/read-write.c')
-rw-r--r--test/read-write.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/test/read-write.c b/test/read-write.c
index d150f44..3204d1c 100644
--- a/test/read-write.c
+++ b/test/read-write.c
@@ -52,13 +52,14 @@ static int create_file(const char *file)
}
static int test_io(const char *file, int write, int buffered, int sqthread,
- int fixed, int mixed_fixed)
+ int fixed, int mixed_fixed, int nonvec)
{
struct io_uring_sqe *sqe;
struct io_uring_cqe *cqe;
struct io_uring ring;
int open_flags, ring_flags;
int i, fd, ret;
+ static int warned;
#ifdef VERBOSE
fprintf(stdout, "%s: start %d/%d/%d/%d/%d: ", __FUNCTION__, write,
@@ -131,6 +132,9 @@ static int test_io(const char *file, int write, int buffered, int sqthread,
io_uring_prep_write_fixed(sqe, use_fd, vecs[i].iov_base,
vecs[i].iov_len,
offset, i);
+ } else if (nonvec) {
+ io_uring_prep_write(sqe, use_fd, vecs[i].iov_base,
+ vecs[i].iov_len, offset);
} else {
io_uring_prep_writev(sqe, use_fd, &vecs[i], 1,
offset);
@@ -147,6 +151,9 @@ static int test_io(const char *file, int write, int buffered, int sqthread,
io_uring_prep_read_fixed(sqe, use_fd, vecs[i].iov_base,
vecs[i].iov_len,
offset, i);
+ } else if (nonvec) {
+ io_uring_prep_read(sqe, use_fd, vecs[i].iov_base,
+ vecs[i].iov_len, offset);
} else {
io_uring_prep_readv(sqe, use_fd, &vecs[i], 1,
offset);
@@ -169,7 +176,13 @@ static int test_io(const char *file, int write, int buffered, int sqthread,
fprintf(stderr, "wait_cqe=%d\n", ret);
goto err;
}
- if (cqe->res != BS) {
+ if (cqe->res == -EINVAL && nonvec) {
+ if (!warned) {
+ fprintf(stdout, "Non-vectored IO not "
+ "supported, skipping\n");
+ warned = 1;
+ }
+ } else if (cqe->res != BS) {
fprintf(stderr, "cqe res %d, wanted %d\n", cqe->res, BS);
goto err;
}
@@ -276,19 +289,20 @@ int main(int argc, char *argv[])
goto err;
}
- /* 5 values, 2^5 == 32 */
- for (i = 0; i < 32; i++) {
- int v1, v2, v3, v4, v5;
+ /* 6 values, 2^6 == 64 */
+ for (i = 0; i < 64; i++) {
+ int v1, v2, v3, v4, v5, v6;
v1 = (i & 1) != 0;
v2 = (i & 2) != 0;
v3 = (i & 4) != 0;
v4 = (i & 8) != 0;
v5 = (i & 16) != 0;
- ret = test_io(".basic-rw", v1, v2, v3, v4, v5);
+ v6 = (i & 32) != 0;
+ ret = test_io(".basic-rw", v1, v2, v3, v4, v5, v6);
if (ret) {
- fprintf(stderr, "test_io failed %d/%d/%d/%d/%d\n",
- v1, v2, v3, v4, v5);
+ fprintf(stderr, "test_io failed %d/%d/%d/%d/%d/%d\n",
+ v1, v2, v3, v4, v5, v6);
goto err;
}
}