Signed-off-by: Pavel Begunkov --- test/helpers.c | 17 +++++++++++++++++ test/helpers.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/test/helpers.c b/test/helpers.c index 05895486..18af2be8 100644 --- a/test/helpers.c +++ b/test/helpers.c @@ -509,3 +509,20 @@ void t_clear_nonblock(int fd) { __t_toggle_nonblock(fd, 0); } + +int t_submit_and_wait_single(struct io_uring *ring, struct io_uring_cqe **cqe) +{ + int ret; + + ret = io_uring_submit(ring); + if (ret <= 0) { + fprintf(stderr, "sqe submit failed: %d\n", ret); + return -1; + } + ret = io_uring_wait_cqe(ring, cqe); + if (ret < 0) { + fprintf(stderr, "wait completion %d\n", ret); + return ret; + } + return 0; +} diff --git a/test/helpers.h b/test/helpers.h index 3f0c11ab..b7465890 100644 --- a/test/helpers.h +++ b/test/helpers.h @@ -122,6 +122,8 @@ unsigned long long mtime_since_now(struct timeval *tv); unsigned long long utime_since(const struct timeval *s, const struct timeval *e); unsigned long long utime_since_now(struct timeval *tv); +int t_submit_and_wait_single(struct io_uring *ring, struct io_uring_cqe **cqe); + #ifdef __cplusplus } #endif -- 2.49.0