* [PATCH liburing 1/1] tests/timeout: add abs imm timeout test
@ 2026-03-02 16:40 Pavel Begunkov
2026-03-02 16:42 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2026-03-02 16:40 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence, axboe
Add a simple test for absolute immediate argument timeout.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/timeout.c | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/test/timeout.c b/test/timeout.c
index 6bef0a7e..0ca387ba 100644
--- a/test/timeout.c
+++ b/test/timeout.c
@@ -31,18 +31,19 @@ static void msec_to_ts(struct __kernel_timespec *ts, unsigned int msec)
ts->tv_nsec = (msec % 1000) * 1000000;
}
-static void t_prep_timeout_rel(struct io_uring_sqe *sqe,
- const struct __kernel_timespec *ts,
- bool immediate)
+static void t_prep_timeout(struct io_uring_sqe *sqe,
+ const struct __kernel_timespec *ts,
+ unsigned flags,
+ bool immediate)
{
if (!immediate) {
io_uring_prep_timeout(sqe, ts, 0, 0);
- return;
+ } else {
+ io_uring_prep_timeout(sqe, NULL, 0, 0);
+ sqe->addr = ts->tv_sec * 1000000000 + ts->tv_nsec;
+ sqe->timeout_flags = IORING_TIMEOUT_IMMEDIATE_ARG;
}
-
- io_uring_prep_timeout(sqe, NULL, 0, 0);
- sqe->addr = ts->tv_sec * 1000000000 + ts->tv_nsec;
- sqe->timeout_flags = IORING_TIMEOUT_IMMEDIATE_ARG;
+ sqe->timeout_flags |= flags;
}
/*
@@ -65,7 +66,7 @@ static int test_single_timeout_many(struct io_uring *ring, bool immediate)
}
msec_to_ts(&ts, TIMEOUT_MSEC);
- t_prep_timeout_rel(sqe, &ts, immediate);
+ t_prep_timeout(sqe, &ts, 0, immediate);
ret = io_uring_submit(ring);
if (ret <= 0) {
@@ -250,7 +251,7 @@ static int test_single_timeout(struct io_uring *ring, bool immediate)
}
msec_to_ts(&ts, TIMEOUT_MSEC);
- t_prep_timeout_rel(sqe, &ts, immediate);
+ t_prep_timeout(sqe, &ts, 0, immediate);
ret = io_uring_submit(ring);
if (ret <= 0) {
@@ -436,7 +437,7 @@ err:
/*
* Test single absolute timeout waking us up
*/
-static int test_single_timeout_abs(struct io_uring *ring)
+static int test_single_timeout_abs(struct io_uring *ring, bool immediate)
{
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
@@ -455,7 +456,7 @@ static int test_single_timeout_abs(struct io_uring *ring)
clock_gettime(CLOCK_MONOTONIC, &abs_ts);
ts.tv_sec = abs_ts.tv_sec + 1;
ts.tv_nsec = abs_ts.tv_nsec;
- io_uring_prep_timeout(sqe, &ts, 0, IORING_TIMEOUT_ABS);
+ t_prep_timeout(sqe, &ts, IORING_TIMEOUT_ABS, immediate);
ret = io_uring_submit(ring);
if (ret <= 0) {
@@ -1805,12 +1806,20 @@ int main(int argc, char *argv[])
return ret;
}
- ret = test_single_timeout_abs(&ring);
+ ret = test_single_timeout_abs(&ring, false);
if (ret) {
fprintf(stderr, "test_single_timeout_abs failed\n");
return ret;
}
+ if (!no_immediate) {
+ ret = test_single_timeout_abs(&ring, true);
+ if (ret) {
+ fprintf(stderr, "test_single_timeout_abs (imm) failed\n");
+ return ret;
+ }
+ }
+
ret = test_single_timeout_remove(&ring);
if (ret) {
fprintf(stderr, "test_single_timeout_remove failed\n");
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH liburing 1/1] tests/timeout: add abs imm timeout test
2026-03-02 16:40 [PATCH liburing 1/1] tests/timeout: add abs imm timeout test Pavel Begunkov
@ 2026-03-02 16:42 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2026-03-02 16:42 UTC (permalink / raw)
To: io-uring, Pavel Begunkov
On Mon, 02 Mar 2026 16:40:00 +0000, Pavel Begunkov wrote:
> Add a simple test for absolute immediate argument timeout.
>
>
Applied, thanks!
[1/1] tests/timeout: add abs imm timeout test
commit: 829c805c7285c31d099166708c92e459fa1bc397
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-02 16:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-02 16:40 [PATCH liburing 1/1] tests/timeout: add abs imm timeout test Pavel Begunkov
2026-03-02 16:42 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox