summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-09-06 13:21:05 -0600
committerJens Axboe <axboe@kernel.dk>2019-09-06 13:21:05 -0600
commite2937e9e773717e54d5df35e842a1578cf2cbe25 (patch)
treec00ecb14c2c2a43b69797b97f61c206c5ace39e6
parentdfdf94f214c96d5f74f9879df9e924ebb651f00a (diff)
downloadliburing-e2937e9e773717e54d5df35e842a1578cf2cbe25.tar.gz
liburing-e2937e9e773717e54d5df35e842a1578cf2cbe25.tar.bz2
test/io_uring_setup: add support for io_uring_params->features
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/io_uring_setup.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/test/io_uring_setup.c b/test/io_uring_setup.c
index 2dd3763..5ce460d 100644
--- a/test/io_uring_setup.c
+++ b/test/io_uring_setup.c
@@ -15,6 +15,24 @@
#include <sys/sysinfo.h>
#include "liburing.h"
+char *features_string(struct io_uring_params *p)
+{
+ static char flagstr[64];
+
+ if (!p || !p->features)
+ return "none";
+
+ if (p->features & ~IORING_FEAT_SINGLE_MMAP) {
+ snprintf(flagstr, 64, "0x%.8x", p->features);
+ return flagstr;
+ }
+
+ if (p->features & IORING_FEAT_SINGLE_MMAP)
+ strncat(flagstr, "IORING_FEAT_SINGLE_MMAP", 64 - strlen(flagstr));
+
+ return flagstr;
+}
+
/*
* Attempt the call with the given args. Return 0 when expect matches
* the return value of the system call, 1 otherwise.
@@ -67,8 +85,8 @@ dump_resv(struct io_uring_params *p)
if (!p)
return "";
- sprintf(resvstr, "0x%.8x 0x%.8x 0x%.8x 0x%.8x 0x%.8x", p->resv[0],
- p->resv[1], p->resv[2], p->resv[3], p->resv[4]);
+ sprintf(resvstr, "0x%.8x 0x%.8x 0x%.8x 0x%.8x", p->resv[0],
+ p->resv[1], p->resv[2], p->resv[3]);
return resvstr;
}
@@ -80,8 +98,8 @@ try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect, int
{
int ret, __errno;
- printf("io_uring_setup(%u, %p), flags: %s, resv: %s, sq_thread_cpu: %u\n",
- entries, p, flags_string(p), dump_resv(p),
+ printf("io_uring_setup(%u, %p), flags: %s, feat: %s, resv: %s, sq_thread_cpu: %u\n",
+ entries, p, flags_string(p), features_string(p), dump_resv(p),
p ? p->sq_thread_cpu : 0);
ret = io_uring_setup(entries, p);
@@ -118,7 +136,7 @@ main(int argc, char **argv)
/* resv array is non-zero */
memset(&p, 0, sizeof(p));
- p.resv[0] = p.resv[1] = p.resv[2] = p.resv[3] = p.resv[4] = 1;
+ p.resv[0] = p.resv[1] = p.resv[2] = p.resv[3] = 1;
status |= try_io_uring_setup(1, &p, -1, EINVAL);
/* invalid flags */