From 7a1dbbd4f93f7e6221eab7f8c26b464685728bf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Anic=CC=81?= Date: Wed, 8 Nov 2023 18:25:29 +0100 Subject: [PATCH] fix io_uring timeout_remove test on kernel 5.4 There is no grantee that `copy_cqes` will return exactly wait_nr number of cqes. If there are ready cqes it can return > 0 but < wait_nr number of cqes. --- lib/std/os/linux/io_uring.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig index d90561e6e4..2372dba09b 100644 --- a/lib/std/os/linux/io_uring.zig +++ b/lib/std/os/linux/io_uring.zig @@ -2329,7 +2329,8 @@ test "timeout_remove" { // * kernel 5.18 gives user data 0x99999999 first, 0x88888888 second var cqes: [2]os.linux.io_uring_cqe = undefined; - try testing.expectEqual(@as(u32, 2), try ring.copy_cqes(cqes[0..], 2)); + cqes[0] = try ring.copy_cqe(); + cqes[1] = try ring.copy_cqe(); for (cqes) |cqe| { // IORING_OP_TIMEOUT_REMOVE is not supported by this kernel version: